-
Notifications
You must be signed in to change notification settings - Fork 53
191 lines (174 loc) · 6.3 KB
/
build-and-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
name: Build
on:
workflow_call:
pull_request:
push:
branches:
- main
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
metadata: [
{
name: "Ubuntu (x86 native)",
os: ubuntu-latest,
bin-path: target/release-compact/winterjs,
artifact-name: winterjs-linux-x86,
target: native,
},
{
name: "macOS (arm native)",
os: macos-latest,
bin-path: target/release-compact/winterjs,
artifact-name: winterjs-macos-arm,
target: native,
},
{
name: "macOS (x86 native)",
os: macos-13,
bin-path: target/release-compact/winterjs,
artifact-name: winterjs-macos-x86,
target: native,
},
{
name: "Ubuntu (wasix)",
os: ubuntu-latest,
bin-path: target/wasm32-wasmer-wasi/release/winterjs.wasm,
artifact-name: winterjs-wasix,
target: wasix,
wasix-toolchain-release-asset: rust-toolchain-x86_64-unknown-linux-gnu.tar.gz
},
# {
# name: "macOS (wasix)",
# os: macos-15-xlarge,
# bin-path: target/release-compact/winterjs,
# artifact-name: winterjs-macos-wasix,
# target: wasix,
# wasix-toolchain-release-asset: rust-toolchain-aarch64-apple-darwin.tar.gz
# }
]
name: Build and Test - ${{ matrix.metadata.name }}
runs-on: ${{ matrix.metadata.os }}
steps:
- name: Check out
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: OS Setup (Ubuntu)
if: ${{ matrix.metadata.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3.11 python3-distutils llvm-15 libclang-dev clang-15 wabt
npm i -g wasm-opt pnpm concurrently
sudo rm /usr/bin/clang
sudo rm /usr/bin/clang++
sudo ln -s /usr/bin/clang-15 /usr/bin/clang
sudo ln -s /usr/bin/clang++-15 /usr/bin/clang++
sudo ln -s /usr/bin/llvm-ar-15 /usr/bin/llvm-ar
sudo ln -s /usr/bin/llvm-nm-15 /usr/bin/llvm-nm
sudo ln -s /usr/bin/llvm-ranlib-15 /usr/bin/llvm-ranlib
sudo ln -s /usr/bin/llvm-objdump-15 /usr/bin/llvm-objdump
- name: OS Setup (macOS)
if: ${{ startsWith(matrix.metadata.os, 'macos-') }}
run: |
brew install wabt llvm@15
ls -al /usr/local/opt/llvm@15/bin
echo PATH="/usr/local/opt/llvm@15/bin:$PATH" >> $GITHUB_ENV
# echo PATH="/opt/homebrew/opt/llvm@15/bin:$PATH" >> $GITHUB_ENV
npm i -g wasm-opt pnpm concurrently
- name: Tool Versions
run: |
echo clang
clang -v
echo '####################'
echo llvm-ar
llvm-ar -V
echo '####################'
echo llvm-nm
llvm-nm -V
echo '####################'
echo llvm-ranlib
llvm-ranlib -v
echo '####################'
echo wasm-opt
wasm-opt --version
echo '####################'
echo wasm-strip
wasm-strip --version
echo '####################'
echo python
python3.11 -V
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.76"
components: "clippy,rustfmt"
- name: Setup Wasmer
if: ${{ matrix.metadata.target == 'wasix' }}
uses: wasmerio/setup-wasmer@v3.1
- name: Download wasix-libc
if: ${{ matrix.metadata.target == 'wasix' }}
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
repo: wasix-org/rust
file: wasix-libc.tar.gz
target: sysroot/wasix-libc.tar.gz
- name: Unpack wasix-libc
if: ${{ matrix.metadata.target == 'wasix' }}
run: |
cd sysroot
tar xzf wasix-libc.tar.gz
- name: Download wasix toolchain
if: ${{ matrix.metadata.target == 'wasix' }}
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
repo: wasix-org/rust
file: ${{ matrix.metadata.wasix-toolchain-release-asset }}
target: wasix-rust-toolchain/toolchain.tar.gz
- name: Install wasix toolchain
if: ${{ matrix.metadata.target == 'wasix' }}
run: |
cd wasix-rust-toolchain
tar xzf toolchain.tar.gz
chmod +x bin/*
chmod +x lib/rustlib/*/bin/*
chmod +x lib/rustlib/*/bin/gcc-ld/*
rustup toolchain link wasix .
- name: Build native
if: ${{ matrix.metadata.target == 'native' }}
run: cargo build --profile release-compact
- name: Build wasix
if: ${{ matrix.metadata.target == 'wasix' }}
run: |
export WASI_SYSROOT=$(pwd)/sysroot/wasix-libc/sysroot32
bash build.sh
- name: Archive build
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.metadata.artifact-name }}
path: ${{ matrix.metadata.bin-path }}
- name: build test suite JS app
run: |
cd test-suite/js-test-app
pnpm i
pnpm run build
- name: Run API test suite (wasix)
# note: we're counting on wasmer compiling and running WinterJS faster
# that cargo builds the test-suite app. This may not be the case forever.
if: ${{ matrix.metadata.target == 'wasix' }}
run: |
conc --kill-others --success "command-1" \
"wasmer run . --net --mapdir /app:./test-suite/js-test-app/dist -- serve /app/bundle.js" \
"sleep 10 && cd test-suite && cargo run"
echo All tests are passing! 🎉
- name: Run API test suite (native)
# note: we're counting on wasmer compiling and running WinterJS faster
# that cargo builds the test-suite app. This may not be the case forever.
if: ${{ matrix.metadata.target == 'native' }}
run: |
conc --kill-others --success "command-1" \
"./target/release-compact/winterjs serve ./test-suite/js-test-app/dist/bundle.js" \
"sleep 10 && cd test-suite && cargo run"
echo All tests are passing! 🎉