Skip to content

Commit

Permalink
ci: add GitHub actions (#70)
Browse files Browse the repository at this point in the history
* fix: vulnerabilities

* ci: added lockfile lint

* ci: added quality checks

* ci: added unit tests

* ci: added integration tests

* ci: added coverage test

* ci: add semantic release and coveralls fix

fix: coveralls fix

* ci: remove circle ci config

* fix: reverted lockfileVersion to 2

* fix: reverted whole package lock file

* ci: add release permissions

* fix: CR fixes

Co-authored-by: ilanKushnir <ilan@zooz.com>
  • Loading branch information
ilanKushnir and ilanKushnir committed Jun 7, 2021
1 parent f60e15c commit b9ab859
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 91 deletions.
89 changes: 0 additions & 89 deletions .circleci/config.yml

This file was deleted.

110 changes: 110 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CI

on: [ push, pull_request ]

jobs:
lockfile-lint:
name: Lockfile lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: lint lock file
run: npx lockfile-lint --path package-lock.json --allowed-hosts npm --validate-https

quality-checks:
needs: [ 'lockfile-lint' ]
name: Quality checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install dependencies
run: npm ci
- name: types check
run: npm run types-check
- name: lint check
run: npm run lint

test:
strategy:
matrix:
platform: [ ubuntu-latest ]
node: [ '10', '12', '14', '16' ]
needs: [ 'quality-checks' ]
name: Node v.${{ matrix.node }} Tests (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ matrix.node }}-node-${{ hashFiles('**/package-lock.json') }}
- name: install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: unit tests
run: npm run unit-tests
- name: integration tests
run: npm run integration-tests
- name: coveralls
uses: coverallsapp/github-action@master
if: ${{ matrix.node == '14' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

prom-client-test:
strategy:
matrix:
node: [ '12', '14' ]
prom-client: [ '12' ]
needs: [ 'lockfile-lint', 'quality-checks' ]
name: Prom Client v.${{ matrix.prom-client }} Tests (node ${{ matrix.node }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: install dependencies
run: npm ci
- name: install prom client
run: npm i prom-client@${{ matrix.prom-client }}
- name: run tests
run: npm test

release:
permissions:
actions: write
checks: write
contents: write
deployments: write
issues: write
packages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
name: release
needs: [ test, prom-client-test, lockfile-lint ]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install dependencies
run: npm ci --ignore-scripts
- name: release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prometheus-api-metrics",
"version": "3.2.0",
"version": "0.0.0",
"description": "API and process monitoring with Prometheus for Node.js micro-service",
"author": "Idan Tovi",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const expect = require('chai').expect;
const supertest = require('supertest');
let app, config;

describe('when using express framework (exclude route)', () => {
describe('when using express framework (exclude route)', function() {
this.timeout(4000);
before(() => {
config = require('./server/config');
config.useUniqueHistogramName = true;
Expand Down

0 comments on commit b9ab859

Please sign in to comment.