-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (160 loc) · 5.24 KB
/
test.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
name: Tests
on: [ push ]
jobs:
build-wabt:
name: Build WAT tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Get WABT commit ID
working-directory: tests/unit/artifacts/wabt
run: echo "WABT_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Cache wabt
uses: actions/cache@v4
id: cache-wabt
with:
key: ${{ runner.os }}-wabt-${{ env.WABT_VERSION }}
path: tests/unit/artifacts/wabt
restore-keys: |
${{ runner.os }}-wabt-
- name: Build WABT # Build latest version
if: steps.cache-wabt.outputs.cache-hit == false
working-directory: tests/unit/artifacts/wabt
run: |
mkdir build; cd build
cmake ..
cmake --build .
- name: Upload built tools
uses: actions/upload-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: tests/unit/artifacts/wabt/build
build-wdcli:
name: Build WARDuino CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Get WDCLI commit ID
working-directory: tests/unit/artifacts/warduino
run: echo "WDCLI_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Cache WARDuino CLI
uses: actions/cache@v4
id: cache-warduino
with:
key: ${{ runner.os }}-warduino-${{ env.WDCLI_VERSION }}
path: tests/unit/artifacts/warduino
restore-keys: |
${{ runner.os }}-warduino-
- name: Build WARDuino CLI # Build latest version
if: steps.cache-warduino.outputs.cache-hit == false
working-directory: tests/unit/artifacts/warduino
run: |
mkdir build; cd build
cmake .. -D BUILD_EMULATOR=ON
cmake --build .
- name: Upload built tools
uses: actions/upload-artifact@v4
with:
name: warduino-build-${{ github.run_id }}
path: tests/unit/artifacts/warduino/build
unit:
name: Unit tests
runs-on: ubuntu-latest
needs: build-wabt
strategy:
fail-fast: false
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- run: npm i
- name: Prebuild files
run: npm run test:prebuild
- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools
- name: Verify tools
run: |
chmod u+x $GITHUB_WORKSPACE/.tools/*
$GITHUB_WORKSPACE/.tools/wasm-objdump --version
- name: Run ava unit tests
run: npm run test:ava
env:
WABT: ${GITHUB_WORKSPACE}/.tools
warduino:
name: WARDuino test
runs-on: ubuntu-latest
needs: [build-wabt, build-wdcli]
strategy:
fail-fast: false
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- run: npm i
- name: Prebuild files
run: npm run test:prebuild
- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools
- name: Download WARDuino
uses: actions/download-artifact@v4
with:
name: warduino-build-${{ github.run_id }}
path: .warduino
- name: Verify
run: |
chmod u+x $GITHUB_WORKSPACE/.tools/*
chmod u+x $GITHUB_WORKSPACE/.warduino/wdcli
$GITHUB_WORKSPACE/.tools/wasm-objdump --version
#$GITHUB_WORKSPACE/.warduino/wdcli --version
- name: Run example WARDuino test
run: npm run test:example
env:
WABT: ${{ github.workspace }}/.tools
EMULATOR: ${{ github.workspace }}/.warduino/wdcli
coverage:
name: Code coverage
runs-on: ubuntu-latest
needs: build-wabt
strategy:
fail-fast: true
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- run: npm i
- name: Prebuild files
run: npm run test:prebuild
- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools
- name: Verify tools
run: |
chmod u+x $GITHUB_WORKSPACE/.tools/*
$GITHUB_WORKSPACE/.tools/wasm-objdump --version
- name: Add .tools to PATH
run: echo "$GITHUB_WORKSPACE/.tools" >> $GITHUB_PATH
- name: Run c8 coverage
run: |
echo "LINE_COVERAGE=$(npm run coverage:test:ava | grep -E 'Lines\s*:\s*[0-9]+(\.[0-9]+)?%' | awk '{print $3}' | tr -d '%')" >> $GITHUB_ENV
- name: Report coverage
run: npx c8 report
- name: Update coverage badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 615b7906cd71effb447c4b08673d2cb6
filename: latch-coverage.json
label: Coverage
message: ${{ env.LINE_COVERAGE }}
valColorRange: ${{ env.LINE_COVERAGE }}
maxColorRange: 100
minColorRange: 0