@@ -12,12 +12,12 @@ jobs:
12
12
uses : actions/checkout@v4
13
13
with :
14
14
submodules : recursive
15
+ fetch-depth : 0
15
16
16
- - name : Pull container image
17
- run : ./.ci/run-container-ci pull
18
-
19
- - name : Run CI in container
20
- run : ./.ci/run-container-ci ${{github.workspace}} ${{ github.base_ref }}
17
+ - name : CI
18
+ uses : ./.github/actions/pr-ci-common
19
+ with :
20
+ base-sha : ${{ github.event.pull_request.base.sha }}
21
21
22
22
# Generate a list of commits to run CI on
23
23
generate-matrix :
34
34
- name : Create jobs for commits in PR history
35
35
id : set-matrix
36
36
run : |
37
- echo matrix=$(.ci/matrix-from-commit-log origin/ ${{github.base_ref }}..${{ github.event.pull_request.head.sha}}~) >> $GITHUB_OUTPUT
37
+ echo matrix=$(.ci/matrix-from-commit-log ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}~) >> $GITHUB_OUTPUT
38
38
39
39
# Run this job for every commit in the PR except HEAD.
40
+ # This job simulates what github does for the PR HEAD commit but for every other commit in the
41
+ # PR. So for every commit, it creates a merge commit between that commit and the base branch.
42
+ # Then it runs the CI on that merge commit.
43
+ # The only caveat is that this file (pr-ci.yml) is already loaded from the PR HEAD merge commit,
44
+ # and therefore we need to load the `.ci` scripts from the PR HEAD merge commit. The outcome of
45
+ # that is that changes to the CI is not tested per commit. All commits use the final version.
40
46
pr-commit-ci :
41
47
runs-on : ubuntu-22.04
42
48
needs : [ generate-matrix ]
@@ -58,13 +64,14 @@ jobs:
58
64
GIT_COMMITTER_NAME : Bot
59
65
GIT_COMMITTER_EMAIL :
[email protected]
60
66
run : |
61
- git fetch origin ${{ matrix.commit }}
67
+ git fetch origin ${{ matrix.commit }} ${{ github.event.pull_request.merge_commit_sha }}
62
68
git merge --no-ff --no-edit ${{ matrix.commit }}
63
- echo "merge commit parents:"
64
69
git log -1 --format="Head %H, Parents %P"
70
+ # Since the workflow definition is taken from the pull request merge commit, we need to
71
+ # get the .ci scripts from there as well.
72
+ git checkout -f ${{ github.event.pull_request.merge_commit_sha }} -- .ci .github
65
73
66
- - name : Pull container image
67
- run : ./.ci/run-container-ci pull
68
-
69
- - name : Run CI in container
70
- run : ./.ci/run-container-ci ${{github.workspace}} ${{ github.base_ref }}
74
+ - name : CI
75
+ uses : ./.github/actions/pr-ci-common
76
+ with :
77
+ base-sha : ${{ github.event.pull_request.base.sha }}
0 commit comments