Skip to content

Commit 97ab276

Browse files
committed
add alt ci workflow
1 parent 89c8107 commit 97ab276

File tree

2 files changed

+263
-0
lines changed

2 files changed

+263
-0
lines changed

.cargo/config_ci.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This config is used for the CI workflow.
2+
# Feel free to also use it locally for fast builds if you have the required setup!
3+
4+
[unstable]
5+
codegen-backend = true
6+
7+
[profile.dev]
8+
codegen-backend = "cranelift"
9+
10+
# Compile deps with LLVM because cranelift can crash the test runner otherwise
11+
[profile.dev.package."*"]
12+
codegen-backend = "llvm"
13+
14+
# Disable cranelift for release profile
15+
[profile.release]
16+
codegen-backend = "llvm"
17+
18+
# cranelift cannot build wasm32-unknown-unknown out of the box
19+
[profile.web]
20+
codegen-backend = "llvm"
21+
22+
# Override the high opt-level from the dev profile for the test profile
23+
[profile.test.package."*"]
24+
opt-level = 1
25+
26+
[target.wasm32-unknown-unknown]
27+
# Clang does not support wasm32-unknown-unknown,
28+
# so we cannot use mold either: https://github.com/flathub/org.freedesktop.Sdk.Extension.rust-stable/issues/168
29+
linker = "lld"
30+
rustflags = [
31+
"-Dwarnings",
32+
"-Cdebuginfo=line-tables-only",
33+
"--cfg",
34+
"getrandom_backend=\"wasm_js\"",
35+
# Nightly
36+
"-Zshare-generics=y",
37+
"-Zthreads=0",
38+
]
39+
rustdocflags = [
40+
"-Dwarnings",
41+
# Nightly
42+
"-Zshare-generics=y",
43+
"-Zthreads=0",
44+
]
45+
46+
47+
[target.x86_64-unknown-linux-gnu]
48+
linker = "clang"
49+
rustflags = [
50+
"-Dwarnings",
51+
"-Cdebuginfo=line-tables-only",
52+
# Mold linker
53+
"-Clink-arg=-fuse-ld=mold",
54+
# Nightly
55+
"-Zshare-generics=y",
56+
"-Zthreads=0",
57+
]
58+
rustdocflags = [
59+
"-Dwarnings",
60+
# Mold linker
61+
"-Clink-arg=-fuse-ld=mold",
62+
# Nightly
63+
"-Zshare-generics=y",
64+
"-Zthreads=0",
65+
]

