1+ name : Test Function Runner
2+
3+ on :
4+ pull_request :
5+ branches : ["main"]
6+ paths :
7+ - " functions-*-rs/**"
8+ - " .github/workflows/test-function-runner.yml"
9+
10+ env :
11+ CARGO_TERM_COLOR : always
12+
13+ jobs :
14+ test-function-runner :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v3
18+
19+ - name : Step 1 - Install function-runner
20+ run : |
21+ echo "Installing function-runner..."
22+ cargo install --git https://github.com/Shopify/function-runner.git function-runner --locked
23+
24+ - name : Step 2 - Test function-runner installation
25+ run : |
26+ echo "Testing function-runner installation..."
27+ function-runner --help
28+
29+ - name : Step 3 - Show available functions
30+ run : |
31+ echo "Available Rust functions:"
32+ ls -la functions-*-rs/ | head -5
33+
34+ - name : Step 4 - Expand liquid templates
35+ run : |
36+ echo "Expanding liquid templates..."
37+ yarn
38+ CI=1 yarn expand-liquid rust
39+
40+ - name : Step 5 - Build one function
41+ run : |
42+ echo "Building functions-cart-checkout-validation-rs..."
43+ cd functions-cart-checkout-validation-rs
44+ cargo build --target wasm32-wasip1 --profile=wasm --features trampoline
45+
46+ - name : Step 6 - Post-process with wasm-opt
47+ run : |
48+ echo "Installing wasm-opt..."
49+ cargo install wasm-opt --locked
50+ echo "Optimizing WASM..."
51+ wasm_file=$(find target/wasm32-wasip1/wasm -name "*.wasm" | head -1)
52+ if [ -f "$wasm_file" ]; then
53+ wasm-opt --enable-bulk-memory --strip-debug "$wasm_file" -o "${wasm_file%.wasm}-optimized.wasm"
54+ fi
55+
56+ - name : Step 7 - Find built WASM file
57+ run : |
58+ echo "Looking for built WASM file..."
59+ find . -name "*.wasm" -type f
60+ echo "Specifically looking in target/wasm32-wasip1/wasm/:"
61+ ls -la target/wasm32-wasip1/wasm/ || echo "wasm directory not found"
62+
63+ - name : Step 8 - Test with empty input
64+ run : |
65+ echo "Testing with empty input..."
66+ echo '{}' > empty_input.json
67+ wasm_file=$(find . -name "*.wasm" -type f | head -1)
68+ if [ -f "$wasm_file" ]; then
69+ echo "Found WASM file: $wasm_file"
70+ echo "Running function-runner..."
71+ function-runner -f "$wasm_file" -i empty_input.json || echo "Function runner failed, continuing..."
72+ else
73+ echo "No WASM file found"
74+ fi
0 commit comments