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