.github/workflows/ci.yaml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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+
jobs:
14+
# Run tests.
15+
test:
16+
name: Tests
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 60
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install Rust toolchain
24+
uses: dtolnay/rust-toolchain@nightly
25+
with:
26+
components: rustc-codegen-cranelift-preview
27+
28+
- name: Install mold
29+
uses: rui314/setup-mold@v1
30+
31+
- name: Active CI cargo config
32+
run: mv .cargo/config_ci.toml .cargo/config.toml
33+
34+
- name: Install nextest
35+
uses: taiki-e/install-action@nextest
36+
37+
- name: Install dependencies
38+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
39+
40+
- name: Set LD_LIBRARY_PATH
41+
run: |
42+
# Setting LD_LIBRARY_PATH is a workaround for <https://github.com/TheBevyFlock/bevy_new_2d/pull/318#issuecomment-2585935350>.
43+
echo "LD_LIBRARY_PATH=$(rustc --print target-libdir)" >>"${GITHUB_ENV}"
44+
45+
- name: Restore Rust cache
46+
uses: Swatinem/rust-cache@v2
47+
with:
48+
save-if: ${{ github.ref == 'refs/heads/main' }}
49+
cache-directories: ${{ env.LD_LIBRARY_PATH }}
50+
51+
- name: Run tests
52+
run: cargo nextest run --locked --workspace --all-features --all-targets --no-fail-fast --no-tests warn
53+
54+
# Running doc tests separately is a workaround for <https://github.com/rust-lang/cargo/issues/6669>.
55+
- name: Run doctests
56+
run: cargo test --locked --workspace --all-features --doc
57+
58+
# Check that the game builds for web.
59+
check-web:
60+
name: Check web build
61+
runs-on: ubuntu-latest
62+
timeout-minutes: 20
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
67+
- name: Install Rust toolchain
68+
uses: dtolnay/rust-toolchain@nightly
69+
with:
70+
targets: wasm32-unknown-unknown
71+
72+
- name: Active CI cargo config
73+
run: mv .cargo/config_ci.toml .cargo/config.toml
74+
75+
- name: Install dependencies
76+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev lld
77+
78+
- name: Restore Rust cache
79+
uses: Swatinem/rust-cache@v2
80+
with:
81+
save-if: ${{ github.ref == 'refs/heads/main' }}
82+
83+
- name: Check web build
84+
run: cargo check --config 'profile.web.inherits="dev"' --features dev --no-default-features --profile web --target wasm32-unknown-unknown
85+
86+
87+
# Run clippy lints.
88+
clippy:
89+
name: Clippy
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 20
92+
steps:
93+
- name: Checkout repository
94+
uses: actions/checkout@v4
95+
96+
- name: Install Rust toolchain
97+
uses: dtolnay/rust-toolchain@nightly
98+
with:
99+
components: clippy, rustc-codegen-cranelift-preview
100+
101+
- name: Install mold
102+
uses: rui314/setup-mold@v1
103+
104+
- name: Active CI cargo config
105+
run: mv .cargo/config_ci.toml .cargo/config.toml
106+
107+
- name: Install dependencies
108+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
109+
110+
- name: Restore Rust cache
111+
uses: Swatinem/rust-cache@v2
112+
with:
113+
save-if: ${{ github.ref == 'refs/heads/main' }}
114+
shared-key: lints
115+
116+
- name: Run clippy lints
117+
run: cargo clippy --locked --workspace --all-targets --all-features
118+
119+
# Check formatting.
120+
format:
121+
name: Format
122+
runs-on: ubuntu-latest
123+
timeout-minutes: 10
124+
steps:
125+
- name: Checkout repository
126+
uses: actions/checkout@v4
127+
128+
- name: Install Rust toolchain
129+
uses: dtolnay/rust-toolchain@nightly
130+
with:
131+
components: rustfmt
132+
133+
- name: Run cargo fmt
134+
run: cargo fmt --all -- --check
135+
136+
# Check documentation.
137+
doc:
138+
name: Docs
139+
runs-on: ubuntu-latest
140+
timeout-minutes: 20
141+
steps:
142+
- name: Checkout repository
143+
uses: actions/checkout@v4
144+
145+
- name: Install Rust toolchain
146+
uses: dtolnay/rust-toolchain@nightly
147+
with:
148+
components: rustc-codegen-cranelift-preview
149+
150+
- name: Install mold
151+
uses: rui314/setup-mold@v1
152+
153+
- name: Active CI cargo config
154+
run: mv .cargo/config_ci.toml .cargo/config.toml
155+
156+
- name: Install dependencies
157+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
158+
159+
- name: Restore Rust cache
160+
uses: Swatinem/rust-cache@v2
161+
with:
162+
save-if: ${{ github.ref == 'refs/heads/main' }}
163+
shared-key: lints
164+
165+
- name: Check documentation
166+
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps
167+
168+
# Run Bevy lints.
169+
bevy-lint:
170+
name: Bevy linter
171+
runs-on: ubuntu-latest
172+
timeout-minutes: 30
173+
steps:
174+
- name: Checkout repository
175+
uses: actions/checkout@v4
176+
177+
- name: Install dependencies
178+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
179+
180+
- name: Restore Rust cache
181+
uses: Swatinem/rust-cache@v2
182+
with:
183+
save-if: ${{ github.ref == 'refs/heads/main' }}
184+
185+
- name: Install Bevy linter
186+
uses: TheBevyFlock/bevy_cli/bevy_lint@lint-v0.3.0
187+
188+
- name: Add cranelift to rustc
189+
run: rustup component add rustc-codegen-cranelift-preview
190+
191+
- name: Install mold
192+
uses: rui314/setup-mold@v1
193+
194+
- name: Active CI cargo config
195+
run: mv .cargo/config_ci.toml .cargo/config.toml
196+
197+
- name: Run Bevy linter
198+
run: bevy_lint --locked --workspace --all-targets --all-features

0 commit comments

Comments
 (0)