-
Notifications
You must be signed in to change notification settings - Fork 5.7k
211 lines (181 loc) · 6.7 KB
/
integrate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# main only
name: Integrate
on:
push:
branches: [main]
env:
SLS_IGNORE_WARNING: '*'
FORCE_COLOR: 1
SLS_SCHEMA_CACHE_BASE_DIR: '/home/runner'
jobs:
linuxNode16:
name: '[Linux] Node.js 16: Publish canary, Unit & packaging tests '
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node.js and npm
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org
- name: Publish canary
# Note: Setting NODE_AUTH_TOKEN as job|workspace wide env var won't work
# as it appears actions/setup-node sets own value
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 01dd......71cc
run: |
./.github/prepare-canary.js
npm publish --tag canary
git checkout .
- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v3
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}-
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Unit tests
# Some tests depend on TTY support, which is missing in GA runner
# Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161
run: script -e -c "npm run coverage -- -b"
- name: Push coverage
run: npx codecov
- name: Packaging tests
run: npm run integration-test-run-package
windowsNode16:
name: '[Windows] Node.js v16: Unit tests'
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v3
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}-
- name: Install Node.js and npm
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Unit tests
run: npm test -- -b
linuxNode14:
name: '[Linux] Node.js 14: Isolated unit tests'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v3
with:
path: |
~/.npm
node_modules
key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}-
- name: Install Node.js and npm
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Unit tests
# Some tests depend on TTY support, which is missing in GA runner
# Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161
run: script -e -c "npm run test:isolated -- -b"
linuxNode12:
name: '[Linux] Node.js v12: Node version validation test'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node.js and npm
uses: actions/setup-node@v3
with:
node-version: 12.x
- name: Node version validation test
run: ./bin/serverless.js 2>&1 | grep -q "does not support"
linuxNode4:
name: '[Linux] Node.js v4: Node version validation test'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node.js and npm
uses: actions/setup-node@v3
with:
node-version: 4.x
- name: Node version validation test
run: ./bin/serverless.js 2>&1 | grep -q "does not support"
integrate:
name: Integrate
runs-on: ubuntu-latest
needs: [linuxNode16, windowsNode16, linuxNode14, linuxNode12, linuxNode4]
timeout-minutes: 30 # Default is 360
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLS_AWS_REQUEST_MAX_RETRIES: 50 #Increase number of retries, due to observed "Rate exceeded" fails
SERVERLESS_BINARY_PATH: ./dist/serverless-linux
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# Ensure to have complete history of commits pushed with given push operation
# It's loose and imperfect assumption that no more than 30 commits will be pushed at once
fetch-depth: 30
# Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow
# Hence we're passing 'serverless-ci' user authentication token
token: ${{ secrets.USER_GITHUB_TOKEN }}
- name: Retrieve dependencies from cache
uses: actions/cache@v3
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
# Potentially needed for test/integration/curated-plugins-python.test.js
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Node.js and npm
uses: actions/setup-node@v3
with:
node-version: 16.x
# Note: No need to install dependencies as we have retrieved cached `node_modules` for very
# same `package.json` as stored with previous job
- name: Build standalone artifacts
run: npm run pkg:build
- name: Basic integration tests against standalone binary
run: npm run integration-test-run-basic
- name: Full integration tests against standalone binary
run: npm run integration-test-run-all
- name: Tag if new version
run: |
NEW_VERSION=`git diff -U0 ${{ github.event.before }} package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$NEW_VERSION" ];
then
git tag v$NEW_VERSION
git push --tags
fi