From 1afad8c7984b843a9b512be8902411a4a83e0cc6 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Mon, 13 Feb 2023 18:09:30 +0900 Subject: [PATCH] Update to upstream TinyGo 0.27.0 (#150) --- .github/workflows/buildtools-tinygo.yaml | 68 --------------------- .github/workflows/ci.yaml | 3 +- .github/workflows/nightly-coraza-check.yaml | 9 +-- buildtools/tinygo/Dockerfile | 21 ------- buildtools/tinygo/wasi-libc.Dockerfile | 13 ---- magefiles/magefile.go | 13 +--- 6 files changed, 5 insertions(+), 122 deletions(-) delete mode 100644 .github/workflows/buildtools-tinygo.yaml delete mode 100644 buildtools/tinygo/Dockerfile delete mode 100644 buildtools/tinygo/wasi-libc.Dockerfile diff --git a/.github/workflows/buildtools-tinygo.yaml b/.github/workflows/buildtools-tinygo.yaml deleted file mode 100644 index ddf90f5..0000000 --- a/.github/workflows/buildtools-tinygo.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: Build TinyGo -on: - push: - branches: - - main - paths: - - buildtools/tinygo/** - - .github/workflows/buildtools-tinygo.yaml - pull_request: - branches: - - main - paths: - - buildtools/tinygo/** - - .github/workflows/buildtools-tinygo.yaml - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-22.04 - permissions: - contents: read - packages: write - services: - registry: - image: registry:2 - ports: - - 5000:5000 - steps: - - uses: actions/checkout@v3 - - - 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 - with: - driver-opts: network=host - - - uses: docker/metadata-action@v4 - id: meta - with: - images: ghcr.io/${{ github.repository }}/buildtools-tinygo - tags: | - type=schedule - type=ref,event=branch - type=ref,event=tag - type=ref,event=pr - type=sha - - - uses: docker/build-push-action@v3 - with: - context: buildtools/tinygo - file: buildtools/tinygo/wasi-libc.Dockerfile - push: true - platforms: linux/amd64 - tags: localhost:5000/buildtools-tinygo-wasi-libc:main - - - uses: docker/build-push-action@v3 - with: - context: buildtools/tinygo - push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64,linux/arm64 - build-args: WASI_LIBC_IMAGE=localhost:5000/buildtools-tinygo-wasi-libc:main - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 79c4427..3543394 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,8 +13,7 @@ on: env: GO_VERSION: 1.19 - TINYGO_VERSION: 0.26.0 - WABT_VERSION: 1.0.29 + TINYGO_VERSION: 0.27.0 # Test against latest two releases and latest dev ENVOY_IMAGES: > envoyproxy/envoy:v1.24-latest diff --git a/.github/workflows/nightly-coraza-check.yaml b/.github/workflows/nightly-coraza-check.yaml index 22a2adb..bd0d560 100644 --- a/.github/workflows/nightly-coraza-check.yaml +++ b/.github/workflows/nightly-coraza-check.yaml @@ -9,8 +9,7 @@ on: env: GO_VERSION: 1.19 - TINYGO_VERSION: 0.26.0 - WABT_VERSION: 1.0.29 + TINYGO_VERSION: 0.27.0 jobs: test: @@ -25,15 +24,11 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: true - - name: Install TinyGo and wabt + - name: Install TinyGo run: | gh release download v${TINYGO_VERSION} -p '*.linux-amd64.tar.gz' -D ~ -R github.com/tinygo-org/tinygo tar -xf ~/tinygo${TINYGO_VERSION}.linux-amd64.tar.gz -C $HOME echo "$HOME/tinygo/bin" >> $GITHUB_PATH - - gh release download ${WABT_VERSION} -p '*-ubuntu.tar.gz' -D ~ -R github.com/WebAssembly/wabt - tar -xf ~/wabt-${WABT_VERSION}-ubuntu.tar.gz -C $HOME - echo "$HOME/wabt-${WABT_VERSION}/bin" >> $GITHUB_PATH env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/buildtools/tinygo/Dockerfile b/buildtools/tinygo/Dockerfile deleted file mode 100644 index e730bd0..0000000 --- a/buildtools/tinygo/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2022 The OWASP Coraza contributors -# SPDX-License-Identifier: Apache-2.0 - -ARG WASI_LIBC_IMAGE -FROM --platform=linux/amd64 ${WASI_LIBC_IMAGE:-ghcr.io/corazawaf/coraza-proxy-wasm/buildtools-tinygo-wasi-libc:main} AS wasi-libc - -FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-19 - -ARG TARGETARCH - -RUN apt-get update && apt-get install -y curl -RUN curl -L https://go.dev/dl/go1.19.2.linux-${TARGETARCH:-amd64}.tar.gz | tar -xz - -ENV PATH /go/bin:/root/go/bin:$PATH -ENV GOROOT /go - -RUN apt-get update && apt-get install -y libclang-15-dev wabt binaryen - -COPY --from=wasi-libc /tinygo /tinygo -WORKDIR /tinygo -RUN go install diff --git a/buildtools/tinygo/wasi-libc.Dockerfile b/buildtools/tinygo/wasi-libc.Dockerfile deleted file mode 100644 index 7374194..0000000 --- a/buildtools/tinygo/wasi-libc.Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 The OWASP Coraza contributors -# SPDX-License-Identifier: Apache-2.0 - -FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-19 - -RUN apt-get update && apt-get install -y git - -RUN git clone https://github.com/tinygo-org/tinygo --branch dev -WORKDIR /tinygo -# https://github.com/tinygo-org/tinygo/commit/47ca1c037baaa137aeb7387454a9c244d4168896 -RUN git fetch origin dev && git reset --hard 47ca1c037baaa137aeb7387454a9c244d4168896 -RUN git submodule update --init lib/wasi-libc -RUN make wasi-libc diff --git a/magefiles/magefile.go b/magefiles/magefile.go index 7fbc2e4..925fe9e 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -20,7 +20,7 @@ import ( ) var minGoVersion = "1.19" -var tinygoMinorVersion = "0.26" +var tinygoMinorVersion = "0.27" var addLicenseVersion = "04bfe4ee9ca5764577b029acc6a1957fd1997153" // https://github.com/google/addlicense var golangCILintVer = "v1.48.0" // https://github.com/golangci/golangci-lint/releases var gosImportsVer = "v0.3.1" // https://github.com/rinchsan/gosimports/releases/tag/v0.3.1 @@ -185,16 +185,7 @@ func Build() error { } } - wd, err := os.Getwd() - if err != nil { - return err - } - - script := fmt.Sprintf(` -cd /src && \ -tinygo build -gc=custom -opt=2 -o %s -scheduler=none -target=wasi %s`, filepath.Join("build", "mainraw.wasm"), buildTagArg) - if err := sh.RunV("docker", "run", "--pull=always", "--rm", "-v", fmt.Sprintf("%s:/src", wd), "ghcr.io/corazawaf/coraza-proxy-wasm/buildtools-tinygo:sha-96443bb", - "bash", "-c", script); err != nil { + if err := sh.RunV("tinygo", "build", "-gc=custom", "-opt=2", "-o", filepath.Join("build", "mainraw.wasm"), "-scheduler=none", "-target=wasi", buildTagArg); err != nil { return err }