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:
+51 -8
View File
@@ -1,22 +1,19 @@
## 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: cache:
timeout: 1000 timeout: 1000
directories: directories:
- $HOME/.stack - $HOME/.stack
- $HOME/.local/bin - $HOME/.local/bin
before_install: before_install:
- mkdir -p "$HOME/.local/bin" - mkdir -p "$HOME/.local/bin"
- export PATH="$PATH:$HOME/.local/bin" - export PATH="$PATH:$HOME/.local/bin"
install: install:
- | - |
if test -f "$HOME/.local/bin/stack" if test -f "$HOME/.local/bin/stack"
@@ -40,7 +37,6 @@ install:
unzip ghr.zip -d "$HOME/.local/bin" unzip ghr.zip -d "$HOME/.local/bin"
rm ghr.zip rm ghr.zip
fi fi
script: script:
## Building the whole project can take longer than 50 minutes. Since Travis has a global timeout of 50 minutes ## 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. ## we compile for 30 minutes tops(`gtimeout 1800`) and quit compiling with no error.
@@ -68,3 +64,50 @@ script:
tar cJf postgrest-$TRAVIS_TAG-osx.tar.xz 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 ghr -t $GITHUB_TOKEN -u $OWNER -r $REPO -b "$BODY"--replace $TRAVIS_TAG postgrest-$TRAVIS_TAG-osx.tar.xz
fi fi
- name: Code Coverage
os: linux
dist: focal
addons:
apt:
update: true
packages:
- postgresql-12
cache:
yarn: true
timeout: 1000
directories:
- $HOME/.local/bin
- $HOME/.stack
- .stack-work
before_install: |
export PATH="$PATH:$HOME/.local/bin:/usr/lib/postgresql/12/bin"
install: |
if [[ ! -f "$HOME/.local/bin/stack" ]]
then
travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
fi
if [[ ! -f "$HOME/.local/bin/shc" ]]
then
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
fi
travis_wait stack --no-terminal setup
travis_wait stack --no-terminal install hpc
script: |
travis_wait 50 stack --no-terminal build --fast -j1 --coverage
travis_wait 50 stack --no-terminal build --fast -j1 --coverage --test --no-run-tests
test/with_tmp_db stack --no-terminal test --coverage
test/with_tmp_db stack --no-terminal exec test/io-tests.sh
after_script: |
export _HPC_DIR=$(stack path --local-hpc-root)
export _MIX_DIR=$(stack path --dist-dir)
export _PKG_NAME=$(stack exec -- ghc-pkg field postgrest key --simple-output)
# merge the results from `stack test` and the io tests and exclude Paths_postgrest
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
# fix a bug in stack-hpc-coveralls
mv $_MIX_DIR/hpc/Main.mix $_MIX_DIR/hpc/$_PKG_NAME/Main.mix
mv $_MIX_DIR/hpc/UnixSocket.mix $_MIX_DIR/hpc/$_PKG_NAME/UnixSocket.mix
sed -i -r "s/(Main|UnixSocket)/$_PKG_NAME\/\1/g" /tmp/all.tix
# upload to coveralls
mv /tmp/all.tix $_HPC_DIR/combined/all/all.tix
shc combined all
+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