Skip to content

Commit 82468ae

Browse files
authored
Merge pull request #26 from MatrixAI/gitlab_ci_configuration
Setup gitlab ci
2 parents 4834c11 + dc7b402 commit 82468ae

File tree

12 files changed

+146
-44
lines changed

12 files changed

+146
-44
lines changed

.gitlab-ci.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1+
variables:
2+
GIT_SUBMODULE_STRATEGY: recursive
3+
14
stages:
5+
- check
26
- build
37

4-
cache:
5-
key: ${CI_COMMIT_REF_SLUG}
6-
paths:
7-
- .cabal-sandbox
8+
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
9+
10+
hlint:
11+
stage: check
12+
script:
13+
- nix-shell --run 'hlint lint ./src ./app ./test'
14+
15+
brittany:
16+
stage: check
17+
script:
18+
- nix-shell --run "find ./src ./app ./test -type f -name '*.hs' -print0 | xargs -0 -I{} sh -c 'brittany --check-mode \"{}\" || echo \"{}\"; exit 1'"
19+
20+
test:
21+
stage: check
22+
script:
23+
- nix-shell --run 'cabal v2-test'
24+
25+
nix-dry:
26+
stage: check
27+
script:
28+
- nix-build -v -v --dry-run ./release.nix --attr library
29+
- nix-build -v -v --dry-run ./release.nix --attr application
30+
- nix-build -v -v --dry-run ./release.nix --attr docker
831

9-
cabal:
32+
nix:
1033
stage: build
11-
image: haskell:8.6.5
1234
script:
13-
- cabal update
14-
- cabal sandbox init
15-
- cabal install hpack
16-
- cabal exec hpack
17-
- cabal install --only-dependencies --enable-tests
18-
- cabal configure --enable-tests
19-
- cabal build
20-
- cabal test
35+
- >
36+
nix-build ./release.nix
37+
--attr library
38+
--attr application
39+
--attr docker
40+
only:
41+
- master

.hlint.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# HLint configuration file
2+
# https://github.com/ndmitchell/hlint
3+
##########################
4+
5+
# This file contains a template configuration file, which is typically
6+
# placed as .hlint.yaml in the root of your project
7+
8+
9+
# Warnings currently triggered by your code
10+
- ignore: {name: "Redundant $"}
11+
- ignore: {name: "Reduce duplication"}
12+
13+
14+
# Specify additional command line arguments
15+
#
16+
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
17+
18+
19+
# Control which extensions/flags/modules/functions can be used
20+
#
21+
# - extensions:
22+
# - default: false # all extension are banned by default
23+
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
24+
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
25+
#
26+
# - flags:
27+
# - {name: -w, within: []} # -w is allowed nowhere
28+
#
29+
# - modules:
30+
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
31+
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
32+
#
33+
# - functions:
34+
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
35+
36+
37+
# Add custom hints for this project
38+
#
39+
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
40+
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
41+
42+
43+
# Turn on hints that are off by default
44+
#
45+
# Ban "module X(module X) where", to require a real export list
46+
# - warn: {name: Use explicit module export list}
47+
#
48+
# Replace a $ b $ c with a . b $ c
49+
# - group: {name: dollar, enabled: true}
50+
#
51+
# Generalise map to fmap, ++ to <>
52+
# - group: {name: generalise, enabled: true}
53+
54+
55+
# Ignore some builtin hints
56+
# - ignore: {name: Use let}
57+
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
58+
59+
60+
# Define some custom infix operators
61+
# - fixity: infixr 3 ~^#^~
62+
63+
64+
# To generate a suitable file for HLint do:
65+
# $ hlint --default > .hlint.yaml

app/ffi/Main.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module Main where
22

3-
import qualified FFI as F
4-
import Lib (someFunc)
3+
import qualified FFI as F
4+
import Lib ( someFunc )
55

66
main :: IO ()
77
main = do
88
time <- F.getTime
9-
let foreignPi = F.getPi
10-
let negPi = F.getNegPi
9+
let foreignPi = F.getPi
10+
let negPi = F.getNegPi
1111
let foreignSum = F.negAdd 1 2
12-
putStrLn $ show time
13-
putStrLn $ show foreignPi
14-
putStrLn $ show negPi
15-
putStrLn $ show foreignSum
12+
print time
13+
print foreignPi
14+
print negPi
15+
print foreignSum
1616
someFunc

app/library/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bar' msg = L.runFileLoggingT "/tmp/demo.log" $ do
5252
$(L.logInfo) $ T.pack $ "[bar'] Got user input: " ++ msg
5353
-- get the logging action from caller's logging context
5454
logAction <- L.askLoggerIO
55-
out <- liftIO $ runBarWithLogger (flip runLoggingT $ logAction) $ preBar msg
55+
out <- liftIO $ runBarWithLogger (`runLoggingT` logAction) $ preBar msg
5656
liftIO $ putStrLn out
5757

5858
-- run runFooBarT and supply a file based logging capability

app/service/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Main where
22

3-
import Demo as Demo
3+
import Demo
44

55
main :: IO ()
66
main = Demo.runDemoApp

brittany.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
conf_forward:
2+
options_ghc:
3+
- -XLambdaCase
4+
- -XMultiWayIf
5+
- -XGADTs
6+
- -XPatternGuards
7+
- -XViewPatterns
8+
- -XRecursiveDo
9+
- -XTupleSections
10+
- -XExplicitForAll
11+
- -XImplicitParams
12+
- -XQuasiQuotes
13+
- -XTemplateHaskell
14+
- -XBangPatterns

pkgs.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import (
2-
let rev = "2867d1963aac8a5f587930644070b7d07e526db3"; in
2+
let rev = "3b2c06909ea24573023a0cef192ab6b4d2936288"; in
33
fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/${rev}.tar.gz"
44
) {}

release.nix

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
with pkgs;
44
let
55
haskellPackages = haskell.packages.ghc865;
6-
strict = drv: haskell.lib.buildStrictly drv;
76
drv = haskellPackages.callPackage ./default.nix {
87
hello = hello;
98
};
109
in
1110
rec {
1211
library = drv;
13-
libraryStrict = strict drv;
1412
application = drv;
15-
applicationStrict = strict drv;
1613
docker = dockerTools.buildImage {
17-
name = applicationStrict.name;
18-
contents = applicationStrict;
14+
name = application.name;
15+
contents = application;
1916
config = {
20-
Cmd = [ "/bin/haskell-demo-exe" ];
17+
Cmd = [ "/bin/haskell-demo-library-exe" ];
2118
};
2219
};
2320
}

shell.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ in
1313
cabal-install
1414
cabal2nix
1515
hpack
16+
hlint
17+
brittany
1618
]);
1719
shellHook = attrs.shellHook + ''
1820
echo 'Entering ${attrs.name}'

src/Demo.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ newtype DemoT m a = DemoT
6262
type Demo = DemoT IO
6363

6464
runDemo :: DemoEnv -> Demo a -> IO a
65-
runDemo env demo = do
66-
L.runStderrLoggingT $ runReaderT (runDemoT demo) env
65+
runDemo env demo = L.runStderrLoggingT $ runReaderT (runDemoT demo) env
6766

6867
warpApp :: Application
6968
warpApp req respond = E.bracket_

0 commit comments

Comments
 (0)