Skip to content

Commit 28b6dda

Browse files
authored
Merge pull request #40 from michelleN/examples
build examples
2 parents ddd5ae1 + 1a5f6eb commit 28b6dda

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build Examples
2+
3+
on:
4+
push:
5+
branches: ["main", "v*"]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: ["main", "v*"]
9+
paths-ignore:
10+
- "README.md"
11+
12+
env:
13+
RUST_VERSION: "1.73"
14+
SPIN_VERSION: ""
15+
16+
jobs:
17+
examples:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Install Rust
22+
uses: dtolnay/rust-toolchain@stable
23+
with:
24+
toolchain: "${{ env.RUST_VERSION }}"
25+
targets: wasm32-wasi
26+
- name: Install Spin
27+
uses: fermyon/actions/spin/setup@v1
28+
- name: Run build_examples.sh
29+
run: |
30+
chmod +x scripts/build_examples.sh
31+
scripts/build_examples.sh

scripts/build_examples.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
EXAMPLES_DIR="examples"
4+
5+
if [[ ! -d "$EXAMPLES_DIR" ]]; then
6+
echo "Directory $EXAMPLES_DIR does not exist."
7+
exit 1
8+
fi
9+
10+
for example in "$EXAMPLES_DIR"/*; do
11+
if [[ -d "$example" ]]; then
12+
example_name=$(basename "$example")
13+
14+
# tells GitHub Action to start a new collapsible log section
15+
echo "::group::Building example: $example_name"
16+
17+
# cd into example app directory
18+
cd "$example" || { echo "Failed to change directory to $example"; continue; }
19+
20+
build_output=$(spin build 2>&1)
21+
build_status=$?
22+
23+
if [[ $build_status -eq 0 ]]; then
24+
echo "`$ spin build` succeeded for $example_name"
25+
else
26+
echo "`$ spin build` failed for $example_name"
27+
fi
28+
echo "$build_output"
29+
30+
echo "::endgroup::"
31+
32+
# return to the parent directory
33+
cd - >/dev/null
34+
fi
35+
done

0 commit comments

Comments
 (0)