Skip to content

Commit 074114b

Browse files
authored
Merge pull request #536 from IntersectMBO/smelc/run-actionlint-in-ci
Run actionlint in CI + make it available in dev shell
2 parents 3de3e7e + c6e0895 commit 074114b

File tree

6 files changed

+48
-9
lines changed

6 files changed

+48
-9
lines changed

.github/workflows/actionlint-exceptions.txt

Whitespace-only changes.

.github/workflows/actionlint.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Actionlint
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
actionlint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
# Note that, because our Nix configuration provisions *both* shellcheck and actionlint,
13+
# actionlint is not going to install its own shellcheck.
14+
# This also makes sure that this pipeline runs using
15+
# the same shellcheck as the ones in Nix shells of developers.
16+
- name: Install Nix with good defaults
17+
uses: input-output-hk/install-nix-action@v20
18+
with:
19+
extra_nix_config: |
20+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
21+
substituters = https://cache.iog.io/ https://cache.nixos.org/
22+
nix_path: nixpkgs=channel:nixos-unstable
23+
- uses: cachix/install-nix-action@v18
24+
with:
25+
nix_path: nixpkgs=channel:nixos-unstable
26+
# Make the Nix environment available to next steps
27+
- uses: rrbutani/use-nix-shell-action@v1
28+
29+
- name: actionlint
30+
run: |
31+
for file in $(git ls-files ".github/workflows/*.y*ml")
32+
do
33+
if grep -q "$file" ".github/workflows/actionlint-exceptions.txt"
34+
then
35+
echo "⚠️ $file is ignored from actionlint's verifications. Please consider fixing it."
36+
else
37+
echo "actionlint $file"
38+
actionlint "$file"
39+
fi
40+
done

.github/workflows/check-cabal-files.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Workaround runner image issue
1313
if: runner.os == 'Linux'
1414
# https://github.com/actions/runner-images/issues/7061
15-
run: sudo chown -R $USER /usr/local/.ghcup
15+
run: sudo chown -R "$USER" /usr/local/.ghcup
1616

1717
- name: Install Haskell
1818
uses: input-output-hk/setup-haskell@v1

.github/workflows/check-stylish-haskell.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ jobs:
3636
3737
steps:
3838
- name: Download stylish-haskell
39-
if: runner.os == 'Linux'
4039
run: |
4140
version="${{ env.STYLISH_HASKELL_VERSION }}"
4241
4342
curl -sL \
4443
"https://github.com/haskell/stylish-haskell/releases/download/v$version/stylish-haskell-v$version-linux-x86_64.tar.gz" \
4544
| tar -C "/tmp" -xz
4645
47-
echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> $GITHUB_ENV
46+
echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> "$GITHUB_ENV"
4847
4948
- uses: actions/checkout@v3
5049

@@ -55,10 +54,10 @@ jobs:
5554
5655
for x in $(git ls-tree --full-tree --name-only -r HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
5756
if [ "${x##*.}" == "hs" ]; then
58-
if grep -qE '^#' $x; then
57+
if grep -qE '^#' "$x"; then
5958
echo "$x contains CPP. Skipping."
6059
else
61-
stylish-haskell -i $x
60+
stylish-haskell -i "$x"
6261
fi
6362
fi
6463
done
@@ -72,10 +71,10 @@ jobs:
7271
git fetch origin ${{ github.base_ref }} --unshallow
7372
for x in $(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}..HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
7473
if [ "${x##*.}" == "hs" ]; then
75-
if grep -qE '^#' $x; then
74+
if grep -qE '^#' "$x"; then
7675
echo "$x contains CPP. Skipping."
7776
else
78-
stylish-haskell -i $x
77+
stylish-haskell -i "$x"
7978
fi
8079
fi
8180
done

.github/workflows/haskell.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208
- name: Create Release Tag
209209
id: create_release_tag
210210
run: |
211-
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
211+
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"
212212
213213
- name: Create Release
214214
id: create_release

flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
stylish-haskell = "0.14.5.0";
8888
};
8989
# and from nixpkgs or other inputs
90-
shell.nativeBuildInputs = with nixpkgs; [ gh jq yq-go shellcheck ];
90+
shell.nativeBuildInputs = with nixpkgs; [ gh jq yq-go actionlint shellcheck ];
9191
# disable Hoogle until someone request it
9292
shell.withHoogle = false;
9393
# Skip cross compilers for the shell

0 commit comments

Comments
 (0)