Skip to content

Commit 9302dec

Browse files
Add e2e test
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
1 parent 0ebab21 commit 9302dec

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

.github/workflows/e2e.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: End-to-End Tests
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
e2e-test:
12+
name: E2E Test
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@stable
20+
with:
21+
toolchain: 1.90
22+
targets: wasm32-wasip2
23+
24+
- name: Install Spin
25+
shell: bash
26+
run: |
27+
curl -fsSL https://spinframework.dev/downloads/install.sh | bash -s -- -v v3.6.0
28+
mv spin /usr/local/bin/
29+
30+
- name: Install pluginify
31+
shell: bash
32+
run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes
33+
34+
- name: Run E2E tests
35+
run: ./test/e2e.sh

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "trigger-command"
33
version = { workspace = true }
44
authors = { workspace = true }
55
edition = { workspace = true }
6-
rust-version = "1.87"
6+
rust-version = "1.90"
77

88
[workspace.package]
99
version = "0.5.1"

test/e2e.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#! /bin/bash
2+
3+
# Colors for output
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
NC='\033[0m' # No Color
7+
8+
# Create random temporary directory for logs
9+
LOG_DIR=$(mktemp -d)
10+
11+
# Check if spin is available
12+
if ! command -v spin &> /dev/null; then
13+
echo -e "${RED}Error: Spin is not installed${NC}"
14+
echo "Please install Spin: https://developer.fermyon.com/spin/install"
15+
exit 1
16+
fi
17+
echo -e "${GREEN}✓ Spin is available${NC}"
18+
19+
# Build and install the plugin
20+
echo -e "\n${GREEN}Building and installing the command trigger plugin...${NC}"
21+
cargo build --release
22+
spin pluginify --install
23+
24+
spin build --up --from examples/hello-world --quiet --log-dir "$LOG_DIR"
25+
26+
# Assert that the contents of stdout is `Hello, world!`
27+
OUTPUT=$(cat "$LOG_DIR/hello-world_stdout.txt")
28+
if [[ "$OUTPUT" == "Hello, world!" ]]; then
29+
echo -e "${GREEN}✓ Output is correct${NC}"
30+
else
31+
echo -e "${RED}✗ Output is incorrect${NC}"
32+
echo "Expected: Hello, world!"
33+
echo "Got: $OUTPUT"
34+
exit 1
35+
fi
36+
37+
rm -rf "$LOG_DIR"

0 commit comments

Comments
 (0)