-
Notifications
You must be signed in to change notification settings - Fork 6
344 lines (289 loc) · 10.2 KB
/
ci.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: NITTA Build and Test
on:
pull_request:
push:
branches: master
env:
GH_PAGES_DIR: gh-pages
jobs:
notify-about-push:
runs-on: ubuntu-latest
steps:
- name: Send msg on push
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
args: |
Repository: <strong>${{ github.event.repository.full_name }}</strong>
Ref: <strong>${{ github.ref }}</strong>
Event: <strong>${{ github.event_name }}</strong>
Info: ${{ github.event.pull_request.title }}
${{ github.event.pull_request.html_url }}
nitta-haskell-deps:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Cache ~/.stack
id: cache
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
lookup-only: true
- name: Install haskell-stack
if: steps.cache.outputs.cache-hit != 'true'
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-version: "latest"
stack-no-global: true
- name: Install nitta and dev dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
stack build --haddock --test --only-dependencies
stack install doctest weeder
nitta:
runs-on: ubuntu-latest
needs: nitta-haskell-deps
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
############################################################
## Caches
- uses: actions/cache@v3
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
- uses: actions/cache@v3
name: Cache .stack-work
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-stack-work-
- uses: actions/cache@v3
name: Cache nitta exe
with:
path: ~/.local/bin
key: ${{ runner.os }}-nitta-exe-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-nitta-exe-
- uses: actions/cache@v3
name: Cache nitta-api-gen
with:
path: ./web/src/services/gen
key: ${{ runner.os }}-nitta-api-gen-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-nitta-api-gen-
############################################################
## Setup dev tools
- name: Install haskell-stack
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-version: "latest"
stack-no-global: true
- name: "Set up HLint"
uses: haskell-actions/hlint-setup@v2.4.8
with:
version: "3.6.1"
- name: Install Icarus Verilog
run: sudo apt-get install iverilog
############################################################
## nitta checks
- name: Build & test nitta
run: make build test
- name: Check nitta lint and format
run: make lint
- name: Make production build
run: make build-prod
- name: Generate backend API
run: stack exec nitta-api-gen -- -v
############################################################
## nitta publish docs & reports
- name: Copy doc to GH_PAGES_DIR
run: |
mkdir -p "${{ env.GH_PAGES_DIR }}/haddock/"
cp -r $(stack path --dist-dir)/doc/html/nitta "$_"
- name: Copy test coverage to GH_PAGES_DIR
run: cp -r $(stack path --local-hpc-root)/combined/all ${{ env.GH_PAGES_DIR }}/hpc
- name: Copy API doc to GH_PAGES_DIR
run: |
mkdir -p "${{ env.GH_PAGES_DIR }}/rest-api/"
cp ./web/src/services/gen/rest_api.markdown "$_"
- name: Copy README.md to GH_PAGES_DIR
run: cp README.md ${{ env.GH_PAGES_DIR }}/
- name: Publish generated content to GitHub Pages
if: ${{ github.ref == 'refs/heads/master'}}
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
folder: ${{ env.GH_PAGES_DIR }}
branch: gh-pages
nitta-frontend:
runs-on: ubuntu-latest
needs: nitta
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
############################################################
## Caches
- name: Get yarn cache directory path
working-directory: ./web
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v3
name: Cache nitta-api-gen
with:
path: ./web/src/services/gen
key: ${{ runner.os }}-nitta-api-gen-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-nitta-api-gen-
############################################################
## nitta ui checks
- name: Build nitta frontend
timeout-minutes: 15
run: |
yarn --cwd web install
make build-ui
nitta-ml:
runs-on: ubuntu-latest
needs: nitta
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
############################################################
## Caches
- uses: actions/cache@v3
name: Cache nitta exe
with:
path: ~/.local/bin
key: ${{ runner.os }}-nitta-exe-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-nitta-exe-
- uses: actions/cache@v3
name: Cache nitta-api-gen
with:
path: ./web/src/services/gen
key: ${{ runner.os }}-nitta-api-gen-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-nitta-api-gen-
############################################################
## Setup dev tools
- uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.6.1
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: poetry
- name: Install Python dependencies
working-directory: ./ml/synthesis
run: poetry install --no-root
############################################################
## nitta ml checks
- name: Run Python tests
working-directory: ./ml/synthesis
env:
NITTA_RUN_COMMAND: nitta
run: |
export PYTHONPATH=$(pwd)/src:$PYTHONPATH
poetry run pytest
verilog-formatting:
timeout-minutes: 5
runs-on: ubuntu-latest
container: ryukzak/alpine-iverilog
defaults:
run:
shell: sh
steps:
- uses: actions/checkout@v3
- run: |
make -C hdl > make_hdl.log
cat make_hdl.log
test "$(grep -ci error make_hdl.log)" -eq 0
haskell-formatting:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.14.1.0"
typescript-formatting:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check ts and tsx code style by prettier
working-directory: ./web
run: |
yarn add -s prettier
yarn exec -s prettier -- --check src/**/*.{ts,tsx}
markdown-formatting:
timeout-minutes: 5
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v3.2.0
- name: Run mdl for check markdown format
uses: nosborn/github-action-markdown-cli@v3.3.0
with:
files: .
config_file: .markdownlint.yaml
python-checks:
timeout-minutes: 5
runs-on: ubuntu-22.04
name: python-${{ matrix.tool }}
strategy:
fail-fast: false
matrix:
include:
- tool: black
run_cmd: black --check --diff src
- tool: ruff
run_cmd: ruff check --diff src
- tool: mypy
# for mypy we need to install all deps for type hints, type stubs and mypy plugins
setup_cmd: |
poetry install --no-root
- tool: vulture
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.6.1
- name: Install ${{ matrix.tool }} with a version from poetry.lock
working-directory: ./ml/synthesis
# use system python, we're in an action container
run: |
poetry config virtualenvs.create false
poetry export --only=dev --without-hashes \
| grep ${{ matrix.tool }} \
| pip install -r /dev/stdin
- name: Run a ${{ matrix.tool }}-specific setup command
if: ${{ matrix.setup_cmd }}
working-directory: ./ml/synthesis
run: ${{ matrix.setup_cmd }}
- name: Check Python code with ${{ matrix.tool }}
working-directory: ./ml/synthesis
# run provided run_cmd or just call tool by name with no arguments
run: |
${{ matrix.run_cmd && matrix.run_cmd || matrix.tool }}