diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..f0a0329 --- /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.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 diff --git a/Cargo.toml b/Cargo.toml index 160e0c0..3b70d43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/test/e2e.sh b/test/e2e.sh new file mode 100755 index 0000000..5ebc66d --- /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 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" \ No newline at end of file