From 480fa9a5176be14b153a416ec9af1b49f38c7f57 Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Mon, 5 Feb 2024 10:46:20 +0100 Subject: [PATCH] chore(deps): upgrade to latest version of tinygo We can stop to rely on a patched version of tinygo Signed-off-by: Flavio Castelli --- .github/workflows/reusable-test-policy-go.yml | 23 ++++++++++++------- Dockerfile | 9 -------- Makefile | 8 +++++-- 3 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/reusable-test-policy-go.yml b/.github/workflows/reusable-test-policy-go.yml index 8108d28..ae52296 100644 --- a/.github/workflows/reusable-test-policy-go.yml +++ b/.github/workflows/reusable-test-policy-go.yml @@ -1,5 +1,4 @@ name: Tests and linters - on: workflow_call: inputs: @@ -30,18 +29,26 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install dependencies uses: kubewarden/github-actions/policy-gh-action-dependencies@v3.1.16 - - 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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ac8126d..0000000 --- a/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -# syntax=docker/dockerfile:1-labs - -FROM alpine AS downloader -ADD --checksum=sha256:86a88ed80ba42d581f2139bfdcf1a6debeec558e3379ef85e69297579c758241 https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/libclang_rt.builtins-wasm32-wasi-16.0.tar.gz / -RUN tar xvf /libclang_rt.builtins-wasm32-wasi-16.0.tar.gz - -FROM "tinygo/tinygo:0.28.1" -COPY --from=downloader /lib/wasi/libclang_rt.builtins-wasm32.a /usr/local/tinygo/lib/wasi-libc/sysroot/lib/wasm32-wasi/ -COPY ./wasi.json /usr/local/tinygo/targets/wasi.json diff --git a/Makefile b/Makefile index d670264..f909f2b 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ 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 @@ -11,13 +11,17 @@ 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, \