Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/e2e.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can roll this action into the existing matrix and only test it on one OS? That would save having to build the plugin one extra time.

Original file line number Diff line number Diff line change
@@ -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.90
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "trigger-command"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
rust-version = "1.87"
rust-version = "1.90"

[workspace.package]
version = "0.5.1"
Expand Down
37 changes: 37 additions & 0 deletions test/e2e.sh
Original file line number Diff line number Diff line change
@@ -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 build --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"