diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2024-06-26 01:08:17 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2024-06-26 16:16:51 +0200 |
commit | 53b517c6851ef52a86e44ea16220d93f88bf9849 (patch) | |
tree | ae630210ddfa25d7dcefdb02c4e39171ffc569ba /.github | |
parent | a70ab58960c254c58c5289b18b769c9d2311dce7 (diff) |
workflows/check-nix-format: show command to fix
When some files are not formatted properly, this shows how people can fix the problem. This notably uses the shell.nix introduced in the parent commit to ensure that the nixfmt version matches what CI expects.
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/check-nix-format.yml | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/.github/workflows/check-nix-format.yml b/.github/workflows/check-nix-format.yml index 5a3b7fe40cb92..5352b6fa53f95 100644 --- a/.github/workflows/check-nix-format.yml +++ b/.github/workflows/check-nix-format.yml @@ -56,6 +56,7 @@ jobs: NIX_FMT_PATHS_BUILD_SUPPORT_PHP: pkgs/build-support/php # Iterate over all environment variables beginning with NIX_FMT_PATHS_. run: | + unformattedPaths=() for env_var in "${!NIX_FMT_PATHS_@}"; do readarray -t paths <<< "${!env_var}" if [[ "${paths[*]}" == "" ]]; then @@ -64,7 +65,12 @@ jobs: fi echo "Checking paths: ${paths[@]}" if ! nixfmt --check "${paths[@]}"; then - echo "Error: nixfmt failed." - exit 1 + unformattedPaths+=("${paths[@]}") fi done + if (( "${#unformattedPaths[@]}" > 0 )); then + echo "Some required Nix files are not properly formatted" + echo "Please run the following in \`nix-shell\`:" + echo "nixfmt ${unformattedPaths[*]@Q}" + exit 1 + fi |