Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run actionlint in CI + make it available in dev shell #536

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
40 changes: 40 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Actionlint

on:
pull_request:

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Note that, because our Nix configuration provisions *both* shellcheck and actionlint,
# actionlint is not going to install its own shellcheck.
# This also makes sure that this pipeline runs using
# the same shellcheck as the ones in Nix shells of developers.
- name: Install Nix with good defaults
uses: input-output-hk/install-nix-action@v20
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
# Make the Nix environment available to next steps
- uses: rrbutani/use-nix-shell-action@v1

- name: actionlint
run: |
for file in $(git ls-files ".github/workflows/*.y*ml")
do
if grep -q "$file" ".github/workflows/actionlint-exceptions.txt"
then
echo "⚠️ $file is ignored from actionlint's verifications. Please consider fixing it."
else
echo "actionlint $file"
actionlint "$file"
fi
done
2 changes: 1 addition & 1 deletion .github/workflows/check-cabal-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Workaround runner image issue
if: runner.os == 'Linux'
# https://github.com/actions/runner-images/issues/7061
run: sudo chown -R $USER /usr/local/.ghcup
run: sudo chown -R "$USER" /usr/local/.ghcup

- name: Install Haskell
uses: input-output-hk/setup-haskell@v1
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/check-stylish-haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ jobs:

steps:
- name: Download stylish-haskell
if: runner.os == 'Linux'
run: |
version="${{ env.STYLISH_HASKELL_VERSION }}"

curl -sL \
"https://github.com/haskell/stylish-haskell/releases/download/v$version/stylish-haskell-v$version-linux-x86_64.tar.gz" \
| tar -C "/tmp" -xz

echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> $GITHUB_ENV
echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> "$GITHUB_ENV"

- uses: actions/checkout@v3

Expand All @@ -55,10 +54,10 @@ jobs:

for x in $(git ls-tree --full-tree --name-only -r HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' $x; then
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
stylish-haskell -i $x
stylish-haskell -i "$x"
fi
fi
done
Expand All @@ -72,10 +71,10 @@ jobs:
git fetch origin ${{ github.base_ref }} --unshallow
for x in $(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}..HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' $x; then
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
stylish-haskell -i $x
stylish-haskell -i "$x"
fi
fi
done
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
- name: Create Release Tag
id: create_release_tag
run: |
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"

- name: Create Release
id: create_release
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
stylish-haskell = "0.14.5.0";
};
# and from nixpkgs or other inputs
shell.nativeBuildInputs = with nixpkgs; [ gh jq yq-go shellcheck ];
shell.nativeBuildInputs = with nixpkgs; [ gh jq yq-go actionlint shellcheck ];
# disable Hoogle until someone request it
shell.withHoogle = false;
# Skip cross compilers for the shell
Expand Down
Loading