-
Notifications
You must be signed in to change notification settings - Fork 38
185 lines (163 loc) · 5.32 KB
/
ci.yml
File metadata and controls
185 lines (163 loc) · 5.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: CI
on:
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
MSRV: "1.85"
# NOTE: When adding a new example, add it here AND to the test matrix below (because we cannot create matrix entries dynamically)
RS_EXAMPLES_LIST: "browser-chat browser-chat/cli browser-echo custom-router dumbpipe-web framed-messages frosty iroh-automerge iroh-automerge-repo iroh-gateway extism/host extism/plugin extism/iroh-extism-host-functions"
WASM_EXAMPLES_LIST: "browser-chat browser-echo"
IROH_FORCE_STAGING_RELAYS: "1"
jobs:
# Prepare dependencies and cache them for all other jobs
prepare:
name: Prepare dependencies
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "iroh-examples-shared"
cache-all-crates: true
- name: Fetch dependencies
run: |
for example in $RS_EXAMPLES_LIST; do
if [ -f "$example/Cargo.toml" ]; then
echo "Fetching dependencies for $example"
cargo fetch --manifest-path "$example/Cargo.toml" --locked 2>/dev/null || cargo fetch --manifest-path "$example/Cargo.toml"
fi
done
# Check formatting for all examples in a single job (fast)
fmt:
name: Format check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: |
for example in $RS_EXAMPLES_LIST; do
if [ -f "$example/Cargo.toml" ]; then
echo "Checking format: $example"
cargo fmt --manifest-path "$example/Cargo.toml" --all -- --check
fi
done
# Build WASM examples
wasm:
name: WASM build
runs-on: ubuntu-latest
timeout-minutes: 20
needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "iroh-examples-shared"
- name: Build WASM examples
run: |
for example in $WASM_EXAMPLES_LIST; do
echo "Building WASM for $example"
cd "$example"
case "$example" in
browser-echo)
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --target wasm32-unknown-unknown --lib
;;
browser-chat)
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --target wasm32-unknown-unknown -p chat-browser
;;
*)
echo "Unknown WASM example: $example"
exit 1
;;
esac
cd ..
done
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}
# Parallel testing matrix for all examples
test:
name: Test ${{ matrix.example }}
runs-on: ubuntu-latest
timeout-minutes: 20
needs: prepare
strategy:
fail-fast: false
matrix:
example:
- browser-chat
- browser-chat/cli
- browser-echo
- custom-router
- dumbpipe-web
- framed-messages
- frosty
- iroh-automerge
- iroh-automerge-repo
- iroh-gateway
- extism/host
- extism/plugin
- extism/iroh-extism-host-functions
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "iroh-examples-shared"
workspaces: ${{ matrix.example }}
- name: Check
run: |
echo "Checking ${{ matrix.example }}"
cargo check --manifest-path "${{ matrix.example }}/Cargo.toml" --all-features
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}
- name: Clippy
run: |
echo "Running clippy on ${{ matrix.example }}"
cargo clippy --manifest-path "${{ matrix.example }}/Cargo.toml" --all-features
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}
- name: Test
run: |
echo "Testing ${{ matrix.example }}"
cargo test --manifest-path "${{ matrix.example }}/Cargo.toml" --all-features
env:
RUST_LOG: ${{ runner.debug && 'DEBUG' || 'INFO'}}