diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6cab366..afd6f78 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yml similarity index 54% rename from .github/workflows/ci.yaml rename to .github/workflows/ci.yml index dd08975..eae02ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yml @@ -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 @@ -25,10 +31,17 @@ 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 @@ -36,14 +49,33 @@ jobs: 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 diff --git a/README.md b/README.md index e0927db..8b10602 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/ci_scripts/build.sh b/ci_scripts/build.sh index 707bf4d..ee7b53e 100644 --- a/ci_scripts/build.sh +++ b/ci_scripts/build.sh @@ -6,4 +6,4 @@ sudo updatedb source ./ci_scripts/install_libpq.sh sudo updatedb sudo ldconfig -cd $BUILD_DIR +cd "$BUILD_DIR" || exit diff --git a/ci_scripts/install_libpq.sh b/ci_scripts/install_libpq.sh index 936c7d6..ca4949e 100644 --- a/ci_scripts/install_libpq.sh +++ b/ci_scripts/install_libpq.sh @@ -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 - diff --git a/ci_scripts/install_openssl.sh b/ci_scripts/install_openssl.sh index 24c0d3a..4bbfc43 100644 --- a/ci_scripts/install_openssl.sh +++ b/ci_scripts/install_openssl.sh @@ -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" diff --git a/package.json b/package.json index b81440e..c3cef9f 100644 --- a/package.json +++ b/package.json @@ -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",