From a94dced1827dcc445050cbda8c3df26039316619 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Thu, 21 May 2026 14:01:16 -0600 Subject: [PATCH 1/3] ci(.github): add e2e-sqs.yml; adjust e2e-test.sh, guest/src/lib.rs Signed-off-by: Vaughn Dice --- .github/workflows/e2e-sqs.yml | 60 +++++++++++++++++++++++++ crates/trigger-sqs/e2e-test/e2e-test.sh | 25 ++++++----- examples/sqs-rust-guest/src/lib.rs | 2 +- 3 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/e2e-sqs.yml diff --git a/.github/workflows/e2e-sqs.yml b/.github/workflows/e2e-sqs.yml new file mode 100644 index 0000000..541abd2 --- /dev/null +++ b/.github/workflows/e2e-sqs.yml @@ -0,0 +1,60 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: trigger-sqs E2E Tests +on: + push: + branches: [main] + paths: + - 'crates/trigger-sqs/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/e2e-sqs.yml' + pull_request: + branches: [main] + paths: + - 'crates/trigger-sqs/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/e2e-sqs.yml' + +jobs: + e2e-test: + name: E2E Test with ElasticMQ + runs-on: ubuntu-latest + defaults: + run: + working-directory: crates/trigger-sqs + steps: + - uses: actions/checkout@v3 + + - name: Start ElasticMQ + run: make setup-elasticmq + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.93" + targets: wasm32-wasip2 + + - name: Install Spin + # TODO: bump to v1 once available; see https://github.com/spinframework/actions/issues/20 + uses: spinframework/actions/spin/setup@06319d3612303cb558fabe9b13cc0d7256d0aeb9 + with: + version: v4.0.0 + plugins: pluginify + + - name: Run E2E tests + env: + SQS_ENDPOINT: http://localhost:9324 + AWS_DEFAULT_REGION: us-east-1 + AWS_ACCESS_KEY_ID: test + AWS_SECRET_ACCESS_KEY: test + AWS_SESSION_TOKEN: test + run: make test-e2e + + - name: Upload logs on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: spin-logs + path: guest/.spin/logs/* diff --git a/crates/trigger-sqs/e2e-test/e2e-test.sh b/crates/trigger-sqs/e2e-test/e2e-test.sh index a8befb3..f0d6e4f 100755 --- a/crates/trigger-sqs/e2e-test/e2e-test.sh +++ b/crates/trigger-sqs/e2e-test/e2e-test.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' @@ -10,13 +12,14 @@ NC='\033[0m' # No Color # Configuration SQS_ENDPOINT="${SQS_ENDPOINT:-http://localhost:9324}" TEST_QUEUE_NAME="${TEST_QUEUE_NAME:-test-queue}" -SPIN_OUTPUT_LOG="guest/.spin/logs/localtest_stdout.txt" +APP_DIR="${SCRIPT_DIR}/../../../examples/sqs-rust-guest" +SPIN_OUTPUT_LOG="${APP_DIR}/.spin/logs/localtest_stdout.txt" SPIN_PID="" MESSAGE="test-value" MESSAGE_BODY="Test message from e2e test" ATTRIBUTE_NAME="glonk" -rm -rf guest/.spin +rm -rf ${APP_DIR}/.spin export AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-us-east-1}" @@ -71,7 +74,7 @@ echo -e "${GREEN}✓ AWS CLI is available${NC}" # Check if spin is available if ! command -v spin &> /dev/null; then echo -e "${RED}Error: Spin is not installed${NC}" - echo "Please install Spin: https://developer.fermyon.com/spin/install" + echo "Please install Spin: https://spinframework.dev/install" exit 1 fi echo -e "${GREEN}✓ Spin is available${NC}" @@ -98,26 +101,26 @@ fi echo -e "${GREEN}✓ Queue created: $QUEUE_URL${NC}" -# Update guest/spin.toml with the queue URL -echo -e "\n${GREEN}Updating guest/spin.toml with queue URL...${NC}" +# Update ${APP_DIR}/spin.toml with the queue URL +echo -e "\n${GREEN}Updating ${APP_DIR}/spin.toml with queue URL...${NC}" # Backup original spin.toml -cp guest/spin.toml guest/spin.toml.backup +cp ${APP_DIR}/spin.toml ${APP_DIR}/spin.toml.backup # Replace queue_url if [[ "$OSTYPE" == "darwin"* ]]; then # macOS sed syntax - sed -i '' "s|queue_url = \".*\"|queue_url = \"$QUEUE_URL\"|g" guest/spin.toml + sed -i '' "s|queue_url = \".*\"|queue_url = \"$QUEUE_URL\"|g" ${APP_DIR}/spin.toml else # Linux sed syntax - sed -i "s|queue_url = \".*\"|queue_url = \"$QUEUE_URL\"|g" guest/spin.toml + sed -i "s|queue_url = \".*\"|queue_url = \"$QUEUE_URL\"|g" ${APP_DIR}/spin.toml fi echo -e "${GREEN}✓ Updated spin.toml${NC}" # Build the guest application echo -e "\n${GREEN}Building guest application...${NC}" -spin build --from guest +spin build --from ${APP_DIR} echo -e "${GREEN}✓ Guest application built${NC}" # Start Spin application @@ -125,7 +128,7 @@ echo -e "\n${GREEN}Starting Spin application...${NC}" AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION" \ AWS_ENDPOINT_URL="$SQS_ENDPOINT" \ AWS_ENDPOINT_URL_SQS="$SQS_ENDPOINT" \ -spin up --from guest & +spin up --from ${APP_DIR} & SPIN_PID=$! echo "Spin started with PID: $SPIN_PID" @@ -157,7 +160,7 @@ echo "Waiting for message to be processed..." sleep 15 # Restore original spin.toml -mv guest/spin.toml.backup guest/spin.toml +mv ${APP_DIR}/spin.toml.backup ${APP_DIR}/spin.toml # Verify output echo -e "\n${GREEN}Verifying output...${NC}" diff --git a/examples/sqs-rust-guest/src/lib.rs b/examples/sqs-rust-guest/src/lib.rs index fcd47d3..59a1025 100644 --- a/examples/sqs-rust-guest/src/lib.rs +++ b/examples/sqs-rust-guest/src/lib.rs @@ -1,6 +1,6 @@ wit_bindgen::generate!({ world: "spin-sqs", - path: "../sqs3.wit", + path: "../../crates/trigger-sqs/sqs3.wit", }); use spin::sqs::sqs_types as sqs; From 96bea862a0a10807d40e08d8dd92ea24041dcd35 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Thu, 21 May 2026 16:04:21 -0600 Subject: [PATCH 2/3] ci(.github): add e2e-mqtt.yml, update test and guest to suit Signed-off-by: Vaughn Dice --- .github/workflows/e2e-mqtt.yml | 46 +++++++++++++++++++ crates/trigger-mqtt/tests/integration_test.sh | 5 +- examples/mqtt-rust-guest/Cargo.toml | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/e2e-mqtt.yml diff --git a/.github/workflows/e2e-mqtt.yml b/.github/workflows/e2e-mqtt.yml new file mode 100644 index 0000000..a3bf329 --- /dev/null +++ b/.github/workflows/e2e-mqtt.yml @@ -0,0 +1,46 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: trigger-mqtt E2E Tests +on: + push: + branches: [main] + paths: + - 'crates/trigger-mqtt/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/e2e-mqtt.yml' + pull_request: + branches: [main] + paths: + - 'crates/trigger-mqtt/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/e2e-mqtt.yml' + +jobs: + e2e-test: + name: E2E test + runs-on: ubuntu-latest + defaults: + run: + working-directory: crates/trigger-mqtt + steps: + - uses: actions/checkout@v6 + + - name: Install rust target for example app + run: rustup target add wasm32-wasip2 + + - name: Install Spin + # TODO: bump to v1 once available; see https://github.com/spinframework/actions/issues/20 + uses: spinframework/actions/spin/setup@06319d3612303cb558fabe9b13cc0d7256d0aeb9 + with: + version: v4.0.0 + plugins: pluginify + + - name: Install mqttx-cli + run: | + curl -LO https://www.emqx.com/en/downloads/MQTTX/v1.13.0/mqttx-cli-linux-x64 + sudo install ./mqttx-cli-linux-x64 /usr/local/bin/mqttx + + - name: Run integration test + run: make test \ No newline at end of file diff --git a/crates/trigger-mqtt/tests/integration_test.sh b/crates/trigger-mqtt/tests/integration_test.sh index 533a7a3..069b859 100755 --- a/crates/trigger-mqtt/tests/integration_test.sh +++ b/crates/trigger-mqtt/tests/integration_test.sh @@ -4,6 +4,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +APP_DIR="${PROJECT_DIR}/../../examples/mqtt-rust-guest" MQTT_CONTAINER_NAME="emqx-test" MQTT_HOST="localhost" MQTT_PORT="1883" @@ -132,8 +133,8 @@ start_spin_app() { SPIN_LOGS_STDOUT="$SPIN_LOG_DIR/mqtt-c01_stdout.txt" # Build and start the example app in background, capturing output - spin build --from examples/mqtt-app/spin.toml - spin up --from examples/mqtt-app/spin.toml --log-dir "$SPIN_LOG_DIR" & + spin build --from ${APP_DIR}/spin.toml + spin up --from ${APP_DIR}/spin.toml --log-dir "$SPIN_LOG_DIR" & SPIN_PID=$! log "Waiting for Spin application to start..." diff --git a/examples/mqtt-rust-guest/Cargo.toml b/examples/mqtt-rust-guest/Cargo.toml index 05f5f40..5f6d650 100755 --- a/examples/mqtt-rust-guest/Cargo.toml +++ b/examples/mqtt-rust-guest/Cargo.toml @@ -11,7 +11,7 @@ crate-type = [ "cdylib" ] [dependencies] anyhow = "1" chrono = "*" -spin-mqtt-sdk = { path = "../../sdk" } +spin-mqtt-sdk = { path = "../../crates/trigger-mqtt/sdk" } [workspace] From 63731d06d5940770a207f575784165b8a4766a86 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Thu, 21 May 2026 16:05:10 -0600 Subject: [PATCH 3/3] ci(.github): add e2e-command.yml, update e2e.sh Signed-off-by: Vaughn Dice --- .github/workflows/e2e-command.yml | 44 ++++++++++++++++++++++++++++++ crates/trigger-command/test/e2e.sh | 5 +++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/e2e-command.yml diff --git a/.github/workflows/e2e-command.yml b/.github/workflows/e2e-command.yml new file mode 100644 index 0000000..6fb98f0 --- /dev/null +++ b/.github/workflows/e2e-command.yml @@ -0,0 +1,44 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: trigger-command E2E Tests +on: + push: + branches: [main] + paths: + - 'crates/trigger-command/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/e2e-command.yml' + pull_request: + branches: [main] + paths: + - 'crates/trigger-command/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/e2e-command.yml' + +jobs: + e2e-test: + name: E2E Test + runs-on: ubuntu-latest + defaults: + run: + working-directory: crates/trigger-command + steps: + - uses: actions/checkout@v6 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: 1.93 + targets: wasm32-wasip2 + + - name: Install Spin + # TODO: bump to v1 once available; see https://github.com/spinframework/actions/issues/20 + uses: spinframework/actions/spin/setup@06319d3612303cb558fabe9b13cc0d7256d0aeb9 + with: + version: v4.0.0 + plugins: pluginify + + - name: Run E2E tests + run: ./test/e2e.sh diff --git a/crates/trigger-command/test/e2e.sh b/crates/trigger-command/test/e2e.sh index 5ebc66d..03af101 100755 --- a/crates/trigger-command/test/e2e.sh +++ b/crates/trigger-command/test/e2e.sh @@ -5,6 +5,9 @@ RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +APP_DIR="${SCRIPT_DIR}/../../../examples/command-rust-guest-hello" + # Create random temporary directory for logs LOG_DIR=$(mktemp -d) @@ -21,7 +24,7 @@ echo -e "\n${GREEN}Building and installing the command trigger plugin...${NC}" cargo build --release spin pluginify --install -spin build --up --from examples/hello-world --quiet --log-dir "$LOG_DIR" +spin build --up --from "${APP_DIR}" --quiet --log-dir "$LOG_DIR" # Assert that the contents of stdout is `Hello, world!` OUTPUT=$(cat "$LOG_DIR/hello-world_stdout.txt")