Skip to content

Commit 2953840

Browse files
authored
ci: add parallel coverage collection (#79)
* ci(scripts): lint with shellcheck Resolves issues https://github.com/koalaman/shellcheck/wiki/SC2086 and https://github.com/koalaman/shellcheck/wiki/SC2164 * ci(dependabot): auto update github actions * style(ci): change extension from `.yaml` to `.yml` * ci: ignore documentation updates * ci: add parallel coverage collection * style(ci): bring into line with skeleton and main fastify repo * chore(package): sort scripts alphabetically ascending
1 parent cd6a0ad commit 2953840

File tree

7 files changed

+66
-27
lines changed

7 files changed

+66
-27
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
version: 2
22
updates:
3+
- package-ecosystem: github-actions
4+
directory: '/'
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
39
- package-ecosystem: npm
410
directory: '/'
511
schedule:

.github/workflows/ci.yaml renamed to .github/workflows/ci.yml

+45-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
name: CI workflow
1+
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '*.md'
8+
pull_request:
9+
paths-ignore:
10+
- 'docs/**'
11+
- '*.md'
412

513
jobs:
6-
build:
14+
test:
715
runs-on: ubuntu-latest
816
strategy:
917
matrix:
10-
node: [10, 12, 14]
11-
12-
name: Node.js ${{ matrix.node }}
13-
18+
node-version: [10.x, 12.x, 14.x]
19+
1420
services:
1521
postgres:
1622
image: postgres:11-alpine
@@ -25,25 +31,51 @@ jobs:
2531
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
2632

2733
steps:
28-
- uses: actions/checkout@v1
34+
- uses: actions/checkout@v2
35+
36+
- name: Use Node.js
37+
uses: actions/[email protected]
2938
with:
3039
node-version: ${{ matrix.node-version }}
3140

41+
- name: Install Dependencies
42+
run: |
43+
npm install
44+
3245
- name: CI environment setup
3346
run: |
3447
npm i node-gyp
3548
sudo apt-get install -yqq libpq-dev postgresql-client
3649
chmod 600 .pgpass
3750
PGPASSFILE=.pgpass psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres
3851
39-
- name: Install
40-
run: npm install
52+
- name: Check licenses
53+
run: |
54+
npm run license-checker --if-present
55+
56+
- name: Run tests
57+
run: |
58+
npm run test:ci
59+
60+
- name: Coveralls Parallel
61+
uses: coverallsapp/[email protected]
62+
with:
63+
github-token: ${{ secrets.github_token }}
64+
parallel: true
65+
flag-name: run-${{ matrix.node-version }}-${{ matrix.os }}
4166

42-
- name: Run tests
43-
run: npm run test
67+
coverage:
68+
needs: test
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Coveralls Finished
72+
uses: coverallsapp/[email protected]
73+
with:
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
parallel-finished: true
4476

4577
automerge:
46-
needs: build
78+
needs: test
4779
runs-on: ubuntu-latest
4880
steps:
4981
- uses: fastify/github-action-merge-dependabot@v1

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# fastify-postgres
22

3-
![CI](https://github.com/fastify/fastify-postgres/workflows/CI%20workflow/badge.svg)
3+
![CI](https://github.com/fastify/fastify-postgres/workflows/CI/badge.svg)
44
[![NPM version](https://img.shields.io/npm/v/fastify-postgres.svg?style=flat)](https://www.npmjs.com/package/fastify-postgres)
55
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-postgres/badge.svg)](https://snyk.io/test/github/fastify/fastify-postgres)
66
[![Coverage Status](https://coveralls.io/repos/github/fastify/fastify-postgres/badge.svg?branch=master)](https://coveralls.io/github/fastify/fastify-postgres?branch=master)

ci_scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sudo updatedb
66
source ./ci_scripts/install_libpq.sh
77
sudo updatedb
88
sudo ldconfig
9-
cd $BUILD_DIR
9+
cd "$BUILD_DIR" || exit

ci_scripts/install_libpq.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ cd "${TMP_DIR}/postgresql-${POSTGRES_VERSION}"
2222
if [ -d "${POSTGRES_DIR}" ]; then
2323
rm -rf "${POSTGRES_DIR}"
2424
fi
25-
mkdir -p $POSTGRES_DIR
25+
mkdir -p "$POSTGRES_DIR"
2626

27-
./configure --prefix=$POSTGRES_DIR --with-openssl --with-includes=${OPENSSL_DIR}/include --with-libraries=${OPENSSL_DIR}/lib --without-readline
27+
./configure --prefix="$POSTGRES_DIR" --with-openssl --with-includes="${OPENSSL_DIR}"/include --with-libraries="${OPENSSL_DIR}"/lib --without-readline
2828

2929
cd src/interfaces/libpq; make; make install; cd -
3030
cd src/bin/pg_config; make install; cd -

ci_scripts/install_openssl.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ if [ -d "${TMP_DIR}" ]; then
1414
rm -rf "${TMP_DIR}"
1515
fi
1616
mkdir -p "${TMP_DIR}"
17-
curl -s https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | \
17+
curl -s https://www.openssl.org/source/openssl-"${OPENSSL_VERSION}".tar.gz | \
1818
tar -C "${TMP_DIR}" -xzf -
19-
pushd "${TMP_DIR}/openssl-${OPENSSL_VERSION}"
19+
pushd "${TMP_DIR}/openssl-${OPENSSL_VERSION}" || exit
2020
if [ -d "${OPENSSL_DIR}" ]; then
2121
rm -rf "${OPENSSL_DIR}"
2222
fi
2323
./Configure \
24-
--prefix=${OPENSSL_DIR} \
24+
--prefix="${OPENSSL_DIR}" \
2525
enable-crypto-mdebug enable-crypto-mdebug-backtrace \
2626
linux-x86_64
27-
make -s $JOBS
27+
make -s "$JOBS"
2828
make install_sw
29-
popd
29+
popd || exit
3030

3131
export PATH="${OPENSSL_DIR}/bin:${PATH}"
3232
export CFLAGS="-I${OPENSSL_DIR}/include"

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
"main": "index.js",
66
"types": "index.d.ts",
77
"scripts": {
8-
"test": "standard && tap -J test/*.test.js && npm run test:typescript",
9-
"test:typescript": "tsd",
10-
"test:report": "standard && tap -J --coverage-report=html test/*.test.js",
11-
"test:verbose": "standard && tap -J test/*.test.js -Rspec",
128
"check-examples": "tsc --build examples/typescript/*",
9+
"load-data": "docker exec -it fastify-postgres psql -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres -d postgres",
1310
"postgres": "docker run -p 5432:5432 --name fastify-postgres -e POSTGRES_PASSWORD=postgres -d postgres:11-alpine",
14-
"load-data": "docker exec -it fastify-postgres psql -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres -d postgres"
11+
"test": "standard && tap -J test/*.test.js && npm run test:typescript",
12+
"test:ci": "standard && tap -J test/*.test.js --coverage-report=lcovonly && npm run test:typescript",
13+
"test:report": "standard && tap -J --coverage-report=html test/*.test.js",
14+
"test:typescript": "tsd",
15+
"test:verbose": "standard && tap -J test/*.test.js -Rspec"
1516
},
1617
"repository": {
1718
"type": "git",

0 commit comments

Comments
 (0)