-
Notifications
You must be signed in to change notification settings - Fork 20
301 lines (268 loc) · 9.09 KB
/
build.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Build
on:
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
verify:
runs-on: macos-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Verify README generation
uses: momentohq/standards-and-practices/github-actions/oss-readme-template@gh-actions-v2
with:
project_status: official
project_stability: stable
project_type: sdk
sdk_language: JavaScript
dev_docs_slug: nodejs
multiple_sdks: true
- name: Verify README generation for nodejs
uses: momentohq/standards-and-practices/github-actions/oss-readme-template@gh-actions-v2
with:
project_status: official
project_stability: stable
project_type: sdk
sdk_language: Node.js
dev_docs_slug: nodejs
template_file: ./packages/client-sdk-nodejs/README.template.md
output_file: ./packages/client-sdk-nodejs/README.md
- name: Verify README generation for web
uses: momentohq/standards-and-practices/github-actions/oss-readme-template@gh-actions-v2
with:
project_status: official
project_stability: stable
project_type: sdk
sdk_language: "JavaScript Web"
dev_docs_slug: web
template_file: ./packages/client-sdk-web/README.template.md
output_file: ./packages/client-sdk-web/README.md
- name: Commitlint and Other Shared Build Steps
uses: momentohq/standards-and-practices/github-actions/shared-build@gh-actions-v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
strategy:
matrix:
node: [18]
name: Test on Node ${{ matrix.node }}
runs-on: macos-latest
env:
TEST_AUTH_TOKEN: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
TEST_SESSION_TOKEN: ${{ secrets.MOMENTO_PREPROD_SESSION_TOKEN }}
TEST_LEGACY_AUTH_TOKEN: ${{ secrets.ALPHA_LEGACY_TEST_AUTH_TOKEN }}
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Build and test all packages
run: |
node -v
./scripts/build-and-test-all-packages.sh
- name: Run auth tests for packages
run: |
node -v
./scripts/test-auth-packages.sh
- name: Run vector tests for packages
run: |
node -v
./scripts/test-vector-packages.sh
test-examples:
strategy:
matrix:
node: [14, 16, 18]
fail-fast: true
max-parallel: 1
name: Test examples on node ${{ matrix.node }}
runs-on: macos-latest
env:
# TODO: remove token stored as secret in favor of using a
# momento-local instance that can be spun up for testing
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Deps and Build
id: validation
continue-on-error: true
run: |
pushd examples/nodejs/cache
npm ci
npm run build
npm run validate-examples
popd
pushd examples/nodejs/observability
npm ci
npm run build
npm run validate-examples
popd
pushd examples/nodejs/load-gen
npm ci
npm run build
popd
pushd examples/nodejs/topics
npm ci
npm run build
popd
pushd examples/nodejs/lambda-examples/topics-microservice
npm ci
npm run build
popd
pushd examples/nodejs/mongodb-examples/simple-read-aside
npm ci
npm run build
popd
pushd examples/nodejs/access-control
npm ci
npm run build
npm run validate-examples
popd
pushd examples/nodejs/aws
npm ci
npm run build
popd
pushd examples/nodejs/vector-index
npm ci
npm run build
npm run validate-examples
popd
- name: Send CI failure mail
if: ${{ steps.validation.outcome == 'failure' }}
uses: momentohq/standards-and-practices/github-actions/error-email-action@gh-actions-v2
with:
username: ${{secrets.MOMENTO_ROBOT_GMAIL_USERNAME}}
password: ${{secrets.MOMENTO_ROBOT_GMAIL_PASSWORD}}
- name: Flag Job Failure
if: ${{ steps.validation.outcome == 'failure' }}
run: exit 1
test-web-examples:
strategy:
matrix:
node: [ 16, 18 ]
fail-fast: true
max-parallel: 1
name: Test web examples on node ${{ matrix.node }}
runs-on: macos-latest
env:
# TODO: remove token stored as secret in favor of using a
# momento-local instance that can be spun up for testing
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Deps and Build
id: validation
continue-on-error: true
run: |
pushd examples/web/cache
npm ci
npm run build
npm run validate-examples
popd
pushd examples/web/nextjs-chat
npm ci
npm run build
popd
pushd examples/web/vite-chat-app
npm ci
npm run build
popd
pushd examples/web/vector-index
npm ci
npm run build
npm run validate-examples
popd
- name: Send CI failure mail
if: ${{ steps.validation.outcome == 'failure' }}
uses: momentohq/standards-and-practices/github-actions/error-email-action@gh-actions-v2
with:
username: ${{secrets.MOMENTO_ROBOT_GMAIL_USERNAME}}
password: ${{secrets.MOMENTO_ROBOT_GMAIL_PASSWORD}}
- name: Flag Job Failure
if: ${{ steps.validation.outcome == 'failure' }}
run: exit 1
test-deno-examples:
strategy:
matrix:
node: [ 16, 18 ]
fail-fast: true
max-parallel: 1
name: Test Deno examples on node ${{ matrix.node }}
runs-on: macos-latest
env:
# TODO: remove token stored as secret in favor of using a
# momento-local instance that can be spun up for testing
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x # Run with latest stable Deno.
- name: Check formatting and Build
id: validation
continue-on-error: true
run: |
pushd examples/deno/web-sdk
deno lint
deno fmt --check
deno compile index.ts
popd
pushd examples/deno/http-api
deno lint
deno fmt --check
deno compile index.ts
popd
- name: Send CI failure mail
if: ${{ steps.validation.outcome == 'failure' }}
uses: momentohq/standards-and-practices/github-actions/error-email-action@gh-actions-v2
with:
username: ${{secrets.MOMENTO_ROBOT_GMAIL_USERNAME}}
password: ${{secrets.MOMENTO_ROBOT_GMAIL_PASSWORD}}
- name: Flag Job Failure
if: ${{ steps.validation.outcome == 'failure' }}
run: exit 1
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
dependabot-auto-merge:
name: Dependabot Auto Merge
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
# make sure we run all tests/examples and they pass before we try and auto approve/merge the dependabot prs
needs: [test-deno-examples, test-web-examples, test-examples, test, verify]
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
# need to have an approver first before dependabot can merge the pr, here we are using the shared
# momento github actions bot user
GH_TOKEN: ${{secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}