Skip to content

Get release-workflow running #117

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

Merged
merged 31 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d3b335f
ci: ignore test.yml workflow on release-* branches PRs #36
jankapunkt Oct 18, 2021
8c080ff
ci: add tests-release.yml workflow to test release-integrity
jankapunkt Oct 18, 2021
c6459b8
ci: add release.yml to release a new version to registries
jankapunkt Oct 18, 2021
f4fc33b
ci(tests): make coverage generate lcov.info file
jankapunkt Oct 26, 2021
02e0a4d
ci(tests): make coverage generate lcov.info file as well as html #36
jankapunkt Oct 26, 2021
ac7bb86
ci(tests): fix spelling in coverage test script #36
jankapunkt Oct 26, 2021
7174693
Merge branch 'development' into ci-release-package
jankapunkt Jan 13, 2022
13aacce
feature(ci): release workflow only runs on non-draft pull requests
jankapunkt Jan 13, 2022
edd8160
fix(ci): use actions v2 for setting up node
jankapunkt Jan 13, 2022
69a3043
fix(ci): use code-ql only on non-draft releases
jankapunkt Jan 13, 2022
36e13eb
fix(ci): fix audit job syntax error
jankapunkt Jan 13, 2022
4188547
fix(ci): fix publish jobs syntax error
jankapunkt Jan 13, 2022
ecb072e
fix(ci): fix publish jobs syntax error
jankapunkt Jan 13, 2022
510546b
fix(ci): fix check coverage
jankapunkt Jan 13, 2022
88a7bfe
fix(ci): run workflows also only on push for non-draft PR
jankapunkt Jan 13, 2022
d6ec7d8
fix(ci): fix tets.yml semantic error
jankapunkt Jan 13, 2022
e556def
fix(ci): release-workflow trigger on push to PR
jankapunkt Jan 13, 2022
465b786
fix(ci): add lcov reporter to test:coverage
jankapunkt Jan 13, 2022
b7867e7
fix(ci): use oauthjs/express-oauth-server for integration testing
jankapunkt Jan 13, 2022
3167a8e
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
c99001c
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
fd9ead8
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
aee6d92
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
916c613
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
a47e867
fix(ci): use node-oauth/express-oauth-server for integration test
jankapunkt Jan 13, 2022
8073105
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
06e6b4c
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
099d063
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
f4bfae8
fix(ci): exclude node 16 to get running
jankapunkt Jan 13, 2022
9c70236
build(ci): add --access-public flag to npm publish
jankapunkt Jan 18, 2022
c97d0e3
ci: disable release workflow until decision is made pro automated rel…
jankapunkt Feb 1, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ name: "CodeQL Semantic Analysis"
on:
push: # all pushes
pull_request: # all PR
types: [review_requested, ready_for_review] # only non-draft PR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Didn't know this..will probably add this to my projects.

schedule:
- cron: '0 2 * * *' # every night at 2am

Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
#
#name: Release
#
#on:
# release:
# types: [created]
#
#jobs:
# build:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# node-version: 12
# - run: npm ci
# - run: npm test
#
# publish-npm:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# # we always publish targeting the lowest supported node version
# node-version: 12
# registry-url: 'https://registry.npmjs.org/'
# - run: npm ci
# - run: npm publish --access public
# env:
# NODE_AUTH_TOKEN: ${{secrets.npm_token}}
#
# publish-gpr:
# needs: build
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# # we always publish targeting the lowest supported node version
# node-version: 12
# registry-url: $registry-url(npm)
# - run: npm ci
# - run: npm publish --access public
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
149 changes: 149 additions & 0 deletions .github/workflows/tests-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Tests for Release

on:
push:
branches:
- release-* # all release-<version> branches
pull_request:
# only non-draft PR and when there are "pushes" to the open PR
types: [review_requested, ready_for_review, synchronize]
branches:
- release-* # all release-<version> branches


jobs:
# STEP 1 - NPM Audit

# Before we even test a thing we want to have a clean audit! Since this is
# sufficient to be done using the lowest node version, we can easily use
# a fixed one:

audit:
name: NPM Audit
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
- run: npm audit --production # no audit for dev dependencies

# STEP 2 - basic unit tests

# This is the standard unit tests as we do in the basic tests for every PR
unittest:
name: Basic unit tests
runs-on: ubuntu-latest
needs: [audit]
strategy:
matrix:
node: [12, 14, 16]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add node 17. We got a regression in mongoose few weeks ago, could have been detected earlier if we would have tested also for node17. Better to also add chec for node17 and later node 18 and 19, while dropping node 12 and 17.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a must have...

steps:
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2

- name: Setup node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}

# for this workflow we also require npm audit to pass
- run: npm ci
- run: npm run test:coverage

# with the following action we enforce PRs to have a high coverage
# and ensure, changes are tested well enough so that coverage won't fail
- name: check coverage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use NYC we can set minimum code coverage and then it already throws an error in the step above.

This is how I do it in a project of mine

https://github.com/cthulhu-node/benchmark.js

uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
with:
path: './coverage/lcov.info'
min_coverage: 95

# STEP 3 - Integration tests

# Since our release may affect several packages that depend on it we need to
# cover the closest ones, like adapters and examples.

integrationtests:
name: Extended integration tests
runs-on: ubuntu-latest
needs: [unittest]
strategy:
matrix:
node: [12, 14] # TODO get running for node 16
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create follow up issue after merge

steps:
# checkout this repo
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2

# checkout express-adapter repo
- name: Checkout express-adapter ${{ matrix.node }}
uses: actions/checkout@v2
with:
repository: node-oauth/express-oauth-server
path: github/testing/express

- name: Setup node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server

# in order to test the adapter we need to use the current checkout
# and install it as local dependency
# we just cloned and install it as local dependency
- run: |
cd github/testing/express
npm ci
npm install ../../../
npm run test

# todo repeat with other adapters

publish-npm-dry:
runs-on: ubuntu-latest
needs: [integrationtests]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-github-dry:
needs: [integrationtests]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
# we always publish targeting the lowest supported node version
node-version: 12
registry-url: $registry-url(npm)
- run: npm ci
- run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
58 changes: 15 additions & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
name: Test suite
name: Tests

# This workflow runs standard unit tests to ensure basic integrity and avoid
# regressions on pull-requests (and pushes)

on:
push:
branches:
- master # allthough master is push protected we still keep it
- master # allthough master is push protected we still keep it
- development
pull_request: # runs on all PR
pull_request: # runs on all PR
branches-ignore:
- release-* # on release we run an extended workflow so no need for this

jobs:
# ----------------------------------
# uncomment when a linter is added
# ----------------------------------

# lintjs:
# name: Javascript lint
# runs-on: ubuntu-latest
# steps:
# - name: checkout
# uses: actions/checkout@v2
#
# - name: setup node
# uses: actions/setup-node@v1
# with:
# node-version: '12.x'
#
# - name: cache dependencies
# uses: actions/cache@v1
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
# - run: npm ci
# - run: npm run lint

unittest:
name: unit tests
runs-on: ubuntu-latest
# uncomment when a linter is added
# needs: [lintjs]
strategy:
matrix:
node: [12, 14, 16]
Expand All @@ -61,15 +38,10 @@ jobs:
- run: npm ci
- run: npm run test:coverage

# ----------------------------------
# uncomment when a linter is added
# ----------------------------------

# - name: check coverage
# uses: devmasx/coverage-check-action@v1.2.0
# with:
# type: lcov
# result_path: coverage/lcov.info
# min_coverage: 90
# token: ${{github.token}}

# with the following action we enforce PRs to have a high coverage
# and ensure, changes are tested well enough so that coverage won't fail
- name: check coverage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above.

uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
with:
path: './coverage/lcov.info'
min_coverage: 95
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'",
"test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'",
"test:watch": "NODE_ENV=test ./node_modules/.bin/mocha --watch 'test/**/*_test.js'",
"test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'",
"test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=lcov --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'",
"lint": "npx eslint .",
"lint:fix": "npx eslint . --fix"
},
Expand Down