Skip to content

Commit e694e8b

Browse files
committed
Add HLint to CI
1 parent c477ec7 commit e694e8b

File tree

3 files changed

+109
-7
lines changed

3 files changed

+109
-7
lines changed

.github/workflows/hlint.yml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: HLint
2+
3+
on:
4+
push:
5+
create:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
fail-fast: false
13+
14+
env:
15+
# Modify this value to "invalidate" the cabal cache.
16+
CABAL_CACHE_VERSION: "2022-12-30"
17+
18+
HLINT_VERSION: "3.5"
19+
20+
steps:
21+
- name: Install Haskell
22+
uses: input-output-hk/setup-haskell@v1
23+
id: setup-haskell
24+
with:
25+
ghc-version: 9.2.4
26+
cabal-version: 3.8.1.0
27+
28+
- name: Cabal update
29+
run: cabal update
30+
31+
- name: Get hlint
32+
run: cabal get "hlint-$HLINT_VERSION"
33+
34+
- name: Build dry run for hlint
35+
run: |
36+
cd "hlint-$HLINT_VERSION"
37+
cabal build all --dry-run
38+
39+
# For users who fork cardano-node and want to define a writable cache, then can set up their own
40+
# S3 bucket then define in their forked repository settings the following secrets:
41+
#
42+
# AWS_ACCESS_KEY_ID
43+
# AWS_SECRET_ACCESS_KEY
44+
# BINARY_CACHE_URI
45+
# BINARY_CACHE_REGION
46+
- name: Cabal cache over S3
47+
uses: action-works/cabal-cache-s3@v1
48+
env:
49+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
50+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
51+
with:
52+
region: ${{ secrets.BINARY_CACHE_REGION }}
53+
dist-dir: hlint-${{ env.HLINT_VERSION }}/dist-newstyle
54+
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
55+
threads: 16
56+
archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}
57+
skip: "${{ secrets.BINARY_CACHE_URI == '' }}"
58+
59+
# It's important to ensure that people who fork this repository can not only successfully build in
60+
# CI by default, but also have meaning cabal store caching.
61+
#
62+
# Because syncing with S3 requires credentials, we cannot rely on S3 for this. For this reason a
63+
# https fallback is used. The https server mirrors the content of the S3 bucket. The https cabal
64+
# store archive is read-only for security reasons.
65+
#
66+
# Users who fork this repository who want to have a writable cabal store archive are encouraged
67+
# to set up their own S3 bucket.
68+
- name: Cabal cache over HTTPS
69+
uses: action-works/cabal-cache-s3@v1
70+
with:
71+
dist-dir: hlint-${{ env.HLINT_VERSION }}/dist-newstyle
72+
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
73+
threads: 16
74+
archive-uri: https://iohk.cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}
75+
skip: "${{ secrets.BINARY_CACHE_URI != '' }}"
76+
enable-save: false
77+
78+
- name: Build hlint
79+
run: |
80+
cd "hlint-$HLINT_VERSION"
81+
cabal build all
82+
83+
- name: Install hlint
84+
run: |
85+
cd "hlint-$HLINT_VERSION"
86+
cabal install exe:hlint
87+
88+
- name: Remove hlint build directory
89+
run: rm -rf "hlint-$HLINT_VERSION"
90+
91+
- name: hlint installation directory
92+
run: find . -name hlint
93+
94+
- name: Add installation directory to path
95+
run: echo "PATH=$HOME/.cabal/bin:$PATH" >> $GITHUB_ENV
96+
97+
- uses: actions/checkout@v2
98+
99+
- name: Run hlint over all Haskell files
100+
run: |
101+
hlint . --threads=4

.hlint.yaml

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
# placed as .hlint.yaml in the root of your project
77

88

9-
# Warnings currently triggered by your code
10-
- ignore: {name: "Move brackets to avoid $"}
11-
129
# Specify additional command line arguments
1310
#
1411
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
@@ -37,6 +34,12 @@
3734
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
3835
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
3936

37+
# The hints are named by the string they display in warning messages.
38+
# For example, if you see a warning starting like
39+
#
40+
# Main.hs:116:51: Warning: Redundant ==
41+
#
42+
# You can refer to that hint with `{name: Redundant ==}` (see below).
4043

4144
# Turn on hints that are off by default
4245
#
@@ -53,7 +56,7 @@
5356
# Ignore some builtin hints
5457
# - ignore: {name: Use let}
5558
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
56-
# - ignore: {name: "Use lambda-case"}
59+
5760

5861
# Define some custom infix operators
5962
# - fixity: infixr 3 ~^#^~

cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus
9999
import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry
100100
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery
101101

102-
{- HLINT ignore "Reduce duplication" -}
103-
{- HLINT ignore "Use const" -}
104-
{- HLINT ignore "Use let" -}
102+
{- HLINT ignore "Move brackets to avoid $" -}
105103

106104
data ShelleyQueryCmdError
107105
= ShelleyQueryCmdEnvVarSocketErr !EnvSocketError

0 commit comments

Comments
 (0)