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

CI: shellcheck scripts #525

Merged
merged 3 commits into from
Apr 25, 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.
39 changes: 39 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Shellcheck
# This pipeline runs shellcheck on all files with extension .sh,
# except the ones listed in .github/workflows/shellcheck-exceptions.txt.
#
# This pipeline uses Nix, so that the shellcheck version used is the same
# ones as used by developers in Nix shells. This ensures the CI's behavior
# is consistent with the one of developers.

on:
pull_request:

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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: Shellcheck
run: |
for file in $(git ls-files "*.sh")
do
if grep -q "$file" ".github/workflows/shellcheck-exceptions.txt"
then
echo "⚠️ $file is ignored from shellcheck's verifications. Please consider fixing it."
else
shellcheck "$file"
fi
done
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 ];
shell.nativeBuildInputs = with nixpkgs; [ gh jq yq-go shellcheck ];
# disable Hoogle until someone request it
shell.withHoogle = false;
# Skip cross compilers for the shell
Expand Down
15 changes: 8 additions & 7 deletions scripts/ci/check-cabal-files.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
#
# Runs "cabal check" in all directories containing a versioned .cabal file

for x in $(find . -name '*.cabal' | grep -v dist-newstyle | cut -c 3-); do
(
d=$(dirname $x)
echo "== $d =="
cd $d
cabal check
)
for cabal_file in $(git ls-files "*.cabal")
do
cd "$(dirname "$cabal_file")" || { echo "Cannot cd"; exit 1; }
echo "$(pwd)> cabal-check"
cabal check
cd - || { echo "Cannot cd back"; exit 1; }
done
Loading