Skip to content

Commit 9d9adb8

Browse files
committed
.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 <[email protected]>
1 parent bf2aa92 commit 9d9adb8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.github/workflows/diff-ceph-config.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,30 @@ jobs:
2020
- name: checkout ceph.git
2121
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
2222
with:
23+
ref: ${{ github.event.pull_request.head.sha }}
2324
path: ceph
2425
sparse-checkout: |
2526
src/script
2627
src/common/options
2728
.github/workflows
2829
30+
- name: 'Get common ancestor between PR and ceph upstream main branch'
31+
id: get_common_ancestor
32+
env:
33+
branch_pr: origin/${{ github.event.pull_request.head.ref }}
34+
refspec_pr: +${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}
35+
working-directory: ceph
36+
run: |
37+
# Fetch enough history to find a common ancestor commit (aka merge-base):
38+
git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \
39+
--no-tags --prune --no-recurse-submodules
40+
41+
# This should get the oldest commit in the local fetched history (the commit in ceph upstream from which PR branched from):
42+
COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 ${{ env.branch_pr }} )
43+
COMMON_ANCESTOR_SHA=$( git log --format=%H "${COMMON_ANCESTOR}" )
44+
45+
echo "COMMON_ANCESTOR_SHA=${COMMON_ANCESTOR_SHA}" >> $GITHUB_ENV
46+
2947
- name: Setup Python
3048
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0
3149
with:
@@ -41,12 +59,14 @@ jobs:
4159
env:
4260
REF_REPO: ${{ github.event.pull_request.base.repo.clone_url }}
4361
REF_BRANCH: ${{ github.event.pull_request.base.ref }}
62+
REF_COMMIT_SHA: ${{ env.COMMON_ANCESTOR_SHA }}
4463
REMOTE_REPO: ${{ github.event.pull_request.head.repo.clone_url }}
4564
REMOTE_BRANCH: ${{ github.event.pull_request.head.ref }}
65+
REMOTE_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
4666
run: |
4767
{
4868
echo 'DIFF_JSON<<EOF'
49-
python3 ./src/script/config-diff/config_diff.py diff-branch-remote-repo --ref-branch $REF_BRANCH --remote-repo $REMOTE_REPO --cmp-branch $REMOTE_BRANCH --format=posix-diff --skip-clone
69+
python3 ./src/script/config-diff/config_diff.py diff-branch-remote-repo --ref-branch $REF_BRANCH --ref-commit-sha $REF_COMMIT_SHA --remote-repo $REMOTE_REPO --cmp-branch $REMOTE_BRANCH --cmp-commit-sha $REMOTE_COMMIT_SHA --format=posix-diff --skip-clone
5070
echo EOF
5171
} >> "$GITHUB_OUTPUT"
5272
working-directory: ceph

0 commit comments

Comments
 (0)