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
+ # install to create local package-lock.json but don't cache the files
31
+ # also: no audit for dev dependencies
32
+ - run : npm i --package-lock-only && npm audit --production
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@v2
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 i
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
+ uses :
VeryGoodOpenSource/[email protected]
69
+ with :
70
+ path : ' ./coverage/lcov.info'
71
+ min_coverage : 95
72
+
73
+ # STEP 3 - Integration tests
74
+
75
+ # Since our release may affect several packages that depend on it we need to
76
+ # cover the closest ones, like adapters and examples.
77
+
78
+ integrationtests :
79
+ name : Extended integration tests
80
+ runs-on : ubuntu-latest
81
+ needs : [unittest]
82
+ strategy :
83
+ matrix :
84
+ node : [12, 14] # TODO get running for node 16
85
+ steps :
86
+ # checkout this repo
87
+ - name : Checkout ${{ matrix.node }}
88
+ uses : actions/checkout@v2
89
+
90
+ # checkout express-adapter repo
91
+ - name : Checkout express-adapter ${{ matrix.node }}
92
+ uses : actions/checkout@v2
93
+ with :
94
+ repository : node-oauth/express-oauth-server
95
+ path : github/testing/express
96
+
97
+ - name : Setup node ${{ matrix.node }}
98
+ uses : actions/setup-node@v2
99
+ with :
100
+ node-version : ${{ matrix.node }}
101
+
102
+ - name : Cache dependencies ${{ matrix.node }}
103
+ uses : actions/cache@v1
104
+ with :
105
+ path : ~/.npm
106
+ key : ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }}
107
+ restore-keys : |
108
+ ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server
109
+
110
+ # in order to test the adapter we need to use the current checkout
111
+ # and install it as local dependency
112
+ # we just cloned and install it as local dependency
113
+ - run : |
114
+ cd github/testing/express
115
+ npm i
116
+ npm install ../../../
117
+ npm run test
118
+
119
+ # todo repeat with other adapters
120
+
121
+ publish-npm-dry :
122
+ runs-on : ubuntu-latest
123
+ needs : [integrationtests]
124
+ steps :
125
+ - uses : actions/checkout@v2
126
+ - uses : actions/setup-node@v2
127
+ with :
128
+ node-version : 12
129
+ registry-url : https://registry.npmjs.org/
130
+ - run : npm i
131
+ - run : npm publish --dry-run
132
+ env :
133
+ NODE_AUTH_TOKEN : ${{secrets.npm_token}}
134
+
135
+ publish-github-dry :
136
+ needs : [integrationtests]
137
+ runs-on : ubuntu-latest
138
+ permissions :
139
+ contents : read
140
+ packages : write
141
+ steps :
142
+ - uses : actions/checkout@v2
143
+ - uses : actions/setup-node@v2
144
+ with :
145
+ # we always publish targeting the lowest supported node version
146
+ node-version : 12
147
+ registry-url : $registry-url(npm)
148
+ - run : npm i
149
+ - run : npm publish --dry-run
150
+ env :
151
+ NODE_AUTH_TOKEN : ${{secrets.GITHUB_TOKEN}}
0 commit comments