Skip to content

Commit fa6299e

Browse files
committed
CI: prevent mismatch between workflows and checkout
As of commit cadbfbb, GitHub Actions CI does the following on pull requests: 1. Merge the pull request source with the destination 2. If the merge succeeded: a. Read workflow files from the merged commit b. Run each workflow: i. 'git clone', creating a checkout at the pull request source Importantly, the Git commit used for the workflow files is different from the Git commit used for the checkout. This causes problems with a workflow file assumes a newer checkout. (For example, commit 52ed893 changed a workflow file and the checkout such that the workflow fails without an updated checkout.) I don't know of a way to coerce GitHub to use the workflow files of the pull request source. Change our workflows to use GitHub's defaults: read workflow files from the merged commit, and create a checkout from the merged commit. This means that CI won't test the code seen in the pull request, but I think that behavior is slightly better in the common case than the current behavior.
1 parent 2791d0d commit fa6299e

17 files changed

+3
-107
lines changed

.github/workflows/build-and-test-dev-env-nix.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ jobs:
1414
# TODO(strager): Use ghcr.io/quick-lint/quick-lint-js-github-builder.
1515
steps:
1616
- name: checkout
17-
if: ${{ github.event_name == 'push' }}
1817
uses: actions/checkout@v2
19-
- name: checkout
20-
if: ${{ github.event_name == 'pull_request' }}
21-
uses: actions/checkout@v2
22-
with:
23-
ref: ${{ github.event.pull_request.head.sha }}
2418

2519
- name: install nix
2620
uses: cachix/install-nix-action@v12

.github/workflows/build-and-test-dev.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ jobs:
2727

2828
steps:
2929
- name: checkout
30-
if: ${{ github.event_name == 'push' }}
3130
uses: actions/checkout@v2
32-
- name: checkout
33-
if: ${{ github.event_name == 'pull_request' }}
34-
uses: actions/checkout@v2
35-
with:
36-
ref: ${{ github.event.pull_request.head.sha }}
3731

3832
- name: 0. Install build dependencies
3933
run: ${{ matrix.toolchain.install_dependencies_script }}

.github/workflows/build-and-test-plugin-vscode.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ jobs:
1919
with:
2020
version: 2.0.4
2121
- name: checkout
22-
if: ${{ github.event_name == 'push' }}
23-
uses: actions/checkout@v2
24-
- name: checkout
25-
if: ${{ github.event_name == 'pull_request' }}
2622
uses: actions/checkout@v2
27-
with:
28-
ref: ${{ github.event.pull_request.head.sha }}
2923

3024
- name: install build dependencies
3125
run: |

.github/workflows/build-and-test-web-demo.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ jobs:
1919
with:
2020
version: 2.0.4
2121
- name: checkout
22-
if: ${{ github.event_name == 'push' }}
23-
uses: actions/checkout@v2
24-
- name: checkout
25-
if: ${{ github.event_name == 'pull_request' }}
2622
uses: actions/checkout@v2
27-
with:
28-
ref: ${{ github.event.pull_request.head.sha }}
2923

3024
- name: install build dependencies
3125
run: |

.github/workflows/build-and-test.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ jobs:
4848
4949
steps:
5050
- name: checkout
51-
if: ${{ github.event_name == 'push' }}
5251
uses: actions/checkout@v2
53-
- name: checkout
54-
if: ${{ github.event_name == 'pull_request' }}
55-
uses: actions/checkout@v2
56-
with:
57-
ref: ${{ github.event.pull_request.head.sha }}
5852

5953
- name: configure
6054
run: |

.github/workflows/build-static.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ jobs:
3232

3333
steps:
3434
- name: checkout
35-
if: ${{ github.event_name == 'push' }}
36-
uses: actions/checkout@v2
37-
- name: checkout
38-
if: ${{ github.event_name == 'pull_request' }}
3935
uses: actions/checkout@v2
40-
with:
41-
ref: ${{ github.event.pull_request.head.sha }}
4236

4337
- name: configure
4438
run: |
@@ -137,13 +131,7 @@ jobs:
137131
runs-on: ubuntu-latest
138132
steps:
139133
- name: checkout
140-
if: ${{ github.event_name == 'push' }}
141-
uses: actions/checkout@v2
142-
- name: checkout
143-
if: ${{ github.event_name == 'pull_request' }}
144134
uses: actions/checkout@v2
145-
with:
146-
ref: ${{ github.event.pull_request.head.sha }}
147135

148136
- uses: actions/download-artifact@v2
149137
with:

.github/workflows/check-copyright.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
container: ghcr.io/quick-lint/quick-lint-js-github-builder:v1
1515
steps:
16-
- if: ${{ github.event_name == 'push' }}
17-
uses: actions/checkout@v2
18-
- if: ${{ github.event_name == 'pull_request' }}
19-
uses: actions/checkout@v2
20-
with:
21-
ref: ${{ github.event.pull_request.head.sha }}
16+
- uses: actions/checkout@v2
2217

2318
- run: |
2419
if ! ./tools/check-file-copyrights; then

.github/workflows/check-error-docs.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ jobs:
1313
runs-on: ubuntu-18.04
1414
container: ghcr.io/quick-lint/quick-lint-js-github-builder:v1
1515
steps:
16-
- if: ${{ github.event_name == 'push' }}
17-
uses: actions/checkout@v2
18-
- if: ${{ github.event_name == 'pull_request' }}
19-
uses: actions/checkout@v2
20-
with:
21-
ref: ${{ github.event.pull_request.head.sha }}
16+
- uses: actions/checkout@v2
2217

2318
- name: configure
2419
run: CC=gcc-8 CXX=g++-8 cmake -DBUILD_TESTING=NO -S . -B build

.github/workflows/check-format.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ jobs:
1313
runs-on: ubuntu-18.04
1414
container: ghcr.io/quick-lint/quick-lint-js-github-builder:v1
1515
steps:
16-
- if: ${{ github.event_name == 'push' }}
17-
uses: actions/checkout@v2
18-
- if: ${{ github.event_name == 'pull_request' }}
19-
uses: actions/checkout@v2
20-
with:
21-
ref: ${{ github.event.pull_request.head.sha }}
16+
- uses: actions/checkout@v2
2217

2318
- run: clang-format --version
2419
- run: ./tools/format

.github/workflows/debian-package.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ jobs:
1414
container: ghcr.io/quick-lint/quick-lint-js-github-builder:v1
1515
steps:
1616
- name: checkout
17-
if: ${{ github.event_name == 'push' }}
18-
uses: actions/checkout@v2
19-
- name: checkout
20-
if: ${{ github.event_name == 'pull_request' }}
2117
uses: actions/checkout@v2
22-
with:
23-
ref: ${{ github.event.pull_request.head.sha }}
2418

2519
- name: build
2620
run: ./dist/debian/build.sh

0 commit comments

Comments
 (0)