Skip to content

Commit

Permalink
chore(deps): upgrade to latest version of tinygo
Browse files Browse the repository at this point in the history
We can stop to rely on a patched version of tinygo

Signed-off-by: Flavio Castelli <[email protected]>
  • Loading branch information
flavio committed Jun 24, 2024
1 parent bed5eeb commit 480fa9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/reusable-test-policy-go.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Tests and linters

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -30,18 +29,26 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install dependencies
uses: kubewarden/github-actions/[email protected]
- name: Install patched tinygo
# TinyGo requires the official Go compiler to be installed
# Ensure latest stable release is available, do not rely on what
# is provided out of the box by the GH runner
- name: setup Go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Install tinygo
shell: bash
run: |
wget https://github.com/tinygo-org/tinygo/releases/download/v0.28.1/tinygo_0.28.1_amd64.deb
sudo dpkg -i tinygo_0.28.1_amd64.deb
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/libclang_rt.builtins-wasm32-wasi-16.0.tar.gz
tar xvf libclang_rt.builtins-wasm32-wasi-16.0.tar.gz
sudo cp lib/wasi/libclang_rt.builtins-wasm32.a /usr/local/lib/tinygo/lib/wasi-libc/sysroot/lib/wasm32-wasi/
sudo cp wasi-gh-action.json /usr/local/lib/tinygo/targets/wasi.json
wget https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb
sudo dpkg -i tinygo_0.30.0_amd64.deb
- name: Build Wasm module
shell: bash
run: |
# we have to remove the wasm-opt binary bundled with the tinygo package,
# this will lead to our binary being used (the one installed by the `policy-gh-action-dependencies`
# step)
sudo rm /usr/local/lib/tinygo/bin/wasm-opt
wasm-opt --version
tinygo build -o policy.wasm -target=wasi -no-debug .
- name: Annotate Wasm module
shell: bash
Expand Down
9 changes: 0 additions & 9 deletions Dockerfile

This file was deleted.

8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ VERSION := $(shell git describe | cut -c2-)

# We cannot use the official tinygo container image until
# this issue is closed: https://github.com/tinygo-org/tinygo/issues/3501
CONTAINER_IMAGE = ghcr.io/kubewarden/tinygo/tinygo-dev:0.28.1-multi3_fix
CONTAINER_IMAGE = tinygo/tinygo:0.30.0

# TODO: drop this once we can use the official tinygo container image
# see comment from above
build-container:
DOCKER_BUILDKIT=1 docker build . -t $(CONTAINER_IMAGE)

policy.wasm: $(SOURCE_FILES) go.mod go.sum
# TODO: remove the -opt=0 once tinygo ships with a more recent version of
# wasm-opt
docker run \
--rm \
-e GOFLAGS="-buildvcs=false" \
-v ${PWD}:/src \
-w /src \
$(CONTAINER_IMAGE) \
tinygo build -o policy.wasm -target=wasi -no-debug .
tinygo build -o policy-no-opt.wasm -opt=0 -target=wasi -no-debug .
# Note: requires binaryen >= 116 to be installed
wasm-opt -Os policy-no-opt.wasm -o policy.wasm

artifacthub-pkg.yml: metadata.yml go.mod
$(warning If you are updating the artifacthub-pkg.yml file for a release, \
Expand Down

0 comments on commit 480fa9a

Please sign in to comment.