From 6924ecfc29968d9d3f698c141958b4530b01ee74 Mon Sep 17 00:00:00 2001 From: Vishal Kumar Date: Tue, 27 May 2025 14:53:03 +0530 Subject: [PATCH] ci: Reusable workflow for sync Reusable workflow for syncing kernel & kernel-topics workspace Kernel - It will be having only the checkout code with PR data Kernel topics - It needs to clone the kernel repo and automerge tool, Creates a merge.conf which will be containing git remotes of qcom-next and topic branch then it fetches the PR data and merge on top of integration branch. Signed-off-by: Vishal Kumar --- .github/actions/build/action.yml | 9 +++- .github/actions/sync/action.yml | 84 ++++++++++++++++++++++++++++++++ .github/workflows/build.yml | 17 ++++--- 3 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 .github/actions/sync/action.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index c998e4d418cf9..809183151550f 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -6,6 +6,9 @@ inputs: description: Docker image required: true default: kmake-image:latest + workspace_path: + description: Workspace path + required: true runs: using: "composite" @@ -13,6 +16,7 @@ runs: - name: Download artifacts shell: bash run: | + cd ${{ inputs.workspace_path }} mkdir -p ../artifacts && \ wget -O ../artifacts/ramdisk.gz https://snapshots.linaro.org/member-builds/qcomlt/testimages/arm64/1379/initramfs-test-image-qemuarm64-20230321073831-1379.rootfs.cpio.gz && \ 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: - name: Make shell: bash run: | + cd ${{ inputs.workspace_path }} docker run -i --rm \ --user $(id -u):$(id -g) \ --workdir="$PWD" \ @@ -34,4 +39,6 @@ runs: - name: Package DLKM into ramdisk shell: bash run: | - (cd ../kobj/tar-install ; find lib/modules | cpio -o -H newc -R +0:+0 | gzip -9 >> ../../artifacts/ramdisk.gz) \ No newline at end of file + cd ${{ inputs.workspace_path }} + (cd ../kobj/tar-install ; find lib/modules | cpio -o -H newc -R +0:+0 | gzip -9 >> ../../artifacts/ramdisk.gz) + diff --git a/.github/actions/sync/action.yml b/.github/actions/sync/action.yml new file mode 100644 index 0000000000000..f3c852977500a --- /dev/null +++ b/.github/actions/sync/action.yml @@ -0,0 +1,84 @@ +name: Sync workspace + +inputs: + base_branch: + description: Base branch + required: true + default: qcom-next-staging + pr_number: + description: PR number + required: false + +outputs: + workspace_path: + description: Sync workspace path + value: ${{ steps.set-workspace.outputs.workspace }} + +runs: + using: "composite" + steps: + - name: Checkout PR branch + if: inputs.base_branch == 'qcom-next-staging' + uses: actions/checkout@v4 + shell: bash + with: + fetch-depth: 0 + + - name: Configure git + shell: bash + run: | + git config --global user.name "github-actions" + git config --global user.email "github-actions@github.com" + + - name: Sync with latest changes + if: inputs.base_branch == 'qcom-next-staging' + shell: bash + run: | + set -e + echo "Syncing with latest changes..." + git fetch origin ${{ inputs.base_branch }} + git merge --no-ff origin/${{ inputs.base_branch }} + + - name: Clone repositories + if: inputs.base_branch != 'qcom-next-staging' + shell: bash + run: | + git clone https://github.com/qualcomm-linux/kernel.git + git clone https://github.com/qualcomm-linux/automerge.git + + - name: Create merge configuration + if: inputs.base_branch != 'qcom-next-staging' + shell: bash + run: | + TOPIC_BRANCH=${{ inputs.base_branch }} + cat < merge.conf + baseline https://github.com/qualcomm-linux/kernel.git qcom-next + topic https://github.com/qualcomm-linux/kernel-topics.git $TOPIC_BRANCH + EOF + echo "File 'merge.conf' created successfully." + + - name: Run auto merge + id: automerge + if: inputs.base_branch != 'qcom-next-staging' + shell: bash + run: | + cd kernel + ../automerge/ci-merge -f ../merge.conf -t head -n + + - name: Fetch PR + if: inputs.base_branch != 'qcom-next-staging' + shell: bash + run: | + cd kernel + git fetch https://github.com/qualcomm-linux/kernel-topics.git pull/${{inputs.pr_number}}/head:pr-${{inputs.pr_number}} + git merge pr-${{inputs.pr_number}} --no-commit + git commit -m "Merged PR ${{inputs.pr_number}}" + + - name: Set workspace path + id: set-workspace + shell: bash + run: | + if [[ "${{ inputs.base_branch }}" == "qcom-next-staging" ]]; then + echo "workspace=${{ github.workspace }}" >> "$GITHUB_OUTPUT" + else + echo "workspace=${{ github.workspace }}/kernel" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad565b476c3a1..93989491dd61c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,11 +13,12 @@ jobs: group: GHA-Kernel-SelfHosted-RG labels: [ self-hosted, kernel-prd-u2404-x64-large-od-ephem ] steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Sync codebase + id: sync + uses: ./.github/actions/sync with: - ref: ${{ github.ref }} - fetch-depth: 0 + base_branch: ${{ github.base_ref }} + pr_number: ${{ github.event.pull_request.number }} - name: Pull docker image uses: ./.github/actions/pull_docker_image @@ -30,9 +31,11 @@ jobs: uses: ./.github/actions/build with: docker_image: ${{ inputs.docker_image }} + workspace_path: ${{ steps.sync.outputs.workspace_path }} - name: Create file list for artifacts upload run: | + cd ${{ steps.sync.outputs.workspace_path }} touch ../artifacts/file_list.txt tar -cJf modules.tar.xz ../kobj/tar-install/lib/modules/ echo "modules.tar.xz" >> ../artifacts/file_list.txt @@ -44,13 +47,12 @@ jobs: uses: ./.github/actions/aws_s3_helper with: s3_bucket: qli-prd-kernel-gh-artifacts - aws_access_key_id: ${{ secrets.AWSKEYID }} - aws_secret_access_key: ${{ secrets.AWSACCESSKEY }} - local_file: ../artifacts/file_list.txt + local_file: ${{ steps.sync.outputs.workspace_path }}/../artifacts/file_list.txt mode: multi-upload - name: Clean up run: | + cd ${{ steps.sync.outputs.workspace_path }} rm -rf ../artifacts rm -rf ../kobj rm -rf modules.tar.xz @@ -68,7 +70,6 @@ jobs: fi SUMMARY='
Build Summary - '${summary}'
'