fix: update nixfmt workflow to use 'main' branch and improve formatting checks
This commit is contained in:
parent
212050a0ee
commit
96fd886f84
31
.github/workflows/nixfmt.yml
vendored
31
.github/workflows/nixfmt.yml
vendored
@ -3,7 +3,7 @@ name: Nix Format Check
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-format:
|
check-format:
|
||||||
@ -13,17 +13,32 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v30
|
uses: cachix/install-nix-action@v30
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
|
||||||
- name: Install nixfmt
|
- name: Install nixfmt
|
||||||
run: nix-env -i nixfmt-rfc-style
|
run: nix profile install nixpkgs#nixfmt-rfc-style
|
||||||
|
|
||||||
- name: Check Nix formatting
|
- name: Check Nix formatting
|
||||||
run: |
|
run: |
|
||||||
find . -name "*.nix" -type f -exec nixfmt {} \;
|
exit_code=0
|
||||||
if git diff --quiet; then
|
while IFS= read -r file; do
|
||||||
echo "All Nix files are properly formatted"
|
if ! nixfmt "$file"; then
|
||||||
|
echo "Error: Failed to format $file"
|
||||||
|
exit_code=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done < <(find . -name "*.nix" -type f)
|
||||||
|
|
||||||
|
if [ $exit_code -eq 0 ]; then
|
||||||
|
if git diff --quiet; then
|
||||||
|
echo "All Nix files are properly formatted"
|
||||||
|
else
|
||||||
|
echo "Error: Some Nix files are not properly formatted"
|
||||||
|
git diff
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Error: Some Nix files are not properly formatted"
|
exit $exit_code
|
||||||
git diff
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
Loading…
x
Reference in New Issue
Block a user