Files
node/.github/workflows/nix-changes.yml
T
Antoine du Hamel ce1e0d59e5 tools: improve nix-changes coverage
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65403
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-08-21 17:05:15 +00:00

122 lines
3.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# This action uses the following secrets:
# CACHIX_AUTH_TOKEN: Write access to nodejs.cachix.org – without it, the cache is read-only.
name: Nix files edited
on:
push:
branches:
- main
- canary
- v[0-9]+.x-staging
- v[0-9]+.x
paths:
- '**.nix'
- tools/nix/**
- .github/workflows/nix-changes.yml
pull_request:
paths:
- '**.nix'
- tools/nix/**
- .github/workflows/nix-changes.yml
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
diff:
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
system: x86_64-linux
- runner: ubuntu-24.04-arm
system: aarch64-linux
- runner: macos-15-intel
system: x86_64-darwin
- runner: macos-latest
system: aarch64-darwin
name: '${{ matrix.system }}: dependencies diff'
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 2
persist-credentials: false
sparse-checkout: |
shell.nix
tools/nix/
sparse-checkout-cone-mode: false
- uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0
with:
extra_nix_config: sandbox = true
- uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: nodejs
- name: Compute requisites after change
run: ./tools/nix/list-requisites.sh > requisites-${{ matrix.system }}-after.list
- name: Compute requisites before change
run: |
git reset HEAD^ --hard
# TODO(aduh95): remove this once list-requisites.sh has reached `main`
[ -f tools/nix/list-requisites.sh ] || git checkout FETCH_HEAD -- tools/nix/list-requisites.sh
./tools/nix/list-requisites.sh > requisites-${{ matrix.system }}-before.list
- name: Output diff
run: |
{
if diff_output="$(git diff -U0 --no-color --no-index requisites-${{ matrix.system }}-before.list requisites-${{ matrix.system }}-after.list)"; then
echo 'No changes detected.'
else
echo '```diff'
echo "$diff_output" | tail -n +5
echo '```'
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Store PR number
if: ${{ github.event.pull_request && matrix.system == 'x86_64-linux' }}
run: echo "${{ github.event.pull_request.number }}" > pr_number.txt
- name: Upload requisites lists
if: ${{ github.event.pull_request }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: requisites-${{ matrix.system }}
path: |
pr_number.*
requisites-${{ matrix.system }}-before.list
requisites-${{ matrix.system }}-after.list
lint-nix:
if: github.event.pull_request.draft == false
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
sparse-checkout: '*.nix'
sparse-checkout-cone-mode: false
- uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0
- name: Lint Nix files
run: |
nix-shell -I nixpkgs=./tools/nix/pkgs.nix -p 'nixfmt-tree' --run '
treefmt --quiet --ci
' && EXIT_CODE="$?" || EXIT_CODE="$?"
if [ "$EXIT_CODE" != "0" ]
then
git --no-pager diff || true
exit "$EXIT_CODE"
fi