workflows/editorconfig: drop and move to treefmt (#405684)
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
# 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:
|
||||
@@ -14,7 +11,7 @@ jobs:
|
||||
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
|
||||
@@ -27,13 +24,13 @@ jobs:
|
||||
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"
|
||||
@@ -1,52 +0,0 @@
|
||||
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."
|
||||
@@ -1,41 +0,0 @@
|
||||
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."'
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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
|
||||
|
||||
@@ -44,10 +44,19 @@ let
|
||||
# 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 {
|
||||
|
||||
Reference in New Issue
Block a user