Skip to content

Commit ee83901

Browse files
committed
ci: Reusable pre merge workflow
Make pre-merge workflow reusable for kernel-topics and kernel repository Signed-off-by: Vishal Kumar <[email protected]>
1 parent 8e30800 commit ee83901

File tree

4 files changed

+295
-207
lines changed

4 files changed

+295
-207
lines changed

.github/actions/build/action.yml

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
name: Build workspace
2-
description: Build workspace
3-
4-
inputs:
5-
docker_image:
6-
description: Docker image
7-
required: true
8-
default: kmake-image:latest
9-
10-
runs:
11-
using: "composite"
12-
steps:
13-
- name: Download artifacts
14-
shell: bash
15-
run: |
16-
mkdir -p ../artifacts && \
17-
wget -O ../artifacts/ramdisk.gz https://snapshots.linaro.org/member-builds/qcomlt/testimages/arm64/1379/initramfs-test-image-qemuarm64-20230321073831-1379.rootfs.cpio.gz && \
18-
wget -O ../artifacts/systemd-boot-efi.deb http://ports.ubuntu.com/pool/universe/s/systemd/systemd-boot-efi_255.4-1ubuntu8_arm64.deb && \
19-
dpkg-deb -xv ../artifacts/systemd-boot-efi.deb ../artifacts/systemd
20-
21-
- name: Make
22-
shell: bash
23-
run: |
24-
docker run -i --rm \
25-
--user $(id -u):$(id -g) \
26-
--workdir="$PWD" \
27-
-v "$(dirname $PWD)":"$(dirname $PWD)" \
28-
${{ inputs.docker_image }} bash -c "
29-
make O=../kobj defconfig
30-
make O=../kobj -j$(nproc)
31-
make O=../kobj -j$(nproc) dir-pkg INSTALL_MOD_STRIP=1
32-
"
33-
34-
- name: Package DLKM into ramdisk
35-
shell: bash
36-
run: |
1+
name: Build workspace
2+
description: Build workspace
3+
4+
inputs:
5+
docker_image:
6+
description: Docker image
7+
required: true
8+
default: kmake-image:latest
9+
workspace_path:
10+
description: Workspace path
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Download artifacts
17+
shell: bash
18+
run: |
19+
cd ${{ inputs.workspace_path }}
20+
mkdir -p ../artifacts && \
21+
wget -O ../artifacts/ramdisk.gz https://snapshots.linaro.org/member-builds/qcomlt/testimages/arm64/1379/initramfs-test-image-qemuarm64-20230321073831-1379.rootfs.cpio.gz && \
22+
wget -O ../artifacts/systemd-boot-efi.deb http://ports.ubuntu.com/pool/universe/s/systemd/systemd-boot-efi_255.4-1ubuntu8_arm64.deb && \
23+
dpkg-deb -xv ../artifacts/systemd-boot-efi.deb ../artifacts/systemd
24+
25+
- name: Make
26+
shell: bash
27+
run: |
28+
cd ${{ inputs.workspace_path }}
29+
docker run -i --rm \
30+
--user $(id -u):$(id -g) \
31+
--workdir="$PWD" \
32+
-v "$(dirname $PWD)":"$(dirname $PWD)" \
33+
${{ inputs.docker_image }} bash -c "
34+
make O=../kobj defconfig
35+
make O=../kobj -j$(nproc)
36+
make O=../kobj -j$(nproc) dir-pkg INSTALL_MOD_STRIP=1
37+
"
38+
39+
- name: Package DLKM into ramdisk
40+
shell: bash
41+
run: |
42+
cd ${{ inputs.workspace_path }}
3743
(cd ../kobj/tar-install ; find lib/modules | cpio -o -H newc -R +0:+0 | gzip -9 >> ../../artifacts/ramdisk.gz)

