Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 59d4af0

Browse files
authored
Merge pull request #1031 from bubba/hspec-formatter
CI improvements
2 parents 60280ce + 11996fb commit 59d4af0

File tree

15 files changed

+172
-42
lines changed

15 files changed

+172
-42
lines changed

.circleci/config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defaults: &defaults
1818

1919
- run:
2020
name: Create a composite cabal file for changes detection
21-
command: find . -name "*.cabal" | grep -v "stack-work" | xargs cat > all-cabal.txt
21+
command: find . -name "*.cabal" | grep -v -e "stack-work" -e "dist-newstyle" -e "submodules" -e "testdata" | sort | xargs cat > all-cabal.txt
2222

2323
- restore_cache:
2424
keys:
@@ -52,7 +52,7 @@ defaults: &defaults
5252

5353
- run:
5454
name: Generate Hoogle database
55-
command: stack --stack-yaml=${STACK_FILE} exec hoogle generate
55+
command: if [ ! -d ~/.hoogle ]; then stack --stack-yaml=${STACK_FILE} exec hoogle generate; fi
5656

5757
- run:
5858
name: Clear cabal-helper cache
@@ -63,6 +63,7 @@ defaults: &defaults
6363
paths: &cache_paths
6464
- ~/.stack
6565
- ~/.cache
66+
- ~/.hoogle
6667
- ~/build/.stack-work
6768
- ~/build/hie-plugin-api/.stack-work
6869
- ~/build/submodules/HaRe/.stack-work
@@ -78,6 +79,9 @@ defaults: &defaults
7879
command: stack -j 1 --stack-yaml=${STACK_FILE} test --dump-logs
7980
no_output_timeout: 120m
8081

82+
- store_test_results:
83+
path: test-results
84+
8185
- store_artifacts:
8286
path: test-logs
8387

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dist-newstyle/
6161
dist
6262
tags
6363
test-logs/
64+
test-results/
6465
.DS_Store
6566

6667
.hspec-failures

cabal.project

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ packages:
66
./submodules/brittany
77
./submodules/cabal-helper/
88
./submodules/ghc-mod/
9-
./submodules/ghc-mod/core/
10-
11-
12-
-- allow-newer:ekg-core-0.1.1.4:base
13-
-- allow-newer:ekg-json-0.1.0.6:base
9+
./submodules/ghc-mod/core/

docs/CircleCI.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CircleCI
2+
3+
## Jobs
4+
5+
For each version of GHC supported, CircleCI will kick off a build that will build and test HIE for that version.
6+
Whenever a new stack-x.y.z is added, be sure to also add it to both the `workflow` and `jobs` sections of `config.yml`.
7+
8+
In addition to the stack based jobs, there is also a job that builds HIE with `cabal new-build`.
9+
Currently tests are not run as there is an issue with cabal-helper-wrapper that prevents any ghc-mod tests from passing.
10+
11+
## Docker
12+
13+
Each job is carried out in a Docker container built from https://github.com/alanz/haskell-dockerfiles/blob/master/haskell-hie-ci/Dockerfile
14+
15+
## Caching
16+
17+
Since HIE takes a long time to build, CI caches things very liberally.
18+
Most importantly, the `~/.stack-work` directories for HIE as well as every submodule are cached before and after testing (This is so that if the build passes but the tests fail there is still something cached for the next build).
19+
20+
### Change detection
21+
22+
Before restoring any cache, the CircleCI job creates three files and uses their checksum to detect any changes:
23+
24+
1. `all-cabal.txt` detects any changes to `.cabal` files (not in submodules or test data)
25+
2. `stack-build.txt` detects any changes to the `stack-x.y.z` file
26+
3. `resolver.txt` detects any changes to the stack resolver
27+
28+
Each job will tries to restore the most specific cache avaialble for it, and fallback to a more general cache if not available:
29+
30+
31+
```yaml
32+
- restore_cache:
33+
keys:
34+
- stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}-{{ checksum "all-cabal.txt" }}
35+
- stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}
36+
- stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}
37+
```
38+
39+
## Invalidating the cache
40+
41+
If you need to clear the cache on CircleCI, bump the `$HIE_CACHE` environment variable via the CircleCI web interface and rerun the workflow.

haskell-ide-engine.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,15 @@ library hie-test-utils
144144
, haskell-lsp
145145
, hie-plugin-api
146146
, aeson
147+
, blaze-markup
147148
, containers
148149
, data-default
149150
, directory
150151
, filepath
151152
, ghc-mod-core
152153
, hslogger
153154
, hspec
155+
, hspec-core
154156
, stm
155157
, text
156158
, unordered-containers

stack-8.6.1.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ extra-deps:
3434
- temporary-1.2.1.1
3535
- yaml-0.8.32
3636

37-
3837
flags:
3938
haskell-ide-engine:
4039
pedantic: true

stack-8.6.3.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extra-deps:
2323
- temporary-1.2.1.1
2424
- yaml-0.8.32
2525

26-
2726
flags:
2827
haskell-ide-engine:
2928
pedantic: true

test/dispatcher/Main.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import System.Directory
2323
import System.FilePath
2424

2525
import Test.Hspec
26+
import Test.Hspec.Runner
2627

2728
-- ---------------------------------------------------------------------
2829
-- plugins
@@ -40,8 +41,9 @@ import Haskell.Ide.Engine.Plugin.HieExtras
4041
main :: IO ()
4142
main = do
4243
setupStackFiles
44+
config <- getHspecFormattedConfig "dispatcher"
4345
withFileLogging "main-dispatcher.log" $ do
44-
hspec funcSpec
46+
hspecWith config funcSpec
4547

4648
-- main :: IO ()
4749
-- main = do

test/functional/Main.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Main where
33
import Control.Monad.IO.Class
44
import Language.Haskell.LSP.Test
55
import qualified FunctionalSpec
6-
import Test.Hspec
6+
import Test.Hspec.Runner (hspecWith)
77
import TestUtils
88

99
main :: IO ()
@@ -13,5 +13,6 @@ main = do
1313
putStrLn "Warming up HIE cache..."
1414
runSessionWithConfig (defaultConfig { messageTimeout = 120 }) hieCommand fullCaps "test/testdata" $
1515
liftIO $ putStrLn "HIE cache is warmed up"
16-
-- withFileLogging "functional.log" $ hspec FunctionalSpec.spec
17-
withFileLogging logFilePath $ hspec FunctionalSpec.spec
16+
17+
config <- getHspecFormattedConfig "functional"
18+
withFileLogging logFilePath $ hspecWith config $ FunctionalSpec.spec

test/plugin-dispatcher/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import Language.Haskell.LSP.Types
1414
import TestUtils
1515

1616
import Test.Hspec
17+
import Test.Hspec.Runner
1718

1819
-- ---------------------------------------------------------------------
1920

2021
main :: IO ()
2122
main = do
2223
setupStackFiles
23-
withFileLogging "plugin-dispatcher.log" $ do
24-
hspec newPluginSpec
24+
config <- getHspecFormattedConfig "plugin-dispatcher"
25+
withFileLogging "plugin-dispatcher.log" $ hspecWith config newPluginSpec
2526

2627
-- ---------------------------------------------------------------------
2728

0 commit comments

Comments
 (0)