-
Notifications
You must be signed in to change notification settings - Fork 44
215 lines (209 loc) · 5.71 KB
/
test-and-publish.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
#
# This workflow will run unit tests, smoke e2e tests and attempt to publish package to NPM.
#
name: Test and publish to NPM
on:
push: {}
pull_request: {}
workflow_dispatch: {}
jobs:
common-unit-tests:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node: [18]
steps:
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Git checkout
uses: actions/checkout@v4
- name: NPM ci, build, & test
run: |
npm ci
npm run build --if-present
npm run coverage
cd templates/project-ts
npm install || true
npm run test
env:
CI: true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: zkapp-cli
verbose: true
handle_no_reports_found: true
fail_ci_if_error: false
sudoku-example-unit-tests:
runs-on: ubuntu-latest
needs: [common-unit-tests]
strategy:
matrix:
node: [18]
steps:
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Git checkout
uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Unit Tests"
- name: NPM ci, build, & test
run: |
npm ci
npm run build --if-present
npm link
zk example sudoku
cd sudoku
npm run test
npm run build
npm run start
env:
CI: true
tictactoe-example-unit-tests:
runs-on: ubuntu-latest
needs: [common-unit-tests]
strategy:
matrix:
node: [18]
steps:
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Git checkout
uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Unit Tests"
- name: NPM ci, build, & test
run: |
npm ci
npm run build --if-present
npm link
zk example tictactoe
cd tictactoe
npm run test
npm run build
npm run start
env:
CI: true
smoke-e2e-tests-against-compatible-network:
needs: [sudoku-example-unit-tests, tictactoe-example-unit-tests]
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
node: [18, 20]
os: [ubuntu-latest]
services:
mina-local-network:
image: o1labs/mina-local-network:compatible-latest-lightnet
env:
NETWORK_TYPE: 'single-node'
PROOF_LEVEL: 'none'
ports:
- 3085:3085
- 5432:5432
- 8080:8080
- 8181:8181
- 8282:8282
volumes:
- /tmp:/root/logs
steps:
- name: Wait for Mina network readiness
uses: o1-labs/wait-for-mina-network-action@v1
with:
mina-graphql-port: 8080
max-attempts: 60
polling-interval-ms: 10000
- uses: actions/checkout@v4
- name: Use shared E2E testing steps
uses: ./.github/actions/e2e-shared
with:
node-version: ${{ matrix.node }}
os-type: ${{ matrix.os }}
shell: bash
mina-branch: 'compatible'
test-script: 'npm run e2e:test:smoke'
artifacts-prefix: 'smoke-e2e-tests'
smoke-e2e-tests-against-master-network:
needs: [sudoku-example-unit-tests, tictactoe-example-unit-tests]
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
node: [18, 20]
os: [ubuntu-latest]
services:
mina-local-network:
image: o1labs/mina-local-network:master-latest-lightnet
env:
NETWORK_TYPE: 'single-node'
PROOF_LEVEL: 'none'
ports:
- 3085:3085
- 5432:5432
- 8080:8080
- 8181:8181
- 8282:8282
volumes:
- /tmp:/root/logs
steps:
- name: Wait for Mina network readiness
uses: o1-labs/wait-for-mina-network-action@v1
with:
mina-graphql-port: 8080
max-attempts: 60
polling-interval-ms: 10000
- uses: actions/checkout@v4
- name: Use shared E2E testing steps
uses: ./.github/actions/e2e-shared
with:
node-version: ${{ matrix.node }}
os-type: ${{ matrix.os }}
shell: bash
mina-branch: 'master'
test-script: 'npm run e2e:test:smoke'
artifacts-prefix: 'smoke-e2e-tests'
publish-to-npm:
needs:
[
smoke-e2e-tests-against-compatible-network,
smoke-e2e-tests-against-master-network,
]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
node: [20]
steps:
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Git checkout
uses: actions/checkout@v4
- name: NPM ci & build
run: |
npm ci
npm run build --if-present
- name: Publish to NPM if version has changed
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
strategy: upgrade
env:
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}