Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add parallel coverage collection #79

Merged
merged 7 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: npm
directory: '/'
schedule:
Expand Down
58 changes: 45 additions & 13 deletions .github/workflows/ci.yaml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
name: CI workflow
name: CI

on: [push, pull_request]
on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]

name: Node.js ${{ matrix.node }}

node-version: [10.x, 12.x, 14.x]

services:
postgres:
image: postgres:11-alpine
Expand All @@ -25,25 +31,51 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2.1.4
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: |
npm install

- name: CI environment setup
run: |
npm i node-gyp
sudo apt-get install -yqq libpq-dev postgresql-client
chmod 600 .pgpass
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

- name: Install
run: npm install
- name: Check licenses
run: |
npm run license-checker --if-present

- name: Run tests
run: |
npm run test:ci

- name: Coveralls Parallel
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.github_token }}
parallel: true
flag-name: run-${{ matrix.node-version }}-${{ matrix.os }}

- name: Run tests
run: npm run test
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

automerge:
needs: build
needs: test
runs-on: ubuntu-latest
steps:
- uses: fastify/github-action-merge-dependabot@v1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fastify-postgres

![CI](https://github.com/fastify/fastify-postgres/workflows/CI%20workflow/badge.svg)
![CI](https://github.com/fastify/fastify-postgres/workflows/CI/badge.svg)
[![NPM version](https://img.shields.io/npm/v/fastify-postgres.svg?style=flat)](https://www.npmjs.com/package/fastify-postgres)
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-postgres/badge.svg)](https://snyk.io/test/github/fastify/fastify-postgres)
[![Coverage Status](https://coveralls.io/repos/github/fastify/fastify-postgres/badge.svg?branch=master)](https://coveralls.io/github/fastify/fastify-postgres?branch=master)
Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sudo updatedb
source ./ci_scripts/install_libpq.sh
sudo updatedb
sudo ldconfig
cd $BUILD_DIR
cd "$BUILD_DIR" || exit
4 changes: 2 additions & 2 deletions ci_scripts/install_libpq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ cd "${TMP_DIR}/postgresql-${POSTGRES_VERSION}"
if [ -d "${POSTGRES_DIR}" ]; then
rm -rf "${POSTGRES_DIR}"
fi
mkdir -p $POSTGRES_DIR
mkdir -p "$POSTGRES_DIR"

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

cd src/interfaces/libpq; make; make install; cd -
cd src/bin/pg_config; make install; cd -
Expand Down
10 changes: 5 additions & 5 deletions ci_scripts/install_openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ if [ -d "${TMP_DIR}" ]; then
rm -rf "${TMP_DIR}"
fi
mkdir -p "${TMP_DIR}"
curl -s https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | \
curl -s https://www.openssl.org/source/openssl-"${OPENSSL_VERSION}".tar.gz | \
tar -C "${TMP_DIR}" -xzf -
pushd "${TMP_DIR}/openssl-${OPENSSL_VERSION}"
pushd "${TMP_DIR}/openssl-${OPENSSL_VERSION}" || exit
if [ -d "${OPENSSL_DIR}" ]; then
rm -rf "${OPENSSL_DIR}"
fi
./Configure \
--prefix=${OPENSSL_DIR} \
--prefix="${OPENSSL_DIR}" \
enable-crypto-mdebug enable-crypto-mdebug-backtrace \
linux-x86_64
make -s $JOBS
make -s "$JOBS"
make install_sw
popd
popd || exit

export PATH="${OPENSSL_DIR}/bin:${PATH}"
export CFLAGS="-I${OPENSSL_DIR}/include"
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "standard && tap -J test/*.test.js && npm run test:typescript",
"test:typescript": "tsd",
"test:report": "standard && tap -J --coverage-report=html test/*.test.js",
"test:verbose": "standard && tap -J test/*.test.js -Rspec",
"check-examples": "tsc --build examples/typescript/*",
"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",
"postgres": "docker run -p 5432:5432 --name fastify-postgres -e POSTGRES_PASSWORD=postgres -d postgres:11-alpine",
"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"
"test": "standard && tap -J test/*.test.js && npm run test:typescript",
"test:ci": "standard && tap -J test/*.test.js --coverage-report=lcovonly && npm run test:typescript",
"test:report": "standard && tap -J --coverage-report=html test/*.test.js",
"test:typescript": "tsd",
"test:verbose": "standard && tap -J test/*.test.js -Rspec"
},
"repository": {
"type": "git",
Expand Down