-
Notifications
You must be signed in to change notification settings - Fork 243
108 lines (90 loc) · 3.16 KB
/
examples.yaml
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
name: Examples
on:
pull_request:
branches: [main]
paths:
- '.github/workflows/examples.yaml'
- 'examples/**'
- 'imports/**/example/**'
- 'Makefile'
push:
branches: [main]
paths:
- '.github/workflows/examples.yaml'
- 'examples/**'
- 'imports/**/example/**'
- 'Makefile'
env:
EMSDK_VERSION: "3.1.16"
jobs:
# Not all toolchains are idempotent when generating wasm, so we don't check
# in %.wasm as a part of this job.
examples:
name: Build examples
runs-on: ubuntu-20.04
strategy:
matrix: # use latest available versions and be consistent on all workflows!
go-version:
- "1.18" # == ${{ env.GO_VERSION }} because matrix cannot expand env variables
- "1.19"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/go/bin
key: check-${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum', 'Makefile') }}
- name: Install TinyGo
run: | # installing via curl so commands are similar on OS/x
tinygo_version=0.25.0
curl -sSL https://github.com/tinygo-org/tinygo/releases/download/v${tinygo_version}/tinygo${tinygo_version}.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf -
echo "TINYGOROOT=/usr/local/tinygo" >> $GITHUB_ENV
echo "/usr/local/tinygo/bin" >> $GITHUB_PATH
- name: Install Zig
run: | # on laptop, use `brew install --build-from-source zig --HEAD`
sudo apt install xz-utils
sudo sh -c 'wget -c https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3007+6ba2fb3db.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: Cache Emscripten
id: cache-emsdk
uses: actions/cache@v3
with:
path: emsdk
key: ${{ runner.os }}-emcc-${{env.EMSDK_VERSION}}
- name: Checkout Emscripten
if: steps.cache-emsdk.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: emscripten-core/emsdk
path: emsdk
- name: Install Emscripten
if: steps.cache-emsdk.outputs.cache-hit != 'true'
run: |
./emsdk/emsdk install ${{env.EMSDK_VERSION}}
- name: Install wasm32-wasi target
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-wasi
- name: Build TinyGO examples
run: make build.examples.tinygo
- name: Build AssemblyScript examples
run: make build.examples.as
- name: Build zig-cc examples
run: make build.examples.zig-cc
- name: Build Rust examples
run: make build.examples.rust
- name: Build Zig examples
run: make build.examples.zig
- name: Build Emscripten examples
run: |
./emsdk/emsdk activate ${{env.EMSDK_VERSION}}
source ./emsdk/emsdk_env.sh
make build.examples.emscripten
- name: Build bench cases
run: make build.bench
- name: Run example tests
run: make test.examples