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

Add GitHub Actions CI for testing #504

Merged
merged 13 commits into from
Oct 19, 2020
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defaults:
on:
release:
types: [created]

jobs:

build:
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Testing

on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
ghc: ['8.10.2', '8.10.1', '8.8.4', '8.8.3', '8.8.2', '8.6.5', '8.6.4']
os: [ubuntu-latest, macOS-latest, windows-latest]
exclude:
- os: windows-latest
ghc: '8.10.2' # broken due to https://gitlab.haskell.org/ghc/ghc/-/issues/18550
- os: windows-latest
ghc: '8.8.4' # also fails due to segfault :(
- os: windows-latest
ghc: '8.8.3' # fails due to segfault
- os: windows-latest
ghc: '8.8.2' # fails due to error with Cabal

steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-haskell@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2'
enable-stack: true

- name: Cache Cabal
uses: actions/cache@v2
env:
cache-name: cache-cabal
with:
path: ~/.cabal/
key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
${{ runner.os }}-${{ matrix.ghc }}-build-
${{ runner.os }}-${{ matrix.ghc }}

- run: cabal update

# Need this to work around filepath length limits in Windows
- name: Shorten binary names
shell: bash
run: |
sed -i.bak -e 's/haskell-language-server/hls/g' \
-e 's/haskell_language_server/hls/g' \
haskell-language-server.cabal
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
src/**/*.hs exe/*.hs

- name: Build
run: cabal build
- name: Test
env:
HLS_TEST_EXE: hls
HLS_WRAPPER_TEST_EXE: hls-wrapper
# run the tests without parallelism, otherwise tasty will attempt to run
# all functional test cases simultaneously which causes way too many hls
# instances to be spun up for the poor github actions runner to handle
run: cabal test --test-options=-j1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you add -j1 due a concrete issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of precaution, the tests previously failed on circleci because without -j1 tasty attempts to run all the functional tests in parallel, which means it spins up 20 or so hls instances simultaneously. I'm not sure if the GitHub runners can handle it or not but the circleCI runners definitely couldn't!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it worths a comment?


5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ source-repository-package
location: https://github.com/bubba/brittany.git
tag: c59655f10d5ad295c2481537fc8abf0a297d9d1c

source-repository-package
type: git
location: https://github.com/bubba/hie-bios.git
tag: cec139a1c3da1632d9a59271acc70156413017e7

tests: true

package *
Expand Down
4 changes: 2 additions & 2 deletions test/functional/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Test.Tasty.ExpectedFailure (ignoreTestBecause)
tests :: TestTree
tests = testGroup "commands" [
testCase "are prefixed" $
runSession hieCommand fullCaps "test/testdata/" $ do
runSession hlsCommand fullCaps "test/testdata/" $ do
ResponseMessage _ _ (Right res) <- initializeResponse
let List cmds = res ^. LSP.capabilities . executeCommandProvider . _Just . commands
f x = (T.length (T.takeWhile isNumber x) >= 1) && (T.count ":" x >= 2)
Expand All @@ -27,7 +27,7 @@ tests = testGroup "commands" [
not (null cmds) @? "Commands aren't empty"
, ignoreTestBecause "Broken: Plugin package doesn't exist" $
testCase "get de-prefixed" $
runSession hieCommand fullCaps "test/testdata/" $ do
runSession hlsCommand fullCaps "test/testdata/" $ do
ResponseMessage _ _ (Left err) <- request
WorkspaceExecuteCommand
(ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse
Expand Down
48 changes: 24 additions & 24 deletions test/functional/Completion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Test.Tasty.HUnit

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- -- -----------------------------------

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

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

-- -- -----------------------------------

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- checkNoSnippets doc

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

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

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

-- This currently fails if , testCase takes too long to typecheck the module
-- , testCase "completes qualified type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
-- , testCase "completes qualified type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
-- doc <- openDoc "Context.hs" "haskell"
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
-- let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc."
Expand Down
12 changes: 6 additions & 6 deletions test/functional/Deferred.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tests :: TestTree
tests = testGroup "deferred responses" [

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

-- id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing)
Expand Down Expand Up @@ -91,21 +91,21 @@ tests = testGroup "deferred responses" [
-- }
-- ]

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

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

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

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