diff --git a/.github/actions/libextism/action.yml b/.github/actions/libextism/action.yml new file mode 100644 index 0000000..cd36dc2 --- /dev/null +++ b/.github/actions/libextism/action.yml @@ -0,0 +1,15 @@ +on: [workflow_call] + +name: libextism + +runs: + using: composite + steps: + - uses: actions/checkout@v3 + with: + repository: extism/cli + path: .extism-cli + - uses: ./.extism-cli/.github/actions/extism-cli + - name: Install + shell: bash + run: sudo extism lib install --version git diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..afbf875 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: CI +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + test-example: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/libextism + + - name: Install WASI SDK + run: | + bash install-wasi-sdk.sh + echo '$WASI_SDK_PATH="'$(pwd)'"/wasi-sdk' >> $GITHUB_ENV + + - name: Example + run: | + cd examples/count-vowels + TEST=$(make run) + echo $TEST | grep '"count": 4' + + + - name: Tests + if: matrix.os != 'macos-latest' + run: | + cd tests + make test diff --git a/install-wasi-sdk.sh b/install-wasi-sdk.sh new file mode 100755 index 0000000..5046e2b --- /dev/null +++ b/install-wasi-sdk.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Orignal from: https://github.com/Shopify/javy + +set -euo pipefail + +PATH_TO_SDK="./wasi-sdk" +if [[ ! -d $PATH_TO_SDK ]]; then + TMPGZ=$(mktemp) + VERSION_MAJOR="22" + VERSION_MINOR="0" + if [[ "$(uname -s)" == "Darwin" ]]; then + curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-macos.tar.gz --output $TMPGZ + else + curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-linux.tar.gz --output $TMPGZ + fi + mkdir $PATH_TO_SDK + tar xf $TMPGZ -C $PATH_TO_SDK --strip-components=1 +fi