Skip to content

Commit cdf50a6

Browse files
authored
Add GitHub Actions CI for testing (#504)
* Add GitHub workflow for testing * Add HLS_TEST_EXE env var to control which exe to test * Pass -j1 flag to tasty when running tests on GitHub * Enable stack in GitHub CI * Update cabal * Add HLS_WRAPPER_TEST_EXE * Fix cache restore keys * Try force language server to use utf8 locale * Use patched hie-bios * Remove debug print * Lets find out what the windows locale encoding is * Give up trying to fix the locale * Add comment for -j1
1 parent 438f699 commit cdf50a6

24 files changed

+217
-132
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ defaults:
77
on:
88
release:
99
types: [created]
10+
1011
jobs:
1112

1213
build:

.github/workflows/test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Testing
2+
3+
on: [push, pull_request]
4+
jobs:
5+
test:
6+
runs-on: ${{ matrix.os }}
7+
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
ghc: ['8.10.2', '8.10.1', '8.8.4', '8.8.3', '8.8.2', '8.6.5', '8.6.4']
12+
os: [ubuntu-latest, macOS-latest, windows-latest]
13+
exclude:
14+
- os: windows-latest
15+
ghc: '8.10.2' # broken due to https://gitlab.haskell.org/ghc/ghc/-/issues/18550
16+
- os: windows-latest
17+
ghc: '8.8.4' # also fails due to segfault :(
18+
- os: windows-latest
19+
ghc: '8.8.3' # fails due to segfault
20+
- os: windows-latest
21+
ghc: '8.8.2' # fails due to error with Cabal
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
with:
26+
submodules: true
27+
- uses: actions/setup-haskell@v1
28+
with:
29+
ghc-version: ${{ matrix.ghc }}
30+
cabal-version: '3.2'
31+
enable-stack: true
32+
33+
- name: Cache Cabal
34+
uses: actions/cache@v2
35+
env:
36+
cache-name: cache-cabal
37+
with:
38+
path: ~/.cabal/
39+
key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
42+
${{ runner.os }}-${{ matrix.ghc }}-build-
43+
${{ runner.os }}-${{ matrix.ghc }}
44+
45+
- run: cabal update
46+
47+
# Need this to work around filepath length limits in Windows
48+
- name: Shorten binary names
49+
shell: bash
50+
run: |
51+
sed -i.bak -e 's/haskell-language-server/hls/g' \
52+
-e 's/haskell_language_server/hls/g' \
53+
haskell-language-server.cabal
54+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
55+
src/**/*.hs exe/*.hs
56+
57+
- name: Build
58+
run: cabal build
59+
- name: Test
60+
env:
61+
HLS_TEST_EXE: hls
62+
HLS_WRAPPER_TEST_EXE: hls-wrapper
63+
# run the tests without parallelism, otherwise tasty will attempt to run
64+
# all functional test cases simultaneously which causes way too many hls
65+
# instances to be spun up for the poor github actions runner to handle
66+
run: cabal test --test-options=-j1
67+

cabal.project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ source-repository-package
88
location: https://github.com/bubba/brittany.git
99
tag: c59655f10d5ad295c2481537fc8abf0a297d9d1c
1010

11+
source-repository-package
12+
type: git
13+
location: https://github.com/bubba/hie-bios.git
14+
tag: cec139a1c3da1632d9a59271acc70156413017e7
15+
1116
tests: true
1217

1318
package *

test/functional/Command.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Test.Tasty.ExpectedFailure (ignoreTestBecause)
1818
tests :: TestTree
1919
tests = testGroup "commands" [
2020
testCase "are prefixed" $
21-
runSession hieCommand fullCaps "test/testdata/" $ do
21+
runSession hlsCommand fullCaps "test/testdata/" $ do
2222
ResponseMessage _ _ (Right res) <- initializeResponse
2323
let List cmds = res ^. LSP.capabilities . executeCommandProvider . _Just . commands
2424
f x = (T.length (T.takeWhile isNumber x) >= 1) && (T.count ":" x >= 2)
@@ -27,7 +27,7 @@ tests = testGroup "commands" [
2727
not (null cmds) @? "Commands aren't empty"
2828
, ignoreTestBecause "Broken: Plugin package doesn't exist" $
2929
testCase "get de-prefixed" $
30-
runSession hieCommand fullCaps "test/testdata/" $ do
30+
runSession hlsCommand fullCaps "test/testdata/" $ do
3131
ResponseMessage _ _ (Left err) <- request
3232
WorkspaceExecuteCommand
3333
(ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse

test/functional/Completion.hs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Test.Tasty.HUnit
1818

1919
tests :: TestTree
2020
tests = testGroup "completions" [
21-
-- testCase "works" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
21+
-- testCase "works" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
2222
-- doc <- openDoc "Completion.hs" "haskell"
2323
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
2424

@@ -40,7 +40,7 @@ tests = testGroup "completions" [
4040
-- resolved ^. insertTextFormat @?= Just Snippet
4141
-- resolved ^. insertText @?= Just "putStrLn ${1:String}"
4242

43-
-- , testCase "completes imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
43+
-- , testCase "completes imports" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
4444
-- doc <- openDoc "Completion.hs" "haskell"
4545
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
4646

@@ -54,7 +54,7 @@ tests = testGroup "completions" [
5454
-- item ^. detail @?= Just "Data.Maybe"
5555
-- item ^. kind @?= Just CiModule
5656

57-
-- , testCase "completes qualified imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
57+
-- , testCase "completes qualified imports" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
5858
-- doc <- openDoc "Completion.hs" "haskell"
5959
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
6060

@@ -68,7 +68,7 @@ tests = testGroup "completions" [
6868
-- item ^. detail @?= Just "Data.List"
6969
-- item ^. kind @?= Just CiModule
7070

71-
-- , testCase "completes language extensions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
71+
-- , testCase "completes language extensions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
7272
-- doc <- openDoc "Completion.hs" "haskell"
7373
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
7474

@@ -81,7 +81,7 @@ tests = testGroup "completions" [
8181
-- item ^. label @?= "OverloadedStrings"
8282
-- item ^. kind @?= Just CiKeyword
8383

84-
-- , testCase "completes pragmas" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
84+
-- , testCase "completes pragmas" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
8585
-- doc <- openDoc "Completion.hs" "haskell"
8686
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
8787

@@ -96,7 +96,7 @@ tests = testGroup "completions" [
9696
-- item ^. insertTextFormat @?= Just Snippet
9797
-- item ^. insertText @?= Just "LANGUAGE ${1:extension} #-}"
9898

99-
-- , testCase "completes pragmas no close" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
99+
-- , testCase "completes pragmas no close" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
100100
-- doc <- openDoc "Completion.hs" "haskell"
101101
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
102102

@@ -111,7 +111,7 @@ tests = testGroup "completions" [
111111
-- item ^. insertTextFormat @?= Just Snippet
112112
-- item ^. insertText @?= Just "LANGUAGE ${1:extension}"
113113

114-
-- , testCase "completes options pragma" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
114+
-- , testCase "completes options pragma" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
115115
-- doc <- openDoc "Completion.hs" "haskell"
116116
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
117117

@@ -128,7 +128,7 @@ tests = testGroup "completions" [
128128

129129
-- -- -----------------------------------
130130

131-
-- , testCase "completes ghc options pragma values" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
131+
-- , testCase "completes ghc options pragma values" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
132132
-- doc <- openDoc "Completion.hs" "haskell"
133133

134134
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
@@ -146,14 +146,14 @@ tests = testGroup "completions" [
146146

147147
-- -- -----------------------------------
148148

149-
-- , testCase "completes with no prefix" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
149+
-- , testCase "completes with no prefix" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
150150
-- doc <- openDoc "Completion.hs" "haskell"
151151
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
152152
-- compls <- getCompletions doc (Position 5 7)
153153
-- liftIO $ filter ((== "!!") . (^. label)) compls `shouldNotSatisfy` null
154154

155155
-- -- See https://github.com/haskell/haskell-ide-engine/issues/903
156-
-- , testCase "strips compiler generated stuff from completions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
156+
-- , testCase "strips compiler generated stuff from completions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
157157
-- doc <- openDoc "DupRecFields.hs" "haskell"
158158
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
159159

@@ -168,7 +168,7 @@ tests = testGroup "completions" [
168168
-- item ^. detail @?= Just "Two -> Int\nDupRecFields"
169169
-- item ^. insertText @?= Just "accessor ${1:Two}"
170170

171-
-- , testCase "have implicit foralls on basic polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
171+
-- , testCase "have implicit foralls on basic polymorphic types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
172172
-- doc <- openDoc "Completion.hs" "haskell"
173173
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
174174
-- let te = TextEdit (Range (Position 5 7) (Position 5 9)) "id"
@@ -180,7 +180,7 @@ tests = testGroup "completions" [
180180
-- liftIO $
181181
-- resolved ^. detail @?= Just "a -> a\nPrelude"
182182

183-
-- , testCase "have implicit foralls with multiple type variables" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
183+
-- , testCase "have implicit foralls with multiple type variables" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
184184
-- doc <- openDoc "Completion.hs" "haskell"
185185
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
186186
-- let te = TextEdit (Range (Position 5 7) (Position 5 24)) "flip"
@@ -198,7 +198,7 @@ tests = testGroup "completions" [
198198

199199
-- snippetTests :: TestTree
200200
-- snippetTests = testGroup "snippets" [
201-
-- testCase "work for argumentless constructors" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
201+
-- testCase "work for argumentless constructors" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
202202
-- doc <- openDoc "Completion.hs" "haskell"
203203
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
204204

@@ -211,7 +211,7 @@ tests = testGroup "completions" [
211211
-- item ^. insertTextFormat @?= Just Snippet
212212
-- item ^. insertText @?= Just "Nothing"
213213

214-
-- , testCase "work for polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
214+
-- , testCase "work for polymorphic types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
215215
-- doc <- openDoc "Completion.hs" "haskell"
216216
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
217217

@@ -228,7 +228,7 @@ tests = testGroup "completions" [
228228
-- resolved ^. insertTextFormat @?= Just Snippet
229229
-- resolved ^. insertText @?= Just "foldl ${1:b -> a -> b} ${2:b} ${3:t a}"
230230

231-
-- , testCase "work for complex types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
231+
-- , testCase "work for complex types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
232232
-- doc <- openDoc "Completion.hs" "haskell"
233233
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
234234

@@ -245,7 +245,7 @@ tests = testGroup "completions" [
245245
-- resolved ^. insertTextFormat @?= Just Snippet
246246
-- resolved ^. insertText @?= Just "mapM ${1:a -> m b} ${2:t a}"
247247

248-
-- , testCase "work for infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
248+
-- , testCase "work for infix functions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
249249
-- doc <- openDoc "Completion.hs" "haskell"
250250
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
251251

@@ -260,7 +260,7 @@ tests = testGroup "completions" [
260260
-- item ^. insertTextFormat @?= Just Snippet
261261
-- item ^. insertText @?= Just "filter`"
262262

263-
-- , testCase "work for infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
263+
-- , testCase "work for infix functions in backticks" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
264264
-- doc <- openDoc "Completion.hs" "haskell"
265265
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
266266

@@ -275,7 +275,7 @@ tests = testGroup "completions" [
275275
-- item ^. insertTextFormat @?= Just Snippet
276276
-- item ^. insertText @?= Just "filter"
277277

278-
-- , testCase "work for qualified infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
278+
-- , testCase "work for qualified infix functions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
279279
-- doc <- openDoc "Completion.hs" "haskell"
280280
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
281281

@@ -290,7 +290,7 @@ tests = testGroup "completions" [
290290
-- item ^. insertTextFormat @?= Just Snippet
291291
-- item ^. insertText @?= Just "intersperse`"
292292

293-
-- , testCase "work for qualified infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
293+
-- , testCase "work for qualified infix functions in backticks" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
294294
-- doc <- openDoc "Completion.hs" "haskell"
295295
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
296296

@@ -306,7 +306,7 @@ tests = testGroup "completions" [
306306
-- item ^. insertText @?= Just "intersperse"
307307

308308
-- -- TODO : Fix compile issue in the test "Variable not in scope: object"
309-
-- , testCase "respects lsp configuration" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
309+
-- , testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
310310
-- doc <- openDoc "Completion.hs" "haskell"
311311
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
312312

@@ -317,7 +317,7 @@ tests = testGroup "completions" [
317317

318318
-- checkNoSnippets doc
319319

320-
-- , testCase "respects client capabilities" $ runSession hieCommand noSnippetsCaps "test/testdata/completion" $ do
320+
-- , testCase "respects client capabilities" $ runSession hlsCommand noSnippetsCaps "test/testdata/completion" $ do
321321
-- doc <- openDoc "Completion.hs" "haskell"
322322
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
323323

@@ -359,7 +359,7 @@ tests = testGroup "completions" [
359359
contextTests :: TestTree
360360
contextTests = testGroup "contexts" [
361361
ignoreTestBecause "Broken: Timed out waiting to receive a message from the server" $
362-
testCase "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
362+
testCase "only provides type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
363363
doc <- openDoc "Context.hs" "haskell"
364364
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
365365
compls <- getCompletions doc (Position 2 17)
@@ -368,7 +368,7 @@ contextTests = testGroup "contexts" [
368368
compls `shouldNotContainCompl` "interact"
369369

370370
, ignoreTestBecause "Broken: Timed out waiting to receive a message from the server" $
371-
testCase "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
371+
testCase "only provides type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
372372
doc <- openDoc "Context.hs" "haskell"
373373
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
374374
compls <- getCompletions doc (Position 3 9)
@@ -377,7 +377,7 @@ contextTests = testGroup "contexts" [
377377
compls `shouldNotContainCompl` "Applicative"
378378

379379
-- This currently fails if , testCase takes too long to typecheck the module
380-
-- , testCase "completes qualified type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
380+
-- , testCase "completes qualified type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
381381
-- doc <- openDoc "Context.hs" "haskell"
382382
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
383383
-- let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc."

test/functional/Deferred.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tests :: TestTree
2222
tests = testGroup "deferred responses" [
2323

2424
--TODO: DOes not compile
25-
-- testCase "do not affect hover requests" $ runSession hieCommand fullCaps "test/testdata" $ do
25+
-- testCase "do not affect hover requests" $ runSession hlsCommand fullCaps "test/testdata" $ do
2626
-- doc <- openDoc "FuncTest.hs" "haskell"
2727

2828
-- id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing)
@@ -91,21 +91,21 @@ tests = testGroup "deferred responses" [
9191
-- }
9292
-- ]
9393

94-
testCase "instantly respond to failed modules with no cache" $ runSession hieCommand fullCaps "test/testdata" $ do
94+
testCase "instantly respond to failed modules with no cache" $ runSession hlsCommand fullCaps "test/testdata" $ do
9595
doc <- openDoc "FuncTestFail.hs" "haskell"
9696
defs <- getDefinitions doc (Position 1 11)
9797
liftIO $ defs @?= []
9898

9999
-- TODO: the benefits of caching parsed modules is doubted.
100100
-- TODO: add issue link
101101
-- , testCase "respond to untypecheckable modules with parsed module cache" $
102-
-- runSession hieCommand fullCaps "test/testdata" $ do
102+
-- runSession hlsCommand fullCaps "test/testdata" $ do
103103
-- doc <- openDoc "FuncTestFail.hs" "haskell"
104104
-- (Left (sym:_)) <- getDocumentSymbols doc
105105
-- liftIO $ sym ^. name @?= "main"
106106

107107
-- TODO does not compile
108-
-- , testCase "returns hints as diagnostics" $ runSession hieCommand fullCaps "test/testdata" $ do
108+
-- , testCase "returns hints as diagnostics" $ runSession hlsCommand fullCaps "test/testdata" $ do
109109
-- _ <- openDoc "FuncTest.hs" "haskell"
110110

111111
-- cwd <- liftIO getCurrentDirectory
@@ -145,7 +145,7 @@ tests = testGroup "deferred responses" [
145145
-- multiServerTests :: TestTree
146146
-- multiServerTests = testGroup "multi-server setup" [
147147
-- testCase "doesn't have clashing commands on two servers" $ do
148-
-- let getCommands = runSession hieCommand fullCaps "test/testdata" $ do
148+
-- let getCommands = runSession hlsCommand fullCaps "test/testdata" $ do
149149
-- rsp <- initializeResponse
150150
-- let uuids = rsp ^? result . _Just . capabilities . executeCommandProvider . _Just . commands
151151
-- return $ fromJust uuids
@@ -158,7 +158,7 @@ multiMainTests :: TestTree
158158
multiMainTests = testGroup "multiple main modules" [
159159
ignoreTestBecause "Broken: Unexpected ConduitParser.empty" $
160160
testCase "Can load one file at a time, when more than one Main module exists"
161-
$ runSession hieCommand fullCaps "test/testdata" $ do
161+
$ runSession hlsCommand fullCaps "test/testdata" $ do
162162
_doc <- openDoc "ApplyRefact2.hs" "haskell"
163163
_diagsRspHlint <- skipManyTill anyNotification message :: Session PublishDiagnosticsNotification
164164
diagsRspGhc <- skipManyTill anyNotification message :: Session PublishDiagnosticsNotification

0 commit comments

Comments
 (0)