on master help sign in
Merge branch 'travis-build-matrix' of https://github.com/diogob/project-m36 into diogob-travis-build-matrix
commitd395a361fdfa46229b83f3f3b66660c5c2152e36 authorAgentM <agentm@themactionfaction.com> dateFri 29 Dec 2017, 22:54 (9 years ago) parent52a18c6f21cb20
6 files changed+127−52
.travis.yml+40−41 .travis/attach-binary.sh+25 .travis/install-ghr.sh+21 .travis/install-stack.sh+29 src/lib/ProjectM36/ScriptSession.hs+4−2 test/Relation/StaticOptimizer.hs+8−9
.travis.yml+40−41
@@ -1,5 +1,5 @@
1−# For more information, see https://github.com/hvr/multi-ghc-travis
2−language: c
1+# For more information, see https://github.com/ChrisPenner/haskell-stack-travis-ci
2+language: nix
33sudo: false
44
55git:
@@ -7,52 +7,51 @@ git:
77
88cache:
99 directories:
10− - $HOME/.cabal/packages
11− - $HOME/.cabal/store
12−
13−before_cache:
14− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
15− # remove files that are regenerated by 'cabal update'
16− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
17− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
18− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
19− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
20− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
10+ - $HOME/.ghc
11+ - $HOME/.cabal
12+ - $HOME/.stack
13+ - .stack-work
2114
2215matrix:
16+ fast_finish: true
2317 include:
24− #- compiler: "ghc-7.8.4"
25− # env: TEST=--disable-tests BENCH=--disable-benchmarks
26− # addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
27− - compiler: "ghc-7.10.3"
28− # env: TEST=--disable-tests BENCH=--disable-benchmarks
29− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
30− - compiler: "ghc-8.0.2"
31− # env: TEST=--disable-tests BENCH=--disable-benchmarks
32− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
33− #- compiler: "ghc-8.2.1"
34− # env: TEST=--disable-tests BENCH=--disable-benchmarks
35− # addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
36−
37−before_install:
38− - HC=${CC}
39− - unset CC
40− - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
18+ - env: GHCVER=7.10.3 CACHE_NAME=7.10.3
19+ compiler: ": #stack 7.10.3"
20+ addons: {apt: {packages: [ghc-7.10.3], sources: [hvr-ghc]}}
4121
42−install:
43− - cabal --version
44− - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
45− - travis_retry cabal update -v
46− - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
22+ - env: GHCVER=8.0.2 CACHE_NAME=8.0.2
23+ compiler: ": #stack 8.0.2"
24+ addons: {apt: {packages: [ghc-8.0.2], sources: [hvr-ghc]}}
4725
48− - cabal new-build -w ${HC} --enable-tests --dep -j2 all
26+ - env: GHCVER=8.2.1 CACHE_NAME=8.2.1 BUILD_BINARY=1
27+ compiler: ": #stack 8.2.1"
28+ addons: {apt: {packages: [ghc-8.2.1], sources: [hvr-ghc]}}
29+
30+ - env: GHCVER=8.2.1 CACHE_NAME=8.2.1-osx BUILD_BINARY=1
31+ os: osx
32+ compiler: ": #stack 8.2.1"
33+ addons: {apt: {packages: [ghc-8.2.1], sources: [hvr-ghc]}}
34+
35+install:
36+ - unset CC
37+ - export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:$PATH
38+ - ./.travis/install-ghr.sh
39+ - ./.travis/install-stack.sh
4940
5041# Here starts the actual work to be performed for the package under test;
5142# any command which exits with a non-zero exit code causes the build to fail.
5243script:
53− - cabal sdist
54− - cabal new-build -w ${HC} -j1
55− - cabal new-test -w ${HC}
56− - curl -sL https://raw.github.com/ndmitchell/hlint/master/misc/travis.sh | sh -s lint src test examples --cpp-define VERSION_project_m36=HLINT
57− - cabal new-haddock
44+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
45+ - GHC_OPTIONS=""
46+ - |
47+ set -ex
48+ # Run tests
49+ stack --no-terminal test --ghc-options="$GHC_OPTIONS"
50+ set +ex
51+
52+after_success:
53+ - |
54+ # Build and ship binary
55+ ./.travis/attach-binary.sh
56+
5857# EOF
.travis/attach-binary.shnew file+25
@@ -0,0 +1,25 @@
1+#!/bin/sh
2+set -o errexit -o verbose
3+
4+if test ! "$BUILD_BINARY" || test ! "$TRAVIS_TAG"
5+then
6+ echo 'This is not a release build.'
7+elif test ! "$GITHUB_TOKEN"
8+then
9+ echo 'The GITHUB_TOKEN environment variable is not set!'
10+ exit 1
11+else
12+ echo "Building binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
13+ stack build --ghc-options -O2 --pedantic
14+ echo "Attaching binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
15+ OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
16+ REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
17+ BIN="$(stack path --local-install-root)/bin/$REPO"
18+ BUNDLE_NAME="$REPO-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.gz"
19+ cp "$BIN" "./$REPO"
20+ chmod +x "./$REPO"
21+ tar -czf "$BUNDLE_NAME" "$REPO"
22+ echo "SHA256:"
23+ shasum -a 256 "$BUNDLE_NAME"
24+ ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
25+fi
.travis/install-ghr.shnew file+21
@@ -0,0 +1,21 @@
1+#!/bin/sh
2+set -o errexit -o verbose
3+
4+if test ! "$BUILD_BINARY" || test ! "$TRAVIS_TAG"
5+then
6+ echo 'This is not a release build.'
7+else
8+ if [ "$TRAVIS_OS_NAME" = "linux" ]
9+ then
10+ ARCH="linux"
11+ else
12+ ARCH="darwin"
13+ fi
14+ echo "Installing ghr"
15+ URL="https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_${ARCH}_386.zip"
16+ curl -L ${URL} > ghr.zip
17+ mkdir -p "$HOME/bin"
18+ export PATH="$HOME/bin:$PATH"
19+ unzip ghr.zip -d "$HOME/bin"
20+ rm ghr.zip
21+fi
.travis/install-stack.shnew file+29
@@ -0,0 +1,29 @@
1+#!/bin/sh
2+
3+# Adapted from https://github.com/commercialhaskell/stack
4+
5+set -eux
6+
7+travis_retry() {
8+ cmd=$*
9+ $cmd || (sleep 2 && $cmd) || (sleep 10 && $cmd)
10+}
11+
12+fetch_stack_osx() {
13+ curl -skL https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin;
14+}
15+
16+fetch_stack_linux() {
17+ curl -sL https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack';
18+}
19+
20+# We need stack to generate cabal files with precise bounds, even for cabal
21+# builds.
22+mkdir -p ~/.local/bin;
23+if [ "$(uname)" = "Darwin" ]; then
24+ travis_retry fetch_stack_osx
25+else
26+ travis_retry fetch_stack_linux
27+fi
28+
29+travis_retry stack --no-terminal setup;
src/lib/ProjectM36/ScriptSession.hs+4−2
@@ -46,7 +46,9 @@ initScriptSession ghcPkgPaths = do
4646
4747 sandboxPkgPaths <- liftIO $ concat <$> mapM glob [
4848 "./dist-newstyle/packagedb/ghc-" ++ ghcVersion,
49− ".cabal-sandbox/*ghc-" ++ ghcVersion ++ "-packages.conf.d",
49+ ".cabal-sandbox/*ghc-" ++ ghcVersion ++ "-packages.conf.d",
50+ ".stack-work/install/*/*/" ++ ghcVersion ++ "/pkgdb",
51+ homeDir </> ".stack/snapshots/*/*/" ++ ghcVersion ++ "/pkgdb",
5052 homeDir </> ".cabal/store/ghc-" ++ ghcVersion ++ "/package.db"
5153 ]
5254
@@ -171,4 +173,4 @@ typeCheckScript expectedType inp = do
171173 pure Nothing
172174 else
173175 pure (Just (TypeCheckCompilationError (showType dflags expectedType) (showType dflags funcType)))
174−
176+
test/Relation/StaticOptimizer.hs+8−9
@@ -124,15 +124,14 @@ testPushDownRestrictionPredicate :: Test
124124testPushDownRestrictionPredicate = TestCase $ do
125125 -- (s union relation{tuple{city "Boston", s# "S6", sname "Stevens", status 50}}) where status = 30 == (s where status=30) union (relation{tuple{city "Boston", s# "S6", sname "Stevens", status 50}} where status=30)
126126 let rvs = RelationVariable "s" ()
127− stevens <- case mkRelationFromList (attributes suppliersRel) [
128− [TextAtom "S6", TextAtom "Stevens", IntegerAtom 50, TextAtom "Boston"]] of
129− Left err -> assertFailure $ "stevens relation: " ++ show err
130− Right rel -> pure rel
131− let expr1 = Restrict status30 (Union rvs (ExistingRelation stevens))
132− status30 = AttributeEqualityPredicate "status" (NakedAtomExpr (IntAtom 30))
127+ relationsOrError = do
128+ stevens <- mkRelationFromList (attributes suppliersRel) [[TextAtom "S6", TextAtom "Stevens", IntegerAtom 50, TextAtom "Boston"]]
129+ let expr1 = Restrict status30 (Union rvs (ExistingRelation stevens))
130+ status30 = AttributeEqualityPredicate "status" (NakedAtomExpr (IntAtom 30))
133131
134− expectedExpr1 = Union (Restrict status30 rvs) (Restrict status30 (ExistingRelation stevens))
135− assertEqual "union restriction pushdown" expectedExpr1 (applyStaticRestrictionPushdown expr1)
132+ expectedExpr1 = Union (Restrict status30 rvs) (Restrict status30 (ExistingRelation stevens))
133+ pure $ (expectedExpr1, (applyStaticRestrictionPushdown expr1))
134+ either (assertFailure . (++) "stevens relation: " . show) (uncurry $ assertEqual "union restriction pushdown") relationsOrError
136135
137136 -- s{sname,city} where city="London" == (s where city="London"){sname,city}
138137 let expr2 = Restrict whereLondon (Project projAttrs2 rvs)
@@ -144,4 +143,4 @@ testPushDownRestrictionPredicate = TestCase $ do
144143 -- (s where city="London"){sname} != s{sname} where city="London" (no "city" attribute at projection time)
145144 let expr3 = Project projAttrs3 (Restrict whereLondon rvs)
146145 projAttrs3 = AttributeNames (S.singleton "sname")
147− assertEqual "projection restriction no-pushdown" expr3 (applyStaticRestrictionPushdown expr3)
146+ assertEqual "projection restriction no-pushdown" expr3 (applyStaticRestrictionPushdown expr3)