Skip to content

Commit 0175f7e

Browse files
authored
Merge pull request #14059 from xokdvium/formatting-ci
ci: Split formatting check into a separate job, gate other jobs
2 parents 73d3ab0 + 00775ad commit 0175f7e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,32 @@ jobs:
2929
github_token: ${{ secrets.GITHUB_TOKEN }}
3030
- run: nix flake show --all-systems --json
3131

32+
pre-commit-checks:
33+
name: pre-commit checks
34+
runs-on: ubuntu-24.04
35+
steps:
36+
- uses: actions/checkout@v5
37+
- uses: ./.github/actions/install-nix-action
38+
with:
39+
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
40+
extra_nix_config: experimental-features = nix-command flakes
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
- uses: DeterminateSystems/magic-nix-cache-action@main
43+
- run: ./ci/gha/tests/pre-commit-checks
44+
45+
basic-checks:
46+
name: aggregate basic checks
47+
if: ${{ always() }}
48+
runs-on: ubuntu-24.04
49+
needs: [pre-commit-checks, eval]
50+
steps:
51+
- name: Exit with any errors
52+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
53+
run: |
54+
exit 1
55+
3256
tests:
57+
needs: basic-checks
3358
strategy:
3459
fail-fast: false
3560
matrix:
@@ -214,6 +239,7 @@ jobs:
214239
docker push $IMAGE_ID:master
215240
216241
vm_tests:
242+
needs: basic-checks
217243
runs-on: ubuntu-24.04
218244
steps:
219245
- uses: actions/checkout@v5

ci/gha/tests/pre-commit-checks

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
system=$(nix eval --raw --impure --expr builtins.currentSystem)
6+
7+
echo "::group::Running pre-commit checks"
8+
9+
if nix build ".#checks.$system.pre-commit" -L; then
10+
echo "::endgroup::"
11+
exit 0
12+
fi
13+
14+
echo "::error ::Changes do not pass pre-commit checks"
15+
16+
cat <<EOF
17+
The code isn't formatted or doesn't pass lints. You can run pre-commit locally with:
18+
19+
nix develop -c ./maintainers/format.sh
20+
EOF
21+
22+
echo "::endgroup::"
23+
24+
exit 1

0 commit comments

Comments
 (0)