test: correctly makes all example tests runnable #1222
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.40" | |
TINYGO_VERSION: "0.32.0" | |
ZIG_VERSION: "0.11.0" | |
concurrency: | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run | |
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.actor }} | |
cancel-in-progress: true | |
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-22.04 | |
strategy: | |
matrix: # Use versions consistent with TinyGo. | |
go-version: | |
- "1.22" | |
- "1.20" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install TinyGo | |
run: | # installing via curl so commands are similar on OS/x | |
tinygo_version=${{ env.TINYGO_VERSION }} | |
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: | | |
sudo apt install xz-utils | |
sudo sh -c 'wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env.ZIG_VERSION }}.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 | |
if: matrix.go-version != '1.20' # fails with TinyGo v0.32.0 | |
- 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: Run example tests | |
run: make test.examples |