forked from bytecodealliance/wit-bindgen
-
-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (179 loc) · 6.41 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
name: CI
on:
pull_request:
merge_group:
defaults:
run:
shell: bash
# 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
jobs:
build:
name: Build wit-bindgen
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@v4
with:
name: bins-${{ matrix.build }}
path: dist
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm32-wasi target
run: rustup target add wasm32-wasi
- uses: ./.github/actions/install-wasi-sdk
- run: |
curl.exe -LO https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1
powershell -File dotnet-install.ps1 -Channel 8.0.1xx -Verbose
echo DOTNET_ROOT=$LOCALAPPDATA'\Microsoft\dotnet' >> $GITHUB_ENV
export DOTNET_ROOT=$LOCALAPPDATA\\Microsoft\\dotnet
echo $LOCALAPPDATA'\Microsoft\dotnet' >> $GITHUB_PATH
echo $LOCALAPPDATA'\Microsoft\dotnet\tools' >> $GITHUB_PATH
$LOCALAPPDATA/Microsoft/dotnet/dotnet --info
echo nativeaot-llvm requires emscripten for its version of clang as wasi-sdk 20 does not work see https://github.com/WebAssembly/wasi-sdk/issues/326
curl.exe -OL https://github.com/emscripten-core/emsdk/archive/refs/heads/main.zip
unzip main.zip
cd emsdk-main
./emsdk.bat install 3.1.47
./emsdk.bat activate 3.1.47
if : matrix.os == 'windows-latest'
- run: ci/download-teavm.sh
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/setup-java@v4
with:
java-version: '18'
distribution: 'adopt'
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: acifani/setup-tinygo@v1
with:
tinygo-version: 0.30.0
- name: All but Windows, cargo test --workspace
if : matrix.os != 'windows-latest'
run: cargo test --workspace
- name: Windows, set EMSDK and run cargo test
if : matrix.os == 'windows-latest'
run: |
source ./emsdk-main/emsdk_env.sh
cargo test --workspace
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm32-wasi target
run: rustup target add wasm32-wasi
# Verify the output of the `./ci/rebuild-libcabi-realloc.sh` script is
# up-to-date.
- uses: ./.github/actions/install-wasi-sdk
- run: ./ci/rebuild-libcabi-realloc.sh
- run: git diff --exit-code
# Test various feature combinations, make sure they all build
- run: cargo build
- run: cargo build --no-default-features
- run: cargo build --no-default-features --features rust
- run: cargo build --no-default-features --features c
- run: cargo build --no-default-features --features teavm-java
- run: cargo build --no-default-features --features go
- run: cargo build --no-default-features --features csharp
- run: cargo build --no-default-features --features markdown
# Feature combos of the `wit-bindgen` crate
- run: cargo build --target wasm32-wasi -p wit-bindgen --no-default-features
- run: cargo build --target wasm32-wasi -p wit-bindgen --no-default-features --features realloc
- run: cargo build --target wasm32-wasi -p wit-bindgen --no-default-features --features macros
- run: cargo build --target wasm32-wasi -p wit-bindgen --no-default-features --features macros,realloc
# Verity that documentation can be generated for the rust bindings crate.
- run: cargo doc -p wit-bindgen --no-deps
env:
RUSTDOCFLAGS: --cfg=docsrs
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
- name: Format source code
run: cargo fmt -- --check
verify-publish:
if: github.repository_owner == 'bytecodealliance'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable && rustup default stable
- run: rustc ci/publish.rs
# Make sure the tree is publish-able as-is
- run: ./publish verify
# Make sure we can bump version numbers for the next release
- run: ./publish bump
# "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
- rustfmt
- build
- verify-publish
- check
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