Skip to content

Commit f4caeb6

Browse files
authored
feature(ci): release workflow added #117
2 parents 72538a3 + c97d0e3 commit f4caeb6

File tree

5 files changed

+218
-44
lines changed

5 files changed

+218
-44
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ name: "CodeQL Semantic Analysis"
1414
on:
1515
push: # all pushes
1616
pull_request: # all PR
17+
types: [review_requested, ready_for_review] # only non-draft PR
1718
schedule:
1819
- cron: '0 2 * * *' # every night at 2am
1920

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
#
4+
#name: Release
5+
#
6+
#on:
7+
# release:
8+
# types: [created]
9+
#
10+
#jobs:
11+
# build:
12+
# runs-on: ubuntu-latest
13+
# steps:
14+
# - uses: actions/checkout@v2
15+
# - uses: actions/setup-node@v2
16+
# with:
17+
# node-version: 12
18+
# - run: npm ci
19+
# - run: npm test
20+
#
21+
# publish-npm:
22+
# needs: build
23+
# runs-on: ubuntu-latest
24+
# steps:
25+
# - uses: actions/checkout@v2
26+
# - uses: actions/setup-node@v2
27+
# with:
28+
# # we always publish targeting the lowest supported node version
29+
# node-version: 12
30+
# registry-url: 'https://registry.npmjs.org/'
31+
# - run: npm ci
32+
# - run: npm publish --access public
33+
# env:
34+
# NODE_AUTH_TOKEN: ${{secrets.npm_token}}
35+
#
36+
# publish-gpr:
37+
# needs: build
38+
# runs-on: ubuntu-latest
39+
# permissions:
40+
# contents: read
41+
# packages: write
42+
# steps:
43+
# - uses: actions/checkout@v2
44+
# - uses: actions/setup-node@v2
45+
# with:
46+
# # we always publish targeting the lowest supported node version
47+
# node-version: 12
48+
# registry-url: $registry-url(npm)
49+
# - run: npm ci
50+
# - run: npm publish --access public
51+
# env:
52+
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/tests-release.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Tests for Release
2+
3+
on:
4+
push:
5+
branches:
6+
- release-* # all release-<version> branches
7+
pull_request:
8+
# only non-draft PR and when there are "pushes" to the open PR
9+
types: [review_requested, ready_for_review, synchronize]
10+
branches:
11+
- release-* # all release-<version> branches
12+
13+
14+
jobs:
15+
# STEP 1 - NPM Audit
16+
17+
# Before we even test a thing we want to have a clean audit! Since this is
18+
# sufficient to be done using the lowest node version, we can easily use
19+
# a fixed one:
20+
21+
audit:
22+
name: NPM Audit
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-node@v2
28+
with:
29+
node-version: '12'
30+
- run: npm audit --production # no audit for dev dependencies
31+
32+
# STEP 2 - basic unit tests
33+
34+
# This is the standard unit tests as we do in the basic tests for every PR
35+
unittest:
36+
name: Basic unit tests
37+
runs-on: ubuntu-latest
38+
needs: [audit]
39+
strategy:
40+
matrix:
41+
node: [12, 14, 16]
42+
steps:
43+
- name: Checkout ${{ matrix.node }}
44+
uses: actions/checkout@v2
45+
46+
- name: Setup node ${{ matrix.node }}
47+
uses: actions/setup-node@v2
48+
with:
49+
node-version: ${{ matrix.node }}
50+
51+
- name: Cache dependencies ${{ matrix.node }}
52+
uses: actions/cache@v1
53+
with:
54+
path: ~/.npm
55+
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
56+
restore-keys: |
57+
${{ runner.os }}-node-${{ matrix.node }}
58+
59+
# for this workflow we also require npm audit to pass
60+
- run: npm ci
61+
- run: npm run test:coverage
62+
63+
# with the following action we enforce PRs to have a high coverage
64+
# and ensure, changes are tested well enough so that coverage won't fail
65+
- name: check coverage
66+
uses: VeryGoodOpenSource/[email protected]
67+
with:
68+
path: './coverage/lcov.info'
69+
min_coverage: 95
70+
71+
# STEP 3 - Integration tests
72+
73+
# Since our release may affect several packages that depend on it we need to
74+
# cover the closest ones, like adapters and examples.
75+
76+
integrationtests:
77+
name: Extended integration tests
78+
runs-on: ubuntu-latest
79+
needs: [unittest]
80+
strategy:
81+
matrix:
82+
node: [12, 14] # TODO get running for node 16
83+
steps:
84+
# checkout this repo
85+
- name: Checkout ${{ matrix.node }}
86+
uses: actions/checkout@v2
87+
88+
# checkout express-adapter repo
89+
- name: Checkout express-adapter ${{ matrix.node }}
90+
uses: actions/checkout@v2
91+
with:
92+
repository: node-oauth/express-oauth-server
93+
path: github/testing/express
94+
95+
- name: Setup node ${{ matrix.node }}
96+
uses: actions/setup-node@v2
97+
with:
98+
node-version: ${{ matrix.node }}
99+
100+
- name: Cache dependencies ${{ matrix.node }}
101+
uses: actions/cache@v1
102+
with:
103+
path: ~/.npm
104+
key: ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }}
105+
restore-keys: |
106+
${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server
107+
108+
# in order to test the adapter we need to use the current checkout
109+
# and install it as local dependency
110+
# we just cloned and install it as local dependency
111+
- run: |
112+
cd github/testing/express
113+
npm ci
114+
npm install ../../../
115+
npm run test
116+
117+
# todo repeat with other adapters
118+
119+
publish-npm-dry:
120+
runs-on: ubuntu-latest
121+
needs: [integrationtests]
122+
steps:
123+
- uses: actions/checkout@v2
124+
- uses: actions/setup-node@v2
125+
with:
126+
node-version: 12
127+
registry-url: https://registry.npmjs.org/
128+
- run: npm ci
129+
- run: npm publish --dry-run
130+
env:
131+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
132+
133+
publish-github-dry:
134+
needs: [integrationtests]
135+
runs-on: ubuntu-latest
136+
permissions:
137+
contents: read
138+
packages: write
139+
steps:
140+
- uses: actions/checkout@v2
141+
- uses: actions/setup-node@v2
142+
with:
143+
# we always publish targeting the lowest supported node version
144+
node-version: 12
145+
registry-url: $registry-url(npm)
146+
- run: npm ci
147+
- run: npm publish --dry-run
148+
env:
149+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/tests.yml

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,21 @@
1-
name: Test suite
1+
name: Tests
2+
3+
# This workflow runs standard unit tests to ensure basic integrity and avoid
4+
# regressions on pull-requests (and pushes)
25

36
on:
47
push:
58
branches:
6-
- master # allthough master is push protected we still keep it
9+
- master # allthough master is push protected we still keep it
710
- development
8-
pull_request: # runs on all PR
11+
pull_request: # runs on all PR
12+
branches-ignore:
13+
- release-* # on release we run an extended workflow so no need for this
914

1015
jobs:
11-
# ----------------------------------
12-
# uncomment when a linter is added
13-
# ----------------------------------
14-
15-
# lintjs:
16-
# name: Javascript lint
17-
# runs-on: ubuntu-latest
18-
# steps:
19-
# - name: checkout
20-
# uses: actions/checkout@v2
21-
#
22-
# - name: setup node
23-
# uses: actions/setup-node@v1
24-
# with:
25-
# node-version: '12.x'
26-
#
27-
# - name: cache dependencies
28-
# uses: actions/cache@v1
29-
# with:
30-
# path: ~/.npm
31-
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
32-
# restore-keys: |
33-
# ${{ runner.os }}-node-
34-
# - run: npm ci
35-
# - run: npm run lint
36-
3716
unittest:
3817
name: unit tests
3918
runs-on: ubuntu-latest
40-
# uncomment when a linter is added
41-
# needs: [lintjs]
4219
strategy:
4320
matrix:
4421
node: [12, 14, 16]
@@ -61,15 +38,10 @@ jobs:
6138
- run: npm ci
6239
- run: npm run test:coverage
6340

64-
# ----------------------------------
65-
# uncomment when a linter is added
66-
# ----------------------------------
67-
68-
# - name: check coverage
69-
# uses: devmasx/[email protected]
70-
# with:
71-
# type: lcov
72-
# result_path: coverage/lcov.info
73-
# min_coverage: 90
74-
# token: ${{github.token}}
75-
41+
# with the following action we enforce PRs to have a high coverage
42+
# and ensure, changes are tested well enough so that coverage won't fail
43+
- name: check coverage
44+
uses: VeryGoodOpenSource/[email protected]
45+
with:
46+
path: './coverage/lcov.info'
47+
min_coverage: 95

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'",
4747
"test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'",
4848
"test:watch": "NODE_ENV=test ./node_modules/.bin/mocha --watch 'test/**/*_test.js'",
49-
"test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'",
49+
"test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=lcov --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'",
5050
"lint": "npx eslint .",
5151
"lint:fix": "npx eslint . --fix"
5252
},

0 commit comments

Comments
 (0)