workflows/editorconfig: drop and move to treefmt (#405684)

Changed files
+14 -101
.github
ci
+4 -7
.github/workflows/check-nix-format.yml .github/workflows/check-format.yml
···
-
# NOTE: Formatting with the RFC-style nixfmt command is not yet stable.
-
# See https://github.com/NixOS/rfcs/pull/166.
-
-
name: Check that Nix files are formatted
+
name: Check that files are formatted
on:
pull_request_target:
···
uses: ./.github/workflows/get-merge-commit.yml
nixos:
-
name: nixfmt-check
+
name: fmt-check
runs-on: ubuntu-24.04
needs: get-merge-commit
if: needs.get-merge-commit.outputs.mergedSha
···
with:
extra_nix_config: sandbox = true
-
- name: Check that Nix files are formatted
+
- name: Check that files are formatted
run: |
# Note that it's fine to run this on untrusted code because:
# - There's no secrets accessible here
# - The build is sandboxed
if ! nix-build ci -A fmt.check; then
-
echo "Some Nix files are not properly formatted"
+
echo "Some files are not properly formatted"
echo "Please format them by going to the Nixpkgs root directory and running one of:"
echo " nix-shell --run treefmt"
echo " nix develop --command treefmt"
-52
.github/workflows/editorconfig-v2.yml
···
-
name: "Checking EditorConfig v2"
-
-
on:
-
pull_request_target:
-
-
permissions: {}
-
-
jobs:
-
get-merge-commit:
-
uses: ./.github/workflows/get-merge-commit.yml
-
-
tests:
-
name: editorconfig-check
-
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:
-
- name: Get list of changed files from PR
-
env:
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
run: |
-
gh api \
-
repos/${{ github.repository }}/pulls/${{ github.event.number }}/files --paginate \
-
| jq '.[] | select(.status != "removed") | .filename' \
-
> "$HOME/changed_files"
-
-
- name: print list of changed files
-
run: |
-
cat "$HOME/changed_files"
-
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-
with:
-
ref: ${{ needs.get-merge-commit.outputs.mergedSha }}
-
-
- name: Get Nixpkgs revision for editorconfig-checker
-
run: |
-
# Pin to a commit from nixpkgs-unstable to avoid building from e.g. 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@526118121621777ccd86f79b04685a9319637641 # v31
-
with:
-
nix_path: nixpkgs=${{ env.url }}
-
-
- name: Checking EditorConfig
-
run: |
-
< "$HOME/changed_files" nix-shell -p editorconfig-checker --run 'xargs -r editorconfig-checker -disable-indent-size'
-
-
- if: ${{ failure() }}
-
run: |
-
echo "::error :: Hey! It looks like your changes don't follow our editorconfig settings. Read https://editorconfig.org/#download to configure your editor so you never see this error again."
-41
.github/workflows/keep-sorted.yml
···
-
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@526118121621777ccd86f79b04685a9319637641 # v31
-
with:
-
extra_nix_config: sandbox = true
-
nix_path: nixpkgs=${{ env.url }}
-
-
- name: Install keep-sorted
-
run: "nix-env -f '<nixpkgs>' -iAP keep-sorted jq"
-
-
- name: Check that Nix files are sorted
-
shell: bash
-
run: |
-
git ls-files | xargs keep-sorted --mode lint | jq --raw-output '.[] | "Please make sure any new entries in \(.path) are sorted alphabetically."'
+1 -1
ci/OWNERS
···
# CI
/.github/*_TEMPLATE* @SigmaSquadron
/.github/workflows @NixOS/Security @Mic92 @zowoq @infinisil @azuwis @wolfgangwalther
-
/.github/workflows/check-nix-format.yml @infinisil @wolfgangwalther
+
/.github/workflows/check-format.yml @infinisil @wolfgangwalther
/.github/workflows/codeowners-v2.yml @infinisil @wolfgangwalther
/.github/workflows/nixpkgs-vet.yml @infinisil @philiptaron @wolfgangwalther
/ci @infinisil @philiptaron @NixOS/Security @wolfgangwalther
+9
ci/default.nix
···
# By default it's info, which is too noisy since we have many unmatched files
settings.on-unmatched = "debug";
+
programs.keep-sorted.enable = true;
+
# This uses nixfmt-rfc-style underneath,
# the default formatter for Nix code.
# See https://github.com/NixOS/nixfmt
programs.nixfmt.enable = true;
+
+
settings.formatter.editorconfig-checker = {
+
command = "${pkgs.lib.getExe pkgs.editorconfig-checker}";
+
options = [ "-disable-indent-size" ];
+
includes = [ "*" ];
+
priority = 1;
+
};
};
fs = pkgs.lib.fileset;
nixFilesSrc = fs.toSource {