Skip to content

Commit 488d287

Browse files
authored
Add Github precommit workflow (#3060)
* Add Github precommit workflow * Reformat remaining files * Don't shorten project name * Fix pre-commit file exclusion pattern
1 parent 347a718 commit 488d287

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

Diff for: .github/workflows/pre-commit.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- uses: ./.github/actions/setup-build
15+
with:
16+
ghc: "9.2.3"
17+
os: ${{ runner.os }}
18+
shorten-hls: false
19+
20+
- name: "Install stylish-haskell"
21+
run: |
22+
cabal install stylish-haskell
23+
echo "${HOME}/.cabal/bin" >> $GITHUB_PATH
24+
25+
- name: "Check stylish-haskell is available"
26+
run: |
27+
echo $(which stylish-haskell)
28+
29+
- name: Compiled deps cache
30+
id: stylish-haskell-compiled-cache
31+
uses: actions/cache@v2
32+
env:
33+
cache-name: stylish-haskell-compiled-cache
34+
with:
35+
path: ${{ env.CABAL_PKGS_DIR }}
36+
key: ${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
37+
restore-keys: |
38+
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-
39+
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-
40+
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-
41+
42+
- uses: actions/setup-python@v3
43+
- uses: pre-commit/[email protected]

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
"id": "mixed-line-ending",
2626
"args": ["--fix", "lf"],
27-
"exclude": "test/testdata/.*CRLF*.hs$"
27+
"exclude": "test/testdata/.*CRLF.*?\\.hs$"
2828
}
2929
]
3030
}

Diff for: plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import Control.Monad.IO.Class (liftIO)
66
import Control.Monad.Trans.Class (lift)
77
import Control.Monad.Trans.Maybe (MaybeT (MaybeT), runMaybeT)
88
import Data.Foldable (toList)
9-
import qualified Data.HashMap.Strict as HM
109
import Data.Hashable (Hashable)
10+
import qualified Data.HashMap.Strict as HM
1111
import qualified Data.Map as Map
1212
import Data.Maybe (fromJust, mapMaybe)
1313
import qualified Data.Text as T
@@ -24,9 +24,9 @@ import Development.IDE (Action, FileDiagnostic,
2424
getFilesOfInterestUntracked,
2525
hscEnv, msrModSummary,
2626
tmrTypechecked, use, uses)
27+
import Development.IDE.Core.Rules (getHieFile,
28+
getSourceFileSource)
2729
import Development.IDE.Core.RuleTypes (HieAstResult (..))
28-
import Development.IDE.Core.Rules (getSourceFileSource,
29-
getHieFile)
3030
import qualified Development.IDE.Core.Shake as Shake
3131
import Development.IDE.GHC.Compat (HieASTs (HieASTs),
3232
RealSrcSpan (..), mkHieFile',

0 commit comments

Comments
 (0)