diff options
| author | Paul Meyer <katexochen0@gmail.com> | 2025-03-18 22:26:31 +0100 |
|---|---|---|
| committer | Paul Meyer <katexochen0@gmail.com> | 2025-03-24 14:50:23 +0100 |
| commit | 60b30dd3164e656eb5ca049064781d14999fc77c (patch) | |
| tree | 28895b42180d303416f24dfd523971e8fa1f66ca /.github | |
| parent | git-blame-ignore-revs: add python-packages format (diff) | |
| download | nixpkgs-60b30dd3164e656eb5ca049064781d14999fc77c.tar.gz | |
ci: add keep-sorted workflow
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/keep-sorted.yml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.github/workflows/keep-sorted.yml b/.github/workflows/keep-sorted.yml new file mode 100644 index 000000000000..fbc39889b87b --- /dev/null +++ b/.github/workflows/keep-sorted.yml @@ -0,0 +1,40 @@ +name: Check that files are sorted + +on: + pull_request_target: + types: [opened, synchronize, reopened] + +permissions: {} + +jobs: + get-merge-commit: + uses: ./.github/workflows/get-merge-commit.yml + + nixos: + name: keep-sorted + runs-on: ubuntu-24.04 + needs: get-merge-commit + if: "needs.get-merge-commit.outputs.mergedSha && !contains(github.event.pull_request.title, '[skip treewide]')" + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ needs.get-merge-commit.outputs.mergedSha }} + + - name: Get Nixpkgs revision for keep-sorted + run: | + # Pin to a commit from nixpkgs-unstable to avoid e.g. building nixfmt from staging. + # This should not be a URL, because it would allow PRs to run arbitrary code in CI! + rev=$(jq -r .rev ci/pinned-nixpkgs.json) + echo "url=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz" >> "$GITHUB_ENV" + + - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30 + with: + extra_nix_config: sandbox = true + nix_path: nixpkgs=${{ env.url }} + + - name: Install keep-sorted + run: "nix-env -f '<nixpkgs>' -iAP keep-sorted" + + - name: Check that Nix files are sorted + run: | + git ls-files | xargs keep-sorted --mode lint |
