From 0777e2e72727d74f7e2c20e7b98079cacfdf697b Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Wed, 11 Feb 2026 16:14:22 -0800 Subject: [PATCH] Add e2e test Signed-off-by: Kate Goldenring --- .github/workflows/e2e.yml | 35 +++++++++++++++++++++++++++++++++++ test/e2e.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/e2e.yml create mode 100755 test/e2e.sh diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..f78a422 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,35 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: End-to-End Tests +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + e2e-test: + name: E2E Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: 1.87 + targets: wasm32-wasip2 + + - name: Install Spin + shell: bash + run: | + curl -fsSL https://spinframework.dev/downloads/install.sh | bash -s -- -v v3.6.0 + mv spin /usr/local/bin/ + + - name: Install pluginify + shell: bash + run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes + + - name: Run E2E tests + run: ./test/e2e.sh diff --git a/test/e2e.sh b/test/e2e.sh new file mode 100755 index 0000000..d065eee --- /dev/null +++ b/test/e2e.sh @@ -0,0 +1,37 @@ +#! /bin/bash + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +# Create random temporary directory for logs +LOG_DIR=$(mktemp -d) + +# 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" + exit 1 +fi +echo -e "${GREEN}✓ Spin is available${NC}" + +# Build and install the plugin +echo -e "\n${GREEN}Building and installing the command trigger plugin...${NC}" +cargo build --release +spin pluginify --install + +spin up --from examples/hello-world --quiet --log-dir "$LOG_DIR" + +# Assert that the contents of stdout is `Hello, world!` +OUTPUT=$(cat "$LOG_DIR/hello-world_stdout.txt") +if [[ "$OUTPUT" == "Hello, world!" ]]; then + echo -e "${GREEN}✓ Output is correct${NC}" +else + echo -e "${RED}✗ Output is incorrect${NC}" + echo "Expected: Hello, world!" + echo "Got: $OUTPUT" + exit 1 +fi + +rm -rf "$LOG_DIR" \ No newline at end of file