Add skeletal test framework and travis scripts to deploy test coverage

This commit is contained in:
Greg Hale 2016-08-03 20:03:00 -04:00
parent 3c71807563
commit 47dfbeeda1
8 changed files with 143 additions and 10 deletions

View File

@ -1,13 +1,22 @@
sudo: required
before_install:
- openssl aes-256-cbc -K $encrypted_3c89d919c82e_key -iv $encrypted_3c89d919c82e_iv -in deploy_key.enc -out ~\/deploy_key -d
script:
- git config --global user.email "travis-ci@example.com"
- git config --global user.name "Travis-CI"
- git submodule update --init --recursive
- deps/reflex-platform/work-on ghcjs ./. --command "cabal configure --ghcjs && cabal build" # ./try-reflex --command "exit 0"
# - travis_wait ./test -j 2
- git config --global user.email "travis-ci@example.com"
- git config --global user.name "Travis-CI"
- git submodule update --init --recursive
- deps/reflex-platform/work-on ghcjs ./. --command "cabal configure --ghcjs && cabal build"
- deps/reflex-platform/work-on ghcjs ./. --command "./deploy.sh"
cache:
directories:
- /nix
- /nix
os:
- linux
# - osx # TODO
- linux
env:
global:
- ENCRYPTION_LABEL: "3c89d919c82e"
- COMMIT_AUTHOR_EMAIL: "imalsogreg@gmail.com"

65
deploy.sh Normal file
View File

@ -0,0 +1,65 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails
SOURCE_BRANCH="dynamic"
TARGET_BRANCH="gh-pages"
OUT=dist-newstyle/hpc
function doCompile {
./runTestsAndCoverage.sh
}
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
echo "Skipping deploy; just doing a build."
doCompile
exit 0
fi
# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`
# Clone the existing gh-pages for this repo into $OUTt/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone $REPO $OUT
cd $OUT
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
cd ..
# Clean out existing contents
rm -rf $OUT/**/* || exit 0
# Run our compile script
doCompile
# Now let's go have some fun with the cloned repo
cd $OUT
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
if [ -z `git diff --exit-code` ]; then
echo "No changes to the output on this push; exiting."
exit 0
fi
# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add .
git commit -m "Deploy to GitHub Pages: ${SHA}"
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key
# Now that we're all set up, we can push.
git push $SSH_REPO $TARGET_BRANCH

BIN
deploy_key.enc Normal file

Binary file not shown.

@ -1 +1 @@
Subproject commit 785e67aa7c9fac423666501858a1d653895e4953
Subproject commit cab4668353eb01d68c7e1bd9eed252188ad6f06d

2
deps/servant-snap vendored

@ -1 +1 @@
Subproject commit dc103ca596b21e21c455ef615d7ba86bd73a2918
Subproject commit 62255c58007d0c5f2e1748aeaf86dd3d7ccb3ecc

46
runTestsAndCoverage.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
set -e
# All directory variables relative to project root
DIR=dist-newstyle/hpc
SUITE=./dist-newstyle/build/servant-reflex-0.2/build/testsuite/testsuite
if [ -z "$DEBUG" ]; then
export DEBUG=snap-testsuite
fi
rm -f testsuite.tix
rm -rf "$DIR"
mkdir -p "$DIR"
if [ ! -f $SUITE ]; then
cat <<EOF
Testsuite executable not found, please run:
cabal install --enable-tests --only-dependencies
cabal configure --enable-tests
cabal build
EOF
exit;
fi
$SUITE $*
EXCLUDES='Main
Paths_servant-reflex
'
EXCL=""
for m in $EXCLUDES; do
EXCL="$EXCL --exclude=$m"
done
# TODO - actually send results to /dev/null when hpc kinks are fully removed
hpc markup $EXCL --destdir=$DIR testsuite # >/dev/null 2>&1
cat <<EOF
Test coverage report written to $HTMLDIR.
EOF

View File

@ -53,3 +53,12 @@ executable example
main-is: Example.hs
other-modules: API
hs-source-dirs: exec
test-suite testsuite
type: exitcode-stdio-1.0
main-is: Tests.hs
hs-source-dirs: test
ghc-prof-options: -prof -auto
ghc-options: -Wall -fwarn-tabs -O2 -fhpc -threaded
other-modules:
build-depends: base

4
test/Tests.hs Normal file
View File

@ -0,0 +1,4 @@
module Main where
main :: IO ()
main = return ()