From 9d9adb80db3ba599884d6ef8493a9e8f3c9d8ca3 Mon Sep 17 00:00:00 2001 From: Naveen Naidu Date: Mon, 9 Jun 2025 13:32:44 +0530 Subject: [PATCH] .github/workflows/diff-ceph-config.yml: use --ref-commit-sha and --cmp-commit-sha update the config_diff.py to use `--ref-commit-sha` and `--cmp-commit-sha` to repliace the three-dot diff [1] that Github uses for showing it's diff. This way we only output the configuration changes that have been made in the PR. Signed-off-by: Naveen Naidu --- .github/workflows/diff-ceph-config.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/diff-ceph-config.yml b/.github/workflows/diff-ceph-config.yml index 53f15f04b71d0..ce1c51ec408a7 100644 --- a/.github/workflows/diff-ceph-config.yml +++ b/.github/workflows/diff-ceph-config.yml @@ -20,12 +20,30 @@ jobs: - name: checkout ceph.git uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 with: + ref: ${{ github.event.pull_request.head.sha }} path: ceph sparse-checkout: | src/script src/common/options .github/workflows + - name: 'Get common ancestor between PR and ceph upstream main branch' + id: get_common_ancestor + env: + branch_pr: origin/${{ github.event.pull_request.head.ref }} + refspec_pr: +${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }} + working-directory: ceph + run: | + # Fetch enough history to find a common ancestor commit (aka merge-base): + git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \ + --no-tags --prune --no-recurse-submodules + + # This should get the oldest commit in the local fetched history (the commit in ceph upstream from which PR branched from): + COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 ${{ env.branch_pr }} ) + COMMON_ANCESTOR_SHA=$( git log --format=%H "${COMMON_ANCESTOR}" ) + + echo "COMMON_ANCESTOR_SHA=${COMMON_ANCESTOR_SHA}" >> $GITHUB_ENV + - name: Setup Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0 with: @@ -41,12 +59,14 @@ jobs: env: REF_REPO: ${{ github.event.pull_request.base.repo.clone_url }} REF_BRANCH: ${{ github.event.pull_request.base.ref }} + REF_COMMIT_SHA: ${{ env.COMMON_ANCESTOR_SHA }} REMOTE_REPO: ${{ github.event.pull_request.head.repo.clone_url }} REMOTE_BRANCH: ${{ github.event.pull_request.head.ref }} + REMOTE_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} run: | { echo 'DIFF_JSON<> "$GITHUB_OUTPUT" working-directory: ceph -- 2.39.5