- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 54
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
Changes from 29 commits
d3b335f
              8c080ff
              c6459b8
              f4fc33b
              02e0a4d
              ac7bb86
              7174693
              13aacce
              edd8160
              69a3043
              36e13eb
              4188547
              ecb072e
              510546b
              88a7bfe
              d6ec7d8
              e556def
              465b786
              b7867e7
              3167a8e
              c99001c
              fd9ead8
              aee6d92
              916c613
              a47e867
              8073105
              06e6b4c
              099d063
              f4bfae8
              9c70236
              c97d0e3
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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 | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | 
| 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] | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/[email protected] | ||
| 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 | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}} | ||
| 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] | ||
|  | @@ -61,15 +38,10 @@ jobs: | |
| - run: npm ci | ||
| - run: npm run test:coverage | ||
|  | ||
| # ---------------------------------- | ||
| # uncomment when a linter is added | ||
| # ---------------------------------- | ||
|  | ||
| # - name: check coverage | ||
| # uses: devmasx/[email protected] | ||
| # 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 | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same as above. | ||
| uses: VeryGoodOpenSource/[email protected] | ||
| with: | ||
| path: './coverage/lcov.info' | ||
| min_coverage: 95 | ||
There was a problem hiding this comment.
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.