Skip to content

Commit 48397b3

Browse files
committed
ci: Reusable workflow for sync
Reusable workflow for syncing kernel-topics automerge Signed-off-by: Vishal Kumar <[email protected]>
1 parent c2c9f6a commit 48397b3

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed

.github/actions/build/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ inputs:
66
description: Docker image
77
required: true
88
default: kmake-image:latest
9+
workspace_path:
10+
description: Workspace path
11+
required: true
912

1013
runs:
1114
using: "composite"
1215
steps:
1316
- name: Download artifacts
1417
shell: bash
1518
run: |
19+
cd ${{ inputs.workspace_path }}
1620
mkdir -p ../artifacts && \
1721
wget -O ../artifacts/ramdisk.gz https://snapshots.linaro.org/member-builds/qcomlt/testimages/arm64/1379/initramfs-test-image-qemuarm64-20230321073831-1379.rootfs.cpio.gz && \
1822
wget -O ../artifacts/systemd-boot-efi.deb http://ports.ubuntu.com/pool/universe/s/systemd/systemd-boot-efi_255.4-1ubuntu8_arm64.deb && \
@@ -21,6 +25,7 @@ runs:
2125
- name: Make
2226
shell: bash
2327
run: |
28+
cd ${{ inputs.workspace_path }}
2429
docker run -i --rm \
2530
--user $(id -u):$(id -g) \
2631
--workdir="$PWD" \
@@ -34,4 +39,6 @@ runs:
3439
- name: Package DLKM into ramdisk
3540
shell: bash
3641
run: |
37-
(cd ../kobj/tar-install ; find lib/modules | cpio -o -H newc -R +0:+0 | gzip -9 >> ../../artifacts/ramdisk.gz)
42+
cd ${{ inputs.workspace_path }}
43+
(cd ../kobj/tar-install ; find lib/modules | cpio -o -H newc -R +0:+0 | gzip -9 >> ../../artifacts/ramdisk.gz)
44+

.github/actions/sync/action.yml

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

.github/workflows/build.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ jobs:
1313
group: GHA-Kernel-SelfHosted-RG
1414
labels: [ self-hosted, kernel-prd-u2404-x64-large-od-ephem ]
1515
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v4
16+
- name: Sync codebase
17+
id: sync
18+
uses: ./.github/actions/sync
1819
with:
19-
ref: ${{ github.ref }}
20-
fetch-depth: 0
20+
base_branch: ${{ github.base_ref }}
21+
pr_number: ${{ github.event.pull_request.number }}
2122

2223
- name: Pull docker image
2324
uses: ./.github/actions/pull_docker_image
@@ -30,9 +31,11 @@ jobs:
3031
uses: ./.github/actions/build
3132
with:
3233
docker_image: ${{ inputs.docker_image }}
34+
workspace_path: ${{ steps.sync.outputs.workspace_path }}
3335

3436
- name: Create file list for artifacts upload
3537
run: |
38+
cd ${{ steps.sync.outputs.workspace_path }}
3639
touch ../artifacts/file_list.txt
3740
tar -cJf modules.tar.xz ../kobj/tar-install/lib/modules/
3841
echo "modules.tar.xz" >> ../artifacts/file_list.txt
@@ -44,13 +47,12 @@ jobs:
4447
uses: ./.github/actions/aws_s3_helper
4548
with:
4649
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+
local_file: ${{ steps.sync.outputs.workspace_path }}/../artifacts/file_list.txt
5051
mode: multi-upload
5152

5253
- name: Clean up
5354
run: |
55+
cd ${{ steps.sync.outputs.workspace_path }}
5456
rm -rf ../artifacts
5557
rm -rf ../kobj
5658
rm -rf modules.tar.xz
@@ -68,7 +70,6 @@ jobs:
6870
fi
6971
SUMMARY='
7072
<details><summary><i>Build Summary</i></summary>
71-
7273
'${summary}'
7374
</details>
7475
'

0 commit comments

Comments
 (0)