forked from WebAssembly/wasi-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (184 loc) · 6.74 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
name: CI
on:
create:
tags:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
name: Native Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/cache@v3
with:
path: ~/.cache/ccache
# Bump the prefix number to evict all previous caches and
# enforce a clean build, in the unlikely case that some
# weird build error occur and ccache becomes a potential
# suspect.
key: 0-cache-ubuntu-latest-${{ github.run_id }}
restore-keys: |
0-cache-ubuntu-latest-
if: matrix.os == 'ubuntu-latest'
- uses: actions/cache@v3
with:
path: ~/Library/Caches/ccache
key: 0-cache-macos-latest-${{ github.run_id }}
restore-keys: |
0-cache-macos-latest-
if: matrix.os == 'macos-latest'
- name: Install wasmtime for tests
# TODO: switch to Wasmtime 17 once it's released, which will include https://github.com/bytecodealliance/wasmtime/pull/7750
run: |
curl -f -L --retry 5 https://wasmtime.dev/install.sh | bash -s -- --version dev
~/.wasmtime/bin/wasmtime --version
curl -f -L --retry 5 -o ~/.wasmtime/bin/wasi_snapshot_preview1.command.wasm https://github.com/bytecodealliance/wasmtime/releases/download/dev/wasi_snapshot_preview1.command.wasm
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
curl -f -OL --retry 5 https://github.com/bytecodealliance/wasm-tools/releases/download/wasm-tools-1.0.54/wasm-tools-1.0.54-x86_64-linux.tar.gz
tar xf wasm-tools-1.0.54-x86_64-linux.tar.gz
cp wasm-tools-1.0.54-x86_64-linux/wasm-tools ~/.wasmtime/bin/
else
curl -f -OL --retry 5 https://github.com/bytecodealliance/wasm-tools/releases/download/wasm-tools-1.0.54/wasm-tools-1.0.54-x86_64-macos.tar.gz
tar xf wasm-tools-1.0.54-x86_64-macos.tar.gz
cp wasm-tools-1.0.54-x86_64-macos/wasm-tools ~/.wasmtime/bin/
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0
# We can't use `--depth 1` here sadly because the GNU config
# submodule is not pinned to a particular tag/branch. Please
# bump depth (or even better, the submodule), in case of "error:
# Server does not allow request for unadvertised object" in the
# future.
- run: git submodule update --init --depth 32 --jobs 3
- name: Install ccache, ninja (macOS)
run: brew install ccache ninja
if: matrix.os == 'macos-latest'
- name: Install ccache, ninja (Linux)
run: sudo apt install ccache ninja-build
if: matrix.os == 'ubuntu-latest'
- name: Build
run: NINJA_FLAGS=-v make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
shell: bash
- name: Run the testsuite
run: NINJA_FLAGS=-v make check RUNTIME=~/.wasmtime/bin/wasmtime ADAPTER=~/.wasmtime/bin/wasi_snapshot_preview1.command.wasm WASM_TOOLS=~/.wasmtime/bin/wasm-tools
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
# Upload the dist folder. Give it a name according to the OS it was built for.
name: ${{ format( 'dist-{0}', matrix.os) }}
path: dist
winbuild:
name: Windows Build
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x64
sys: clang64
env: clang-x86_64
- arch: x86
sys: clang32
env: clang-i686
steps:
- uses: actions/cache@v3
with:
path: ~/AppData/Local/ccache
key: 0-${{ format( 'cache-windows-latest-{0}', matrix.arch) }}-${{ github.run_id }}
restore-keys: |
0-${{ format( 'cache-windows-latest-{0}', matrix.arch) }}-
- uses: msys2/setup-msys2@v2
with:
install: >-
base-devel
git
mingw-w64-${{ matrix.env }}-ccache
mingw-w64-${{ matrix.env }}-cmake
mingw-w64-${{ matrix.env }}-ninja
mingw-w64-${{ matrix.env }}-toolchain
msystem: ${{ matrix.sys }}
update: true
release: false
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git submodule update --init --depth 32 --jobs 3
- name: Build
shell: msys2 {0}
run: |
echo $PATH
rustup --version
rustc -vV
make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
make check
- name: Does it work sans msys2?
run: |
C:\wasi-sdk\bin\clang.exe --version
C:\wasi-sdk\bin\llvm-ar.exe --version
C:\wasi-sdk\bin\wasm-ld.exe --version
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
# Upload the dist folder. Give it a name according to the OS it was built for.
name: ${{ format( 'dist-windows-latest-{0}', matrix.arch) }}
path: dist
dockerbuild:
name: Docker Build
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
with:
path: ~/.ccache
key: 0-cache-ubuntu-bionic-${{ github.run_id }}
restore-keys: |
0-cache-ubuntu-bionic-
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git submodule update --init --depth 32 --jobs 3
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
- name: Run docker_build script
run: ./docker_build.sh
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
# Upload the dist folder. Give it a name according to the OS it was built for.
name: dist-ubuntu-bionic
path: dist
- name: Build and push wasi-sdk docker image
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
push: ${{ github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max