.github/actions/sync/action.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Sync workspace
2+
3+
inputs:
4+
base_branch:
5+
description: Base branch
6+
required: true
7+
default: qcom-next-staging
8+
pr_url:
9+
description: PR url
10+
required: false
11+
pr_number:
12+
description: PR number
13+
required: false
14+
15+
outputs:
16+
workspace_path:
17+
description: Sync workspace path
18+
value: ${{ steps.set-workspace.outputs.workspace }}
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- name: Checkout PR branch
24+
if: ${{ inputs.base_branch }} == 'qcom-next-staging'
25+
uses: actions/checkout@v4
26+
shell: bash
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Configure git
31+
shell: bash
32+
run: |
33+
git config --global user.name "github-actions"
34+
git config --global user.email "[email protected]"
35+
36+
- name: Sync with latest changes
37+
if: ${{ inputs.base_branch }} == 'qcom-next-staging'
38+
shell: bash
39+
run: |
40+
set -e
41+
echo "Syncing with latest changes..."
42+
git fetch origin ${{ inputs.base_branch }}
43+
git merge --no-ff origin/${{ inputs.base_branch }}
44+
45+
- name: Clone repositories
46+
if: ${{ inputs.base_branch }} != 'qcom-next-staging'
47+
shell: bash
48+
run: |
49+
git clone https://github.com/qualcomm-linux/kernel.git
50+
git clone https://github.com/qualcomm-linux/automerge.git
51+
52+
- name: Create merge configuration
53+
if: ${{ inputs.base_branch }} != 'qcom-next-staging'
54+
shell: bash
55+
run: |
56+
TOPIC_BRANCH=${{ inputs.base_branch }}
57+
cat <<EOF > merge.conf
58+
baseline [email protected]:qualcomm-linux/kernel.git qcom-next
59+
topic [email protected]:qualcomm-linux/kernel-topics.git $TOPIC_BRANCH
60+
pr ${{ inputs.pr_url }} pull/${{ inputs.pr_number }}/head
61+
EOF
62+
echo "File 'merge.conf' created successfully."
63+
64+
- name: Run auto merge
65+
id: automerge
66+
if: ${{ inputs.base_branch }} != 'qcom-next-staging'
67+
shell: bash
68+
run: |
69+
cd kernel
70+
../automerge/ci-merge -f ../merge.conf -t head -n
71+
72+
- name: Set workspace path
73+
id: set-workspace
74+
shell: bash
75+
run: |
76+
if [[ "${{ inputs.base_branch }}" == "qcom-next-staging" ]]; then
77+
echo "workspace=${{ github.workspace }}" >> "$GITHUB_OUTPUT"
78+
else
79+
echo "workspace=${{ github.workspace }}/kernel" >> "$GITHUB_OUTPUT"

.github/workflows/build.yml

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,78 @@
1-
name: _build
2-
on:
3-
workflow_call:
4-
inputs:
5-
docker_image:
6-
description: Docker image
7-
type: string
8-
required: true
9-
10-
jobs:
11-
build:
12-
runs-on:
13-
group: GHA-Kernel-SelfHosted-RG
14-
labels: [ self-hosted, kernel-prd-u2404-x64-large-od-ephem ]
15-
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v4
18-
with:
19-
ref: ${{ github.ref }}
20-
fetch-depth: 0
21-
22-
- name: Pull docker image
23-
uses: ./.github/actions/pull_docker_image
24-
with:
25-
image: ${{ inputs.docker_image }}
26-
github_token: ${{ secrets.GITHUB_TOKEN }}
27-
28-
- name: Build workspace
29-
id: build_workspace
30-
uses: ./.github/actions/build
31-
with:
32-
docker_image: ${{ inputs.docker_image }}
33-
34-
- name: Create file list for artifacts upload
35-
run: |
36-
touch ../artifacts/file_list.txt
37-
tar -cJf modules.tar.xz ../kobj/tar-install/lib/modules/
38-
echo "modules.tar.xz" >> ../artifacts/file_list.txt
39-
echo "../kobj/arch/arm64/boot/Image" >> ../artifacts/file_list.txt
40-
echo "../kobj/vmlinux" >> ../artifacts/file_list.txt
41-
echo "../kobj/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dtb" >> ../artifacts/file_list.txt
42-
43-
- name: Upload artifacts
44-
uses: ./.github/actions/aws_s3_helper
45-
with:
46-
s3_bucket: qli-prd-kernel-gh-artifacts
47-
aws_access_key_id: ${{ secrets.AWSKEYID }}
48-
aws_secret_access_key: ${{ secrets.AWSACCESSKEY }}
49-
local_file: ../artifacts/file_list.txt
50-
mode: multi-upload
51-
52-
- name: Clean up
53-
run: |
54-
rm -rf ../artifacts
55-
rm -rf ../kobj
56-
rm -rf modules.tar.xz
57-
58-
- name: Update summary
59-
if: success() || failure()
60-
shell: bash
61-
run: |
62-
if [ ${{ steps.build_workspace.outcome }} == 'success' ]; then
63-
echo "Build was successful"
64-
summary=":heavy_check_mark: Build Success"
65-
else
66-
echo "Build failed"
67-
summary=":x: Build Failed"
68-
fi
69-
SUMMARY='
70-
<details><summary><i>Build Summary</i></summary>
71-
72-
'${summary}'
73-
</details>
74-
'
1+
name: _build
2+
on:
3+
workflow_call:
4+
inputs:
5+
docker_image:
6+
description: Docker image
7+
type: string
8+
required: true
9+
10+
jobs:
11+
build:
12+
runs-on:
13+
group: GHA-Kernel-SelfHosted-RG
14+
labels: [ self-hosted, kernel-prd-u2404-x64-large-od-ephem ]
15+
steps:
16+
- name: Sync codebase
17+
id: sync
18+
uses: ./.github/actions/sync
19+
with:
20+
base_branch: ${{ github.base_ref }}
21+
pr_url: ${{ github.event.pull_request.ssh_url }}
22+
pr_number: ${{ github.event.pull_request.number }}
23+
24+
- name: Pull docker image
25+
uses: ./.github/actions/pull_docker_image
26+
with:
27+
image: ${{ inputs.docker_image }}
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Build workspace
31+
id: build_workspace
32+
uses: ./.github/actions/build
33+
with:
34+
docker_image: ${{ inputs.docker_image }}
35+
workspace_path: ${{ steps.sync.outputs.workspace_path }}
36+
37+
- name: Create file list for artifacts upload
38+
run: |
39+
cd ${{ steps.sync.outputs.workspace_path }}
40+
touch ../artifacts/file_list.txt
41+
tar -cJf modules.tar.xz ../kobj/tar-install/lib/modules/
42+
echo "modules.tar.xz" >> ../artifacts/file_list.txt
43+
echo "../kobj/arch/arm64/boot/Image" >> ../artifacts/file_list.txt
44+
echo "../kobj/vmlinux" >> ../artifacts/file_list.txt
45+
echo "../kobj/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dtb" >> ../artifacts/file_list.txt
46+
47+
- name: Upload artifacts
48+
uses: ./.github/actions/aws_s3_helper
49+
with:
50+
s3_bucket: qli-prd-kernel-gh-artifacts
51+
local_file: ${{ steps.sync.outputs.workspace_path }}/../artifacts/file_list.txt
52+
mode: multi-upload
53+
54+
- name: Clean up
55+
run: |
56+
cd ${{ steps.sync.outputs.workspace_path }}
57+
rm -rf ../artifacts
58+
rm -rf ../kobj
59+
rm -rf modules.tar.xz
60+
61+
- name: Update summary
62+
if: success() || failure()
63+
shell: bash
64+
run: |
65+
if [ ${{ steps.build_workspace.outcome }} == 'success' ]; then
66+
echo "Build was successful"
67+
summary=":heavy_check_mark: Build Success"
68+
else
69+
echo "Build failed"
70+
summary=":x: Build Failed"
71+
fi
72+
SUMMARY='
73+
<details><summary><i>Build Summary</i></summary>
74+
75+
'${summary}'
76+
</details>
77+
'
7578
echo -e "$SUMMARY" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)