|
| 1 | +name: Review Nix changes |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '**.nix' |
| 7 | + - '.github/workflows/review-nix-changes.yml' |
| 8 | + types: [opened, synchronize, reopened, ready_for_review] |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - canary |
| 13 | + - v[0-9]+.x-staging |
| 14 | + - v[0-9]+.x |
| 15 | + paths: |
| 16 | + - '**.nix' |
| 17 | + - '.github/workflows/review-nix-changes.yml' |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + eval: |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - runner: ubuntu-24.04 |
| 33 | + system: x86_64-linux |
| 34 | + - runner: ubuntu-24.04-arm |
| 35 | + system: aarch64-linux |
| 36 | + - runner: macos-15-intel |
| 37 | + system: x86_64-darwin |
| 38 | + - runner: macos-latest |
| 39 | + system: aarch64-darwin |
| 40 | + name: '${{ matrix.system }}: Evaluate shell.nix' |
| 41 | + runs-on: ${{ matrix.runner }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 44 | + with: |
| 45 | + persist-credentials: false |
| 46 | + sparse-checkout: '*.nix' |
| 47 | + sparse-checkout-cone-mode: false |
| 48 | + fetch-depth: 2 |
| 49 | + |
| 50 | + - uses: cachix/install-nix-action@96951a368ba55167b55f1c916f7d416bac6505fe # v31.10.3 |
| 51 | + with: |
| 52 | + extra_nix_config: sandbox = true |
| 53 | + |
| 54 | + - uses: cachix/cachix-action@1eb2ef646ac0255473d23a5907ad7b04ce94065c # v17 |
| 55 | + with: |
| 56 | + name: nodejs |
| 57 | + |
| 58 | + - name: Compare |
| 59 | + run: | |
| 60 | + NIX_DIR=./tools/nix |
| 61 | + nix_show_derivation () { |
| 62 | + nix --extra-experimental-features nix-command derivation show $2 "$1" |
| 63 | + } |
| 64 | + list_nix_derivations () { |
| 65 | + DRV="$( |
| 66 | + nix-instantiate -I "nixpkgs=$NIX_DIR/pkgs.nix" "./shell.nix" \ |
| 67 | + --arg devTools " |
| 68 | + (import $NIX_DIR/devTools.nix {}) |
| 69 | + ++ builtins.attrValues ( |
| 70 | + { inherit (import <nixpkgs> {}) nixfmt-tree sccache; } |
| 71 | + // import $NIX_DIR/openssl-matrix.nix {} |
| 72 | + )" \ |
| 73 | + --arg withTemporal true \ |
| 74 | + --arg withQuic true |
| 75 | + )" |
| 76 | + nix-store -qR --include-outputs "$DRV" | grep -v '.drv$' | sort -k1.45 > "out/${{ matrix.system }}-$1-paths.txt" |
| 77 | + nix_show_derivation "$DRV" -r | jq '( |
| 78 | + .derivations |= ( |
| 79 | + to_entries |
| 80 | + | sort_by(.key | .[32:]) |
| 81 | + | .[].value.inputs.drvs |= ( |
| 82 | + to_entries |
| 83 | + | sort_by(.key | .[32:]) |
| 84 | + | from_entries) |
| 85 | + | from_entries))' > "out/${{ matrix.system }}-$1-drv.json" |
| 86 | + } |
| 87 | + mkdir out |
| 88 | + list_nix_derivations after |
| 89 | + git reset HEAD^ --hard |
| 90 | + list_nix_derivations before |
| 91 | +
|
| 92 | + - name: Upload tarball artifact |
| 93 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 94 | + with: |
| 95 | + path: out/ |
| 96 | + name: diff-${{ matrix.system }} |
| 97 | + |
| 98 | + compare: |
| 99 | + runs-on: ubuntu-slim |
| 100 | + needs: eval |
| 101 | + permissions: |
| 102 | + pull-requests: write |
| 103 | + steps: |
| 104 | + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 105 | + |
| 106 | + - name: Generate aggregated summary |
| 107 | + run: | |
| 108 | + set -ex |
| 109 | + { |
| 110 | + echo "This PR touches some Nix files. To help review it, here's a quick overview of the changes that were detected:" |
| 111 | +
|
| 112 | + for system in x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin; do |
| 113 | + echo |
| 114 | + echo "<details><summary>$system</summary>" |
| 115 | + echo |
| 116 | +
|
| 117 | + diff "diff-$system/$system-before-paths.txt" "diff-$system/$system-after-paths.txt" > computed_diff && EXIT_CODE="$?" || EXIT_CODE="$?" |
| 118 | + if [ "$EXIT_CODE" = "0" ]; then |
| 119 | + echo "No changes detected." |
| 120 | + else |
| 121 | + echo '```diff' |
| 122 | + grep '^[<>]' computed_diff |
| 123 | + echo '```' |
| 124 | + fi |
| 125 | +
|
| 126 | + echo |
| 127 | + echo "</details>" |
| 128 | + done |
| 129 | +
|
| 130 | + echo |
| 131 | + echo "There might be more changes that are not shown here" |
| 132 | + } >> "$GITHUB_STEP_SUMMARY" |
| 133 | +
|
| 134 | +
|
0 commit comments