git.iko.soy/typeable/servant-reflex
on master help sign in
Add skeletal test framework and travis scripts to deploy test coverage
commit47dfbeeda17fd73ccd6d76c6cbeede6040de7f43 authorGreg Hale <imalsogreg@gmail.com> dateWed 3 Aug 2016, 20:03 (10 years ago) parent3c71807
8 files changed+143−10
.travis.yml+17−8 deploy.sh+65 deploy_key.enc deps/reflex-dom-contrib+1−1 deps/servant-snap+1−1 runTestsAndCoverage.sh+46 servant-reflex.cabal+9 test/Tests.hs+4
.travis.yml+17−8
@@ -1,13 +1,22 @@
11sudo: required
2+
3+before_install:
4+ - openssl aes-256-cbc -K $encrypted_3c89d919c82e_key -iv $encrypted_3c89d919c82e_iv -in deploy_key.enc -out ~\/deploy_key -d
5+
26script:
3− - git config --global user.email "travis-ci@example.com"
4− - git config --global user.name "Travis-CI"
5− - git submodule update --init --recursive
6− - deps/reflex-platform/work-on ghcjs ./. --command "cabal configure --ghcjs && cabal build" # ./try-reflex --command "exit 0"
7− # - travis_wait ./test -j 2
7+- git config --global user.email "travis-ci@example.com"
8+- git config --global user.name "Travis-CI"
9+- git submodule update --init --recursive
10+- deps/reflex-platform/work-on ghcjs ./. --command "cabal configure --ghcjs && cabal build"
11+- deps/reflex-platform/work-on ghcjs ./. --command "./deploy.sh"
12+
813cache:
914 directories:
10− - /nix
15+ - /nix
1116os:
12− - linux
13− # - osx # TODO
17+- linux
18+
19+env:
20+ global:
21+ - ENCRYPTION_LABEL: "3c89d919c82e"
22+ - COMMIT_AUTHOR_EMAIL: "imalsogreg@gmail.com"
deploy.shnew file+65
@@ -0,0 +1,65 @@
1+#!/bin/bash
2+
3+set -e # Exit with nonzero exit code if anything fails
4+
5+SOURCE_BRANCH="dynamic"
6+TARGET_BRANCH="gh-pages"
7+OUT=dist-newstyle/hpc
8+
9+function doCompile {
10+ ./runTestsAndCoverage.sh
11+}
12+
13+# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
14+if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
15+ echo "Skipping deploy; just doing a build."
16+ doCompile
17+ exit 0
18+fi
19+
20+# Save some useful information
21+REPO=`git config remote.origin.url`
22+SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
23+SHA=`git rev-parse --verify HEAD`
24+
25+# Clone the existing gh-pages for this repo into $OUTt/
26+# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
27+git clone $REPO $OUT
28+cd $OUT
29+git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
30+cd ..
31+
32+# Clean out existing contents
33+rm -rf $OUT/**/* || exit 0
34+
35+# Run our compile script
36+doCompile
37+
38+# Now let's go have some fun with the cloned repo
39+cd $OUT
40+git config user.name "Travis CI"
41+git config user.email "$COMMIT_AUTHOR_EMAIL"
42+
43+# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
44+if [ -z `git diff --exit-code` ]; then
45+ echo "No changes to the output on this push; exiting."
46+ exit 0
47+fi
48+
49+# Commit the "changes", i.e. the new version.
50+# The delta will show diffs between new and old versions.
51+git add .
52+git commit -m "Deploy to GitHub Pages: ${SHA}"
53+
54+# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
55+ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
56+ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
57+ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
58+ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
59+openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d
60+chmod 600 deploy_key
61+eval `ssh-agent -s`
62+ssh-add deploy_key
63+
64+# Now that we're all set up, we can push.
65+git push $SSH_REPO $TARGET_BRANCH
deploy_key.encnew file

Binary file not shown.

deps/reflex-dom-contrib+1−1

Submodule changed.

deps/servant-snap+1−1

Submodule changed.

runTestsAndCoverage.shnew file+46
@@ -0,0 +1,46 @@
1+#!/bin/sh
2+
3+set -e
4+
5+# All directory variables relative to project root
6+DIR=dist-newstyle/hpc
7+
8+SUITE=./dist-newstyle/build/servant-reflex-0.2/build/testsuite/testsuite
9+
10+if [ -z "$DEBUG" ]; then
11+ export DEBUG=snap-testsuite
12+fi
13+
14+rm -f testsuite.tix
15+rm -rf "$DIR"
16+mkdir -p "$DIR"
17+
18+if [ ! -f $SUITE ]; then
19+ cat <<EOF
20+Testsuite executable not found, please run:
21+ cabal install --enable-tests --only-dependencies
22+ cabal configure --enable-tests
23+ cabal build
24+EOF
25+ exit;
26+fi
27+
28+$SUITE $*
29+
30+EXCLUDES='Main
31+Paths_servant-reflex
32+'
33+
34+EXCL=""
35+
36+for m in $EXCLUDES; do
37+ EXCL="$EXCL --exclude=$m"
38+done
39+
40+# TODO - actually send results to /dev/null when hpc kinks are fully removed
41+hpc markup $EXCL --destdir=$DIR testsuite # >/dev/null 2>&1
42+
43+cat <<EOF
44+
45+Test coverage report written to $HTMLDIR.
46+EOF
servant-reflex.cabal+9
@@ -53,3 +53,12 @@ executable example
5353 main-is: Example.hs
5454 other-modules: API
5555 hs-source-dirs: exec
56+
57+test-suite testsuite
58+ type: exitcode-stdio-1.0
59+ main-is: Tests.hs
60+ hs-source-dirs: test
61+ ghc-prof-options: -prof -auto
62+ ghc-options: -Wall -fwarn-tabs -O2 -fhpc -threaded
63+ other-modules:
64+ build-depends: base
test/Tests.hsnew file+4
@@ -0,0 +1,4 @@
1+module Main where
2+
3+main :: IO ()
4+main = return ()