ci: add coveralls.io integration

This commit is contained in:
Wolfgang Walther
2020-10-22 12:05:25 -05:00
committed by Steve Chavez
parent d1d0c6772a
commit eed0d3a66c
5 changed files with 114 additions and 74 deletions
+1 -2
View File
@@ -47,8 +47,7 @@ jobs:
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.3.1/stack-2.3.1-linux-x86_64.tar.gz | tar zx -C /tmp curl -L https://github.com/commercialhaskell/stack/releases/download/v2.3.1/stack-2.3.1-linux-x86_64.tar.gz | tar zx -C /tmp
sudo mv /tmp/stack-2.3.1-linux-x86_64/stack /usr/bin sudo mv /tmp/stack-2.3.1-linux-x86_64/stack /usr/bin
sudo apt-get update sudo apt-get update
# ncat utility from nmap needed to test socket connection with curl < 7.40 sudo apt-get install -y libgmp-dev postgresql-client
sudo apt-get install -y libgmp-dev postgresql-client nmap
sudo apt-get install -y --only-upgrade binutils sudo apt-get install -y --only-upgrade binutils
stack setup stack setup
- run: - run:
+108 -65
View File
@@ -1,70 +1,113 @@
## Travis is only used for building an OSX binary ,
## no tests are run here.
language: generic language: generic
sudo: false sudo: false
os: jobs:
- osx include:
- name: Build OSX Binary
os: osx
cache:
timeout: 1000
directories:
- $HOME/.stack
- $HOME/.local/bin
before_install:
- mkdir -p "$HOME/.local/bin"
- export PATH="$PATH:$HOME/.local/bin"
install:
- |
if test -f "$HOME/.local/bin/stack"
then
echo 'Stack is already installed.'
else
echo "Installing Stack..."
travis_retry curl -L https://www.stackage.org/stack/osx-x86_64 > stack.tar.gz
gunzip stack.tar.gz
tar -x -f stack.tar --strip-components 1
mv stack "$HOME/.local/bin/"
rm stack.tar
fi
- |
if test -f "$HOME/.local/bin/ghr"
then
echo 'ghr is already installed.'
else
echo "Installing ghr..."
travis_retry curl -L https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_darwin_386.zip > ghr.zip
unzip ghr.zip -d "$HOME/.local/bin"
rm ghr.zip
fi
script:
## Building the whole project can take longer than 50 minutes. Since Travis has a global timeout of 50 minutes
## we compile for 30 minutes tops(`gtimeout 1800`) and quit compiling with no error.
## Since we CACHE the compile results we can continue compiling from where we left off
## on the next commit.
- gtimeout 1800 stack build --no-terminal --only-snapshot --install-ghc || (($?==124))
- |
if test ! "$TRAVIS_TAG"
then
echo 'No tag pushed. Skip building binary.'
else
stack build --no-terminal --copy-bins --local-bin-path .
fi
- |
if test ! "$TRAVIS_TAG"
then
echo 'No tag pushed. Skipping release.'
else
OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
START=$(echo $TRAVIS_TAG | cut -c2-)
END='## \['
BODY=$(sed -n "1,/$START/d;/$END/q;p" CHANGELOG.md)
strip postgrest
tar cJf postgrest-$TRAVIS_TAG-osx.tar.xz postgrest
ghr -t $GITHUB_TOKEN -u $OWNER -r $REPO -b "$BODY"--replace $TRAVIS_TAG postgrest-$TRAVIS_TAG-osx.tar.xz
fi
cache: - name: Code Coverage
timeout: 1000 os: linux
directories: dist: focal
- $HOME/.stack addons:
- $HOME/.local/bin apt:
update: true
before_install: packages:
- mkdir -p "$HOME/.local/bin" - postgresql-12
- export PATH="$PATH:$HOME/.local/bin" cache:
yarn: true
install: timeout: 1000
- | directories:
if test -f "$HOME/.local/bin/stack" - $HOME/.local/bin
then - $HOME/.stack
echo 'Stack is already installed.' - .stack-work
else before_install: |
echo "Installing Stack..." export PATH="$PATH:$HOME/.local/bin:/usr/lib/postgresql/12/bin"
travis_retry curl -L https://www.stackage.org/stack/osx-x86_64 > stack.tar.gz install: |
gunzip stack.tar.gz if [[ ! -f "$HOME/.local/bin/stack" ]]
tar -x -f stack.tar --strip-components 1 then
mv stack "$HOME/.local/bin/" travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
rm stack.tar fi
fi if [[ ! -f "$HOME/.local/bin/shc" ]]
- | then
if test -f "$HOME/.local/bin/ghr" travis_retry curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.4.0/shc-linux-x64-8.0.1.tar.bz2 | tar -xj -C ~/.local/bin
then fi
echo 'ghr is already installed.' travis_wait stack --no-terminal setup
else travis_wait stack --no-terminal install hpc
echo "Installing ghr..." script: |
travis_retry curl -L https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_darwin_386.zip > ghr.zip travis_wait 50 stack --no-terminal build --fast -j1 --coverage
unzip ghr.zip -d "$HOME/.local/bin" travis_wait 50 stack --no-terminal build --fast -j1 --coverage --test --no-run-tests
rm ghr.zip test/with_tmp_db stack --no-terminal test --coverage
fi test/with_tmp_db stack --no-terminal exec test/io-tests.sh
after_script: |
script: export _HPC_DIR=$(stack path --local-hpc-root)
## Building the whole project can take longer than 50 minutes. Since Travis has a global timeout of 50 minutes export _MIX_DIR=$(stack path --dist-dir)
## we compile for 30 minutes tops(`gtimeout 1800`) and quit compiling with no error. export _PKG_NAME=$(stack exec -- ghc-pkg field postgrest key --simple-output)
## Since we CACHE the compile results we can continue compiling from where we left off # merge the results from `stack test` and the io tests and exclude Paths_postgrest
## on the next commit. stack --no-terminal exec hpc -- sum --union --exclude=Paths_postgrest --output=/tmp/all.tix $_HPC_DIR/combined/all/all.tix test/io-tests/postgrest.tix
- gtimeout 1800 stack build --no-terminal --only-snapshot --install-ghc || (($?==124)) # fix a bug in stack-hpc-coveralls
- | mv $_MIX_DIR/hpc/Main.mix $_MIX_DIR/hpc/$_PKG_NAME/Main.mix
if test ! "$TRAVIS_TAG" mv $_MIX_DIR/hpc/UnixSocket.mix $_MIX_DIR/hpc/$_PKG_NAME/UnixSocket.mix
then sed -i -r "s/(Main|UnixSocket)/$_PKG_NAME\/\1/g" /tmp/all.tix
echo 'No tag pushed. Skip building binary.' # upload to coveralls
else mv /tmp/all.tix $_HPC_DIR/combined/all/all.tix
stack build --no-terminal --copy-bins --local-bin-path . shc combined all
fi
- |
if test ! "$TRAVIS_TAG"
then
echo 'No tag pushed. Skipping release.'
else
OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
START=$(echo $TRAVIS_TAG | cut -c2-)
END='## \['
BODY=$(sed -n "1,/$START/d;/$END/q;p" CHANGELOG.md)
strip postgrest
tar cJf postgrest-$TRAVIS_TAG-osx.tar.xz postgrest
ghr -t $GITHUB_TOKEN -u $OWNER -r $REPO -b "$BODY"--replace $TRAVIS_TAG postgrest-$TRAVIS_TAG-osx.tar.xz
fi
+1
View File
@@ -9,6 +9,7 @@
[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://postgrest.org) [![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://postgrest.org)
[![Docker Stars](https://img.shields.io/docker/pulls/postgrest/postgrest.svg)](https://hub.docker.com/r/postgrest/postgrest/) [![Docker Stars](https://img.shields.io/docker/pulls/postgrest/postgrest.svg)](https://hub.docker.com/r/postgrest/postgrest/)
[![Build Status](https://circleci.com/gh/PostgREST/postgrest/tree/master.svg?style=shield)](https://circleci.com/gh/PostgREST/postgrest/tree/master) [![Build Status](https://circleci.com/gh/PostgREST/postgrest/tree/master.svg?style=shield)](https://circleci.com/gh/PostgREST/postgrest/tree/master)
[![Coverage Status](https://img.shields.io/coveralls/github/PostgREST/postgrest)](https://coveralls.io/github/PostgREST/postgrest)
[![Hackage docs](https://img.shields.io/hackage/v/postgrest.svg?label=hackage)](http://hackage.haskell.org/package/postgrest) [![Hackage docs](https://img.shields.io/hackage/v/postgrest.svg?label=hackage)](http://hackage.haskell.org/package/postgrest)
PostgREST serves a fully RESTful API from any existing PostgreSQL PostgREST serves a fully RESTful API from any existing PostgreSQL
+2 -2
View File
@@ -97,7 +97,7 @@ postgrest-test-spec-all postgrest-test-spec-postgresql-9.6
``` ```
Note that `postgrest-tests-io` is now also available. Note that `postgrest-test-io` is now also available.
To run one-off commands, you can also use `nix-shell --run <command>`, which To run one-off commands, you can also use `nix-shell --run <command>`, which
will lauch the Nix shell, run that one command and exit. Note that the tab will lauch the Nix shell, run that one command and exit. Note that the tab
@@ -168,7 +168,7 @@ give you some more background and details on how it works.
### `default.nix` ### `default.nix`
[`default.nix`](../default.nix) is our 'respository expression' that pulls all [`default.nix`](../default.nix) is our 'repository expression' that pulls all
the pieces that we define with Nix together. It returns a set (like a dict in the pieces that we define with Nix together. It returns a set (like a dict in
other programming languages), where each attribute is a derivation that Nix other programming languages), where each attribute is a derivation that Nix
knows how to build, like the `postgrest` attribute from earlier. knows how to build, like the `postgrest` attribute from earlier.
+2 -5
View File
@@ -43,7 +43,7 @@ pgrStart(){ postgrest $1 >/dev/null 2>/dev/null & pgrPID="$!"; }
pgrStartRead(){ postgrest $1 <$2 >/dev/null & pgrPID="$!"; } pgrStartRead(){ postgrest $1 <$2 >/dev/null & pgrPID="$!"; }
pgrStartStdin(){ postgrest $1 >/dev/null <<< "$2" & pgrPID="$!"; } pgrStartStdin(){ postgrest $1 >/dev/null <<< "$2" & pgrPID="$!"; }
pgrStarted(){ kill -0 "$pgrPID" 2>/dev/null; } pgrStarted(){ kill -0 "$pgrPID" 2>/dev/null; }
pgrStop(){ kill "$pgrPID" 2>/dev/null; pgrPID=""; } pgrStop(){ kill "$pgrPID" 2>/dev/null; pgrPID=""; sleep 0.1; }
# Utilities to send HTTP requests to the PostgREST server # Utilities to send HTTP requests to the PostgREST server
rootStatus(){ rootStatus(){
@@ -273,13 +273,10 @@ replaceConfigValue(){
} }
getSocketStatus() { getSocketStatus() {
curl -sL -w "%{http_code}\\n" -o /dev/null localhost:54321 curl -sL -w "%{http_code}\\n" -o /dev/null --unix-socket /tmp/postgrest.sock http://localhost/
} }
socketConnection(){ socketConnection(){
# map port 54321 traffic to unix socket as workaround for curl below 7.40
# not supporting --unix-socket flag
ncat -vlk 54321 -c 'ncat -U /tmp/postgrest.sock' &
pgrStart "./configs/unix-socket.config" pgrStart "./configs/unix-socket.config"
while pgrStarted && test "$( getSocketStatus )" -ne 200 while pgrStarted && test "$( getSocketStatus )" -ne 200
do do