mirror of
https://github.com/NixOS/nix.git
synced 2025-11-25 11:49:35 +01:00
Merge pull request #14059 from xokdvium/formatting-ci
ci: Split formatting check into a separate job, gate other jobs
This commit is contained in:
commit
0175f7e836
2 changed files with 50 additions and 0 deletions
26
.github/workflows/ci.yml
vendored
26
.github/workflows/ci.yml
vendored
|
|
@ -29,7 +29,32 @@ jobs:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: nix flake show --all-systems --json
|
- run: nix flake show --all-systems --json
|
||||||
|
|
||||||
|
pre-commit-checks:
|
||||||
|
name: pre-commit checks
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: ./.github/actions/install-nix-action
|
||||||
|
with:
|
||||||
|
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||||
|
extra_nix_config: experimental-features = nix-command flakes
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
- run: ./ci/gha/tests/pre-commit-checks
|
||||||
|
|
||||||
|
basic-checks:
|
||||||
|
name: aggregate basic checks
|
||||||
|
if: ${{ always() }}
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
needs: [pre-commit-checks, eval]
|
||||||
|
steps:
|
||||||
|
- name: Exit with any errors
|
||||||
|
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
|
||||||
|
run: |
|
||||||
|
exit 1
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
|
needs: basic-checks
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|
@ -214,6 +239,7 @@ jobs:
|
||||||
docker push $IMAGE_ID:master
|
docker push $IMAGE_ID:master
|
||||||
|
|
||||||
vm_tests:
|
vm_tests:
|
||||||
|
needs: basic-checks
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
|
||||||
24
ci/gha/tests/pre-commit-checks
Executable file
24
ci/gha/tests/pre-commit-checks
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
system=$(nix eval --raw --impure --expr builtins.currentSystem)
|
||||||
|
|
||||||
|
echo "::group::Running pre-commit checks"
|
||||||
|
|
||||||
|
if nix build ".#checks.$system.pre-commit" -L; then
|
||||||
|
echo "::endgroup::"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::error ::Changes do not pass pre-commit checks"
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
The code isn't formatted or doesn't pass lints. You can run pre-commit locally with:
|
||||||
|
|
||||||
|
nix develop -c ./maintainers/format.sh
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
exit 1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue