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/very_good_coverage@v1.2.0
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}}
0 commit comments