Skip to content

fix(wash-cli): improve tests for help usage #13

fix(wash-cli): improve tests for help usage

fix(wash-cli): improve tests for help usage #13

name: example-providers
on:
merge_group:
push:
branches:
- main
pull_request:
branches: [main]
paths:
- .github/workflows/examples-providers.yml
- crates/wash-lib/**
- crates/wash-cli/**
- examples/rust/providers/**
- examples/golang/providers/**
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build-wash-cli:
name: build wash-cli
runs-on: ubuntu-22.04
strategy:
matrix:
wash-version:
- 0.37.0
- current
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
if: ${{ matrix.wash-version == 'current' }}
- run: rustup show
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
with:
shared-key: "ubuntu-22.04-shared-cache"
- name: install wash (previous version)
if: ${{ matrix.wash-version != 'current' }}
uses: taiki-e/install-action@2c3c8dfabf5933531aca0613c6b0c173fa51745e
with:
tool: wash-cli@${{ matrix.wash-version }}
- name: build wash (current)
if: ${{ matrix.wash-version == 'current' }}
run: cargo build -p wash-cli --release
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
if: ${{ matrix.wash-version == 'current' }}
with:
name: wash-${{ matrix.wash-version }}
path: ./target/release/wash
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
if: ${{ matrix.wash-version != 'current' }}
with:
name: wash-${{ matrix.wash-version }}
path: ~/.cargo/bin/wash
# Ensure that `wash build` and `wash app validate` works for all example projects below
wash-build:
name: example-provider-build
runs-on: ubuntu-22.04
needs: [build-wash-cli]
strategy:
fail-fast: false
matrix:
wash-version:
- 0.37.0
- current
project:
# Golang example providers
- name: "custom-template"
lang: "golang"
lang_version: "1.23"
tinygo_version: "0.33.0"
test_deploy: wadm.yaml
# Rust example providers
- name: "custom-template"
lang: "rust"
test_deploy: wadm.yaml
- name: "messaging-nats"
lang: "rust"
test_deploy: local.wadm.yaml
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
# Download wash binary & install to path
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: wash-${{ matrix.wash-version }}
path: artifacts
- name: install wash binary to PATH # Some build tools expect wash to be on the PATH
shell: bash
run: |
chmod +x ./artifacts/wash;
echo "$(realpath ./artifacts)" >> "$GITHUB_PATH";
# Language specific setup
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
if: ${{ matrix.project.lang == 'golang' }}
with:
go-version: ${{ matrix.project.lang_version }}
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7
if: ${{ matrix.project.lang == 'golang' }}
with:
tinygo-version: ${{ matrix.project.tinygo_version }}
install-binaryen: "false"
- name: install wit-bindgen-wrpc
shell: bash
run: |
curl -LO https://github.com/bytecodealliance/wrpc/releases/download/v0.11.1/wit-bindgen-wrpc-x86_64-unknown-linux-musl;
echo "7ae7607987a208eda2a44a0dfc376ebf681321443151589a0f0004f53da43258 wit-bindgen-wrpc-x86_64-unknown-linux-musl" | sha256sum -c -;
mv wit-bindgen-wrpc-x86_64-unknown-linux-musl wit-bindgen-wrpc
chmod +x wit-bindgen-wrpc
install -m 755 wit-bindgen-wrpc /usr/local/bin/
# Validate example [local.]wadm.yaml if present
- name: validate wadm.yaml
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
shell: bash
run: |
[[ ! -f wadm.yaml ]] || wash app validate wadm.yaml
[[ ! -f local.wadm.yaml ]] || wash app validate local.wadm.yaml
# Build example project(s)
- name: build project
run: wash build
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
# Install wit-bindgen
- uses: taiki-e/install-action@2c3c8dfabf5933531aca0613c6b0c173fa51745e
with:
tool: wit-bindgen-cli
# Build required project if necessary
- name: Build dependent component if present
shell: bash
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
run: |
if [[ -f component/wasmcloud.toml ]]; then
wash build -p component/wasmcloud.toml;
fi
# Run the local.wadm that comes with the example
- name: test provider load
if: ${{ matrix.project.test_deploy && matrix.wash-version == 'current' }}
shell: bash
working-directory: examples/${{ matrix.project.lang }}/providers/${{ matrix.project.name }}
run: |
set -xe
wash up &
WASH_PID=$!
sleep 4;
wash app deploy ${{ matrix.project.test_deploy }};
TRIES=0
while [[ $(wash get inventory --output=json | jq '.inventories[0].providers | length') -eq 0 ]] ; do
if [[ $TRIES -gt 10 ]]; then
echo "❌ failed to find provider in inventory output after deploying example manifest";
exit -1;
fi
TRIES=$((TRIES+1));
sleep 1;
done;
echo "✅ successfully started at least one provider";
wash app delete ${{ matrix.project.test_deploy }};
kill $WASH_PID;
exit 0;