Skip to content

Commit

Permalink
Use HLint action for CI (#42)
Browse files Browse the repository at this point in the history
* Use HLint action for CI

* Split linting and styling, use Fourmolu
  • Loading branch information
tchoutri authored Apr 26, 2022
1 parent ec4322e commit b00a2be
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 32 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Tests

# Trigger the workflow on push or pull request, but only for the main branch
on:
Expand Down Expand Up @@ -30,7 +30,6 @@ jobs:
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
echo "NIX_SSL_CERT_FILE=$cert_file" >> "$GITHUB_ENV"
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
env
- name: Configure Darwin Nixpkgs
if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -70,12 +69,6 @@ jobs:
- name: Installing dependencies
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'make deps' .github/workflows/shell.nix

- name: Running hlint
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run './.github/workflows/hlint-runner.sh' .github/workflows/shell.nix

- name: Running stylish-haskell
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run './.github/workflows/stylish-haskell-runner.sh' .github/workflows/shell.nix

- name: Build
run: nix-shell --pure -I ${{ env.NIX_PATH }} --argstr ghcVersion ${{env.GHC}} --run 'make build' .github/workflows/shell.nix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eux

git add .

stylish-haskell -c .stylish-haskell.yaml -r src test app -i
fourmolu --mode check $(git ls-files '*.hs')

git status

Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/hlint-runner.sh

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Linting

on:
pull_request:
push:
branches: ["main", "development"]

jobs:
hlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: 'Set up HLint'
uses: rwe/actions-hlint-setup@v1
with:
version: '3.3.6'

- name: 'Run HLint'
uses: rwe/actions-hlint-run@v1
with:
path: '["src/", "test/"]'
fail-on: warning

styling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure environment

- name: Set up Haskell
id: setup-haskell
uses: haskell/actions/setup@v1
with:
ghc-version: "8.10.7"
cabal-version: "latest"


- name: Install tools
run: |
cd ~/
echo "$HOME/.ghcup/bin" >> $GITHUB_PATH
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH
cabal install -j fourmolu
- name: Running fourmolu
run: ./.github/workflows/fourmolu-runner.sh
9 changes: 9 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
indentation: 2
comma-style: leading # for lists, tuples etc. - can also be 'leading'
import-export-comma-style: leading # for module import export lists - can also be 'leading'
record-brace-space: false # rec {x = 1} vs. rec{x = 1}
indent-wheres: true # 'false' means save space by only half-indenting the 'where' keyword
diff-friendly-import-export: false # 'false' uses Ormolu-style lists
respectful: true # don't be too opinionated about newlines etc.
haddock-style: multi-line # '--' vs. '{-'
newlines-between-decls: 1 # number of newlines between top-level declarations
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ in with pkgs;
hlint
cacert
haskellPackages.apply-refact
stylish-haskell
fourmolu_0_6_0_0
git
haskellPackages.cabal-fmt

Expand Down

0 comments on commit b00a2be

Please sign in to comment.