Skip to content

Commit cc77bc9

Browse files
committed
ci: Reusable workflow for sync
Reusable workflow for syncing kernel-topics automerge Signed-off-by: Vishal Kumar <viskuma@qti.qualcomm.com>
1 parent c2c9f6a commit cc77bc9

3 files changed

Lines changed: 97 additions & 9 deletions

File tree

.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: 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 "github-actions@github.com"
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 https://github.com/qualcomm-linux/kernel.git qcom-next
59+
topic https://github.com/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: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ 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_url: ${{ github.event.repository.html_url }}
22+
pr_number: ${{ github.event.pull_request.number }}
2123

2224
- name: Pull docker image
2325
uses: ./.github/actions/pull_docker_image
@@ -30,9 +32,11 @@ jobs:
3032
uses: ./.github/actions/build
3133
with:
3234
docker_image: ${{ inputs.docker_image }}
35+
workspace_path: ${{ steps.sync.outputs.workspace_path }}
3336

3437
- name: Create file list for artifacts upload
3538
run: |
39+
cd ${{ steps.sync.outputs.workspace_path }}
3640
touch ../artifacts/file_list.txt
3741
tar -cJf modules.tar.xz ../kobj/tar-install/lib/modules/
3842
echo "modules.tar.xz" >> ../artifacts/file_list.txt
@@ -44,13 +48,12 @@ jobs:
4448
uses: ./.github/actions/aws_s3_helper
4549
with:
4650
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
51+
local_file: ${{ steps.sync.outputs.workspace_path }}/../artifacts/file_list.txt
5052
mode: multi-upload
5153

5254
- name: Clean up
5355
run: |
56+
cd ${{ steps.sync.outputs.workspace_path }}
5457
rm -rf ../artifacts
5558
rm -rf ../kobj
5659
rm -rf modules.tar.xz
@@ -68,7 +71,6 @@ jobs:
6871
fi
6972
SUMMARY='
7073
<details><summary><i>Build Summary</i></summary>
71-
7274
'${summary}'
7375
</details>
7476
'

0 commit comments

Comments
 (0)