Skip to content

Commit 837bee7

Browse files
authored
feat: setup ci
feat: setup ci
2 parents 8170c98 + d8f6d21 commit 837bee7

File tree

9 files changed

+381
-154
lines changed

9 files changed

+381
-154
lines changed

.github/workflows/ci.yaml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
env:
14+
# Reduce compile time and cache size.
15+
RUSTFLAGS: -Dwarnings -Zshare-generics=y -Zthreads=0
16+
RUSTDOCFLAGS: -Dwarnings -Zshare-generics=y -Zthreads=0
17+
# Use the same Rust toolchain across jobs so they can share a cache.
18+
toolchain: nightly-2025-06-26
19+
20+
jobs:
21+
# Check formatting.
22+
format:
23+
name: Format
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Install Rust toolchain
31+
uses: dtolnay/rust-toolchain@master
32+
with:
33+
toolchain: ${{ env.toolchain }}
34+
components: rustfmt
35+
36+
- name: Check formatting
37+
run: cargo fmt --all -- --check
38+
39+
# Check documentation.
40+
docs:
41+
name: Docs
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 20
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
- name: Install Rust toolchain
49+
uses: dtolnay/rust-toolchain@master
50+
with:
51+
toolchain: ${{ env.toolchain }}
52+
53+
- name: Restore Rust cache
54+
id: cache
55+
uses: Swatinem/rust-cache@v2
56+
with:
57+
shared-key: ci
58+
save-if: false
59+
60+
- name: Install build dependencies
61+
if: steps.cache.outputs.cache-hit != 'true'
62+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
63+
64+
- name: Check documentation
65+
run: cargo doc --locked --workspace --profile ci --all-features --document-private-items --no-deps
66+
67+
# Run Clippy lints.
68+
clippy-lints:
69+
name: Clippy lints
70+
runs-on: ubuntu-latest
71+
timeout-minutes: 20
72+
steps:
73+
- name: Checkout repository
74+
uses: actions/checkout@v4
75+
76+
- name: Install Rust toolchain
77+
uses: dtolnay/rust-toolchain@master
78+
with:
79+
toolchain: ${{ env.toolchain }}
80+
components: clippy
81+
82+
- name: Restore Rust cache
83+
id: cache
84+
uses: Swatinem/rust-cache@v2
85+
with:
86+
shared-key: ci
87+
save-if: ${{ github.ref == 'refs/heads/main' }}
88+
89+
- name: Install build dependencies
90+
if: steps.cache.outputs.cache-hit != 'true'
91+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
92+
93+
- name: Run Clippy lints
94+
run: cargo clippy --locked --workspace --all-targets --profile ci --all-features
95+
96+
# Run Bevy lints.
97+
bevy-lints:
98+
name: Bevy lints
99+
runs-on: ubuntu-latest
100+
timeout-minutes: 20
101+
steps:
102+
- name: Checkout repository
103+
uses: actions/checkout@v4
104+
105+
- name: Install Rust toolchain (plus bevy_lint)
106+
uses: TheBevyFlock/bevy_cli/bevy_lint@lint-v0.4.0
107+
with:
108+
cache: true
109+
save-cache-if: ${{ github.ref == 'refs/heads/main' }}
110+
111+
- name: Restore Rust cache
112+
id: cache
113+
uses: Swatinem/rust-cache@v2
114+
with:
115+
shared-key: ci
116+
save-if: false
117+
118+
- name: Install build dependencies
119+
if: steps.cache.outputs.cache-hit != 'true'
120+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
121+
122+
- name: Run Bevy lints
123+
run: bevy_lint --locked --workspace --all-targets --profile ci --all-features
124+
125+
# Run tests.
126+
tests:
127+
name: Tests
128+
runs-on: ubuntu-latest
129+
timeout-minutes: 40
130+
steps:
131+
- name: Checkout repository
132+
uses: actions/checkout@v4
133+
134+
- name: Set up environment
135+
run: echo "RUSTFLAGS=${RUSTFLAGS:+$RUSTFLAGS }-Zcodegen-backend=cranelift" >> "${GITHUB_ENV}"
136+
137+
- name: Install Rust toolchain
138+
uses: dtolnay/rust-toolchain@master
139+
with:
140+
toolchain: ${{ env.toolchain }}
141+
components: rustc-codegen-cranelift-preview
142+
143+
- name: Restore Rust cache
144+
uses: Swatinem/rust-cache@v2
145+
with:
146+
shared-key: test
147+
cache-directories: ${{ env.LD_LIBRARY_PATH }}
148+
save-if: ${{ github.ref == 'refs/heads/main' }}
149+
150+
- name: Install build dependencies
151+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
152+
153+
- name: Run tests
154+
run: cargo test --locked --workspace --all-targets --profile ci --no-fail-fast
155+
156+
# Check that the web build compiles.
157+
check-web:
158+
name: Check web
159+
runs-on: ubuntu-latest
160+
timeout-minutes: 20
161+
steps:
162+
- name: Checkout repository
163+
uses: actions/checkout@v4
164+
165+
- name: Install Rust toolchain
166+
uses: dtolnay/rust-toolchain@master
167+
with:
168+
toolchain: ${{ env.toolchain }}
169+
targets: wasm32-unknown-unknown
170+
171+
- name: Restore Rust cache
172+
id: cache
173+
uses: Swatinem/rust-cache@v2
174+
with:
175+
shared-key: web-ci
176+
save-if: ${{ github.ref == 'refs/heads/main' }}
177+
178+
- name: Install build dependencies
179+
if: steps.cache.outputs.cache-hit != 'true'
180+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
181+
182+
- name: Check web
183+
run: cargo check --config 'profile.web.inherits="dev"' --profile ci --no-default-features --features dev --target wasm32-unknown-unknown

0 commit comments

Comments
 (0)