forked from bytecodealliance/wasm-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
249 lines (236 loc) · 8.52 KB
/
main.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
name: CI
on:
pull_request:
merge_group:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
name: Build wasm-tools
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- build: x86_64-linux
os: ubuntu-latest
- build: x86_64-macos
os: macos-latest
- build: aarch64-macos
os: macos-latest
target: aarch64-apple-darwin
- build: x86_64-windows
os: windows-latest
- build: aarch64-linux
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable --no-self-update && rustup default stable
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
with:
name: ${{ matrix.build }}
- run: |
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
rustup target add ${{ matrix.target }}
if: matrix.target != ''
- run: $CENTOS cargo build --release
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
- uses: actions/upload-artifact@v3
with:
name: bins-${{ matrix.build }}
path: dist
# - uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/') && github.repository == 'bytecodealliance/wasm-tools'
# with:
# files: "dist/*"
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [stable, beta, nightly, macos, windows]
include:
- build: stable
os: ubuntu-latest
rust: stable
- build: beta
os: ubuntu-latest
rust: beta
- build: nightly
os: ubuntu-latest
rust: nightly
- build: macos
os: macos-latest
rust: stable
- build: windows
os: windows-latest
rust: stable
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
shell: bash
- run: cargo test --locked --all
- run: cargo test --locked -p wasmparser --benches
- run: cargo test --locked -p wasm-encoder --all-features
- run: cargo test -p wasm-smith --features wasmparser
- run: cargo build --manifest-path crates/wast/Cargo.toml --no-default-features
- run: cargo build --manifest-path crates/wast/Cargo.toml --no-default-features --features wasm-module
- run: cmake -S ${{github.workspace}}/examples -B ${{github.workspace}}/examples/build -DCMAKE_BUILD_TYPE=Release
- run: cmake --build ${{github.workspace}}/examples/build --config Release
wasm:
name: Test on WebAssembly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- run: rustup target add wasm32-wasi
- run: |
tag=v10.0.1
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/${tag}/wasmtime-${tag}-x86_64-linux.tar.xz
tar xf wasmtime-${tag}-x86_64-linux.tar.xz
echo `pwd`/wasmtime-${tag}-x86_64-linux >> $GITHUB_PATH
echo CARGO_TARGET_WASM32_WASI_RUNNER='wasmtime run --dir . --' >> $GITHUB_ENV
echo CARGO_BUILD_TARGET='wasm32-wasi' >> $GITHUB_ENV
- run: |
cargo --locked test --workspace \
--exclude fuzz-stats \
--exclude wasm-tools-fuzz \
--exclude wasm-mutate-stats
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
# Note that this doesn't use `cargo fmt` because that doesn't format
# modules-defined-in-macros which is in use in `wast` for example. This is
# the best alternative I can come up with at this time
- run: find . -name '*.rs' | xargs rustfmt --check --edition 2021
fuzz:
name: Fuzz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: cargo install cargo-fuzz
- run: cargo fuzz build --dev -s none
- run: cargo fuzz build --dev --features wasmtime -s none
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo check --benches -p wasm-smith
- run: cargo check --no-default-features
- run: cargo check --no-default-features --features print
- run: cargo check --no-default-features --features parse
- run: cargo check --no-default-features --features validate
- run: cargo check --no-default-features --features smith
- run: cargo check --no-default-features --features shrink
- run: cargo check --no-default-features --features mutate
- run: cargo check --no-default-features --features dump
- run: cargo check --no-default-features --features objdump
- run: cargo check --no-default-features --features strip
- run: cargo check --no-default-features --features compose
- run: cargo check --no-default-features --features demangle
- run: cargo check --no-default-features --features component
- run: cargo check --no-default-features --features metadata
- run: cargo check --no-default-features --features wit-smith
- run: cargo check --no-default-features --features addr2line
- run: cargo check --no-default-features -p wit-parser
- run: cargo check --no-default-features -p wit-parser --features wat
- run: cargo check --no-default-features -p wit-parser --features serde
- run: cargo check --no-default-features -p wit-parser --features decoding
- run: cargo check --no-default-features -p wit-parser --features serde,decoding,wat
- run: |
if cargo tree -p wasm-smith --no-default-features -e no-dev | grep wasmparser; then
echo wasm-smith without default features should not depend on wasmparser
exit 1
fi
doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo doc --all
# "Join node" which the merge queue waits on.
ci-status:
name: Record the result of testing and building steps
runs-on: ubuntu-latest
needs:
- test
- wasm
- rustfmt
- fuzz
- check
- doc
- build
if: always()
steps:
- name: Successful test and build
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failing test and build
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Report failure on cancellation
if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }}
run: exit 1
# Look for the term "automatically-tag-and-release-this-commit" within merged
# PRs/commits.
push-tag:
runs-on: ubuntu-latest
needs: ci-status
if: |
always()
&& needs.ci-status.result == 'success'
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
&& github.repository_owner == 'bytecodealliance'
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Test if tag is needed
run: |
git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log
version=$(./ci/print-current-version.sh)
echo "version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
if grep -q "automatically-tag-and-release-this-commit" main.log; then
echo push-tag
echo "push_tag=yes" >> $GITHUB_OUTPUT
else
echo no-push-tag
echo "push_tag=no" >> $GITHUB_OUTPUT
fi
id: tag
- name: Push the tag
run: |
git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
curl -iX POST $git_refs_url \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d @- << EOF
{
"ref": "refs/tags/v${{ steps.tag.outputs.version }}",
"sha": "${{ steps.tag.outputs.sha }}"
}
EOF
if: steps.tag.outputs.push_tag == 'yes'