chore: exclude text files from cache #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: example-components | |
on: | |
merge_group: | |
push: | |
branches: | |
- main | |
tags: | |
- component-blobby-v[0-9]+.[0-9]+.[0-9]+* | |
- component-dog-fetcher-v[0-9]+.[0-9]+.[0-9]+* | |
- component-echo-messaging-v[0-9]+.[0-9]+.[0-9]+* | |
- component-ferris-says-v[0-9]+.[0-9]+.[0-9]+* | |
- component-http-blobstore-v[0-9]+.[0-9]+.[0-9]+* | |
- component-http-hello-world-v[0-9]+.[0-9]+.[0-9]+* | |
- component-http-jsonify-v[0-9]+.[0-9]+.[0-9]+* | |
- component-http-keyvalue-counter-v[0-9]+.[0-9]+.[0-9]+* | |
- component-keyvalue-messaging-v[0-9]+.[0-9]+.[0-9]+* | |
- component-sqldb-postgres-query-v[0-9]+.[0-9]+.[0-9]+* | |
- component-http-task-manager-v[0-9]+.[0-9]+.[0-9]+* | |
pull_request: | |
branches: [main] | |
paths: | |
- .github/workflows/examples-components.yml | |
- crates/wash-lib/** | |
- crates/wash-cli/** | |
- examples/rust/components/** | |
- examples/golang/components/** | |
- examples/python/components/** | |
- examples/typescript/components/** | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ 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.34.1 | |
- current | |
steps: | |
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 | |
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@42f4ec8e42bf7fe4dadd39bfc534566095a8edff | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | |
if: ${{ matrix.wash-version == 'current' }} | |
with: | |
name: wash-${{ matrix.wash-version }} | |
path: ./target/release/wash | |
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | |
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: build | |
runs-on: ubuntu-22.04 | |
needs: [build-wash-cli] | |
strategy: | |
fail-fast: false | |
matrix: | |
wash-version: | |
- 0.34.1 | |
- current | |
project: | |
# Golang example components | |
- lang: "golang" | |
lang_version: "1.20" | |
name: "http-echo-tinygo" | |
test_deploy: wadm.yaml | |
- lang: "golang" | |
lang_version: "1.20" | |
name: "http-hello-world" | |
test_deploy: wadm.yaml | |
- name: "sqldb-postgres-query" | |
lang: "golang" | |
wasm-bin: "sqldb_postgres_query_s.wasm" | |
test_deploy: local.wadm.yaml | |
# Rust example components | |
- name: "blobby" | |
lang: "rust" | |
wasm-bin: "blobby_s.wasm" | |
- name: "dog-fetcher" | |
lang: "rust" | |
wasm-bin: "dog_fetcher_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "echo-messaging" | |
lang: "rust" | |
wasm-bin: "echo_messaging_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "ferris-says" | |
lang: "rust" | |
wasm-bin: "ferris_says_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "http-blobstore" | |
lang: "rust" | |
wasm-bin: "http_blobstore_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "http-hello-world" | |
lang: "rust" | |
wasm-bin: "http_hello_world_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "http-jsonify" | |
lang: "rust" | |
wasm-bin: "http_jsonify_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "http-keyvalue-counter" | |
lang: "rust" | |
wasm-bin: "http_keyvalue_counter_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "keyvalue-messaging" | |
lang: "rust" | |
wasm-bin: "keyvalue_messaging_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "sqldb-postgres-query" | |
lang: "rust" | |
wasm-bin: "sqldb_postgres_query_s.wasm" | |
test_deploy: local.wadm.yaml | |
- name: "http-task-manager" | |
lang: "rust" | |
wasm-bin: "http_task_manager_s.wasm" | |
test_deploy: local.wadm.yaml | |
# Python example components | |
- name: "http-hello-world" | |
lang: "python" | |
lang_version: "3.10" | |
# Typescript example components | |
- name: "http-hello-world" | |
lang: "typescript" | |
lang_version: "20.x" | |
test_deploy: wadm.yaml | |
steps: | |
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 | |
# 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@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 | |
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: "0.30.0" | |
install-binaryen: "false" | |
- uses: taiki-e/install-action@42f4ec8e42bf7fe4dadd39bfc534566095a8edff | |
if: ${{ matrix.project.lang == 'golang' }} | |
with: | |
tool: wit-bindgen-cli | |
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 | |
if: ${{ matrix.project.lang == 'python' }} | |
with: | |
python-version: ${{ matrix.project.lang_version }} | |
- name: install python reqs | |
if: ${{ matrix.project.lang == 'python' }} | |
run: | | |
pip install componentize-py | |
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 | |
if: ${{ matrix.project.lang == 'typescript' }} | |
with: | |
node-version: ${{ matrix.project.lang_version }} | |
- name: install node reqs | |
if: ${{ matrix.project.lang == 'typescript' }} | |
run: | | |
npm install -g @bytecodealliance/jco | |
npm install -g @bytecodealliance/componentize-js | |
# Validate example [local.]wadm.yaml if present | |
- name: validate wadm.yaml | |
working-directory: examples/${{ matrix.project.lang }}/components/${{ 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 }}/components/${{ matrix.project.name }} | |
# Run the local.wadm that comes with the example | |
- name: test component load | |
if: ${{ matrix.project.test_deploy && matrix.wash-version == 'current' }} | |
shell: bash | |
working-directory: examples/${{ matrix.project.lang }}/components/${{ matrix.project.name }} | |
run: | | |
set -xe | |
wash up & | |
WASH_PID=$! | |
sleep 3; | |
wash app deploy ${{ matrix.project.test_deploy }}; | |
TRIES=0 | |
while [[ $(wash get inventory --output=json | jq '.inventories[0].components | length') -eq 0 ]] ; do | |
if [[ $TRIES -gt 10 ]]; then | |
echo "❌ failed to find component in inventory output after deploying example manifest"; | |
exit -1; | |
fi | |
TRIES=$((TRIES+1)); | |
sleep 1; | |
done; | |
echo "✅ successfully started at least one component"; | |
wash app delete ${{ matrix.project.test_deploy }}; | |
kill $WASH_PID; | |
exit 0; | |
# Save example as an artifact for later step(s) | |
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | |
if: ${{ startswith(github.ref, format('refs/tags/component-{0}-v', matrix.project.name)) }} | |
with: | |
name: wash-build-${{ matrix.wash-version }}-${{ matrix.project.lang }}-component-${{ matrix.project.name }} | |
path: examples/${{ matrix.project.lang }}/components/${{ matrix.project.name }}/build/${{ matrix.project.wasm-bin }} | |
# Publish components relevant components if they've been tagged | |
publish: | |
name: publish | |
runs-on: ubuntu-22.04 | |
needs: [wash-build] | |
if: ${{ startswith(github.ref, 'refs/tags/component-') }} | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
wash-version: | |
- 0.34.1 | |
project: | |
# Go example components (to publish) | |
- lang: "golang" | |
lang_version: "1.20" | |
name: "http-echo-tinygo" | |
- lang: "golang" | |
lang_version: "1.20" | |
name: "http-hello-world" | |
# Rust example components (to publish) | |
- name: "blobby" | |
lang: "rust" | |
wasm-bin: "blobby_s.wasm" | |
- name: "dog-fetcher" | |
lang: "rust" | |
wasm-bin: "dog_fetcher_s.wasm" | |
- name: "echo-messaging" | |
lang: "rust" | |
wasm-bin: "echo_messaging_s.wasm" | |
- name: "ferris-says" | |
lang: "rust" | |
wasm-bin: "ferris_says_s.wasm" | |
- name: "http-blobstore" | |
lang: "rust" | |
wasm-bin: "http_blobstore_s.wasm" | |
- name: "http-hello-world" | |
lang: "rust" | |
wasm-bin: "http_hello_world_s.wasm" | |
- name: "http-jsonify" | |
lang: "rust" | |
wasm-bin: "http_jsonify_s.wasm" | |
- name: "http-keyvalue-counter" | |
lang: "rust" | |
wasm-bin: "http_keyvalue_counter_s.wasm" | |
- name: "keyvalue-messaging" | |
lang: "rust" | |
wasm-bin: "keyvalue_messaging_s.wasm" | |
- name: "sqldb-postgres-query" | |
lang: "rust" | |
wasm-bin: "sqldb_postgres_query_s.wasm" | |
- name: "http-task-manager" | |
lang: "rust" | |
wasm-bin: "http_task_manager_s.wasm" | |
steps: | |
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 | |
# Determine tag version (if this is a release tag), without the 'v' | |
- name: Determine version | |
id: meta | |
shell: bash | |
env: | |
REF: ${{ github.ref }} | |
REF_PREFIX: ${{ format('refs/tags/component-{0}-v', matrix.project.name) }} | |
run: | | |
export VERSION=${REF#$REF_PREFIX}; | |
echo -e "version=${VERSION}" >> $GITHUB_OUTPUT; | |
echo "bin-name=wash-build-${{ matrix.wash-version }}-${{ matrix.project.lang }}-component-${{ matrix.project.name }}/${{ matrix.project.wasm-bin }}" >> $GITHUB_OUTPUT; | |
echo "ref-prefix=$REF_PREFIX" >> $GITHUB_OUTPUT; | |
echo "wasmcloud-toml-path=examples/${{ matrix.project.lang }}/components/${{ matrix.project.name }}/wasmcloud.toml" >> $GITHUB_OUTPUT; | |
# Download all artifacts (wash binary and example component binaries) to work dir | |
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | |
with: | |
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-${{ matrix.wash-version }}/wash; | |
echo "$(realpath ./artifacts/wash-${{ matrix.wash-version }})" >> "$GITHUB_PATH"; | |
# Push the project to GitHub Container Registry under various tags, if this is a release tag | |
- name: Push SHA-tagged WebAssembly binary to GHCR | |
if: ${{ startsWith(github.ref, steps.meta.outputs.ref-prefix) }} | |
env: | |
WASH_REG_USER: ${{ github.repository_owner }} | |
WASH_REG_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
wash push ghcr.io/${{ github.repository_owner }}/components/${{ matrix.project.name }}-${{ matrix.project.lang }}:${{ github.sha }} artifacts/${{ steps.meta.outputs.bin-name }} | |
- name: Push version-tagged WebAssembly binary to GHCR | |
if: ${{ startsWith(github.ref, steps.meta.outputs.ref-prefix) }} | |
env: | |
WASH_REG_USER: ${{ github.repository_owner }} | |
WASH_REG_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
wash push ghcr.io/${{ github.repository_owner }}/components/${{ matrix.project.name }}-${{ matrix.project.lang }}:${{ steps.meta.outputs.version }} artifacts/${{ steps.meta.outputs.bin-name }} | |
# (wasmCloud/wasmCloud repository only) | |
# Push the project to Azure Container Registry under various tags, if this is a release tag | |
- name: Push SHA-tagged WebAssembly binary to AzureCR | |
if: ${{ startsWith(github.ref, steps.meta.outputs.ref-prefix) && github.repository_owner == 'wasmCloud' }} | |
run: | | |
wash push wasmcloud.azurecr.io/${{ github.repository_owner }}/components/${{ matrix.project.name }}-${{ matrix.project.lang }}:${{ github.sha }} artifacts/${{ steps.meta.outputs.bin-name }} | |
env: | |
WASH_REG_USER: ${{ secrets.AZURECR_PUSH_USER }} | |
WASH_REG_PASSWORD: ${{ secrets.AZURECR_PUSH_PASSWORD }} | |
- name: Push version-tagged WebAssembly binary to AzureCR | |
if: ${{ startsWith(github.ref, steps.meta.outputs.ref-prefix) && github.repository_owner == 'wasmCloud' }} | |
run: | | |
wash push wasmcloud.azurecr.io/${{ github.repository_owner }}/components/${{ matrix.project.name }}-${{ matrix.project.lang }}:${{ steps.meta.outputs.version }} artifacts/${{ steps.meta.outputs.bin-name }} | |
env: | |
WASH_REG_USER: ${{ secrets.AZURECR_PUSH_USER }} | |
WASH_REG_PASSWORD: ${{ secrets.AZURECR_PUSH_PASSWORD }} |