Skip to content

Commit d3ae816

Browse files
committed
Ci stability and speed improvements (bevyengine#2551)
# Objective - There are a few random failures in CI, mostly due to contacting crates.io or checking for deadlinks - CI can take some time, more than 20 minutes for a full status - A clippy/format issue stops running tests on other platforms ## Solution - Use GitHub cache for cargo artefacts - This speeds up builds and reduce dependencies on outside world - Reorder and add dependencies between short jobs. They are still setup to run even if one of the dependency failed - This reduce the number of parallel jobs that are running for one PR. On GitHub free tier, we're limited to 20. - Split CI checks (format & clippy) in its own job - This speeds up test jobs, and allow us to not kill all platform tests for a format issue - Retry in case of dead links check failure - Internet is just that kind of place where things may seem dead at some point but back alive 5 seconds later ## Before <img width="1062" alt="Screenshot 2021-07-27 at 01 18 52" src="https://user-images.githubusercontent.com/8672791/127071973-9a2c5ce8-c871-4f8d-9b17-08871824b6c4.png"> ## After (with all cache live) <img width="1063" alt="Screenshot 2021-07-27 at 01 18 28" src="https://user-images.githubusercontent.com/8672791/127071986-767a7e65-53ed-45fd-8d75-51a571f0b851.png">
1 parent 5583f9a commit d3ae816

File tree

1 file changed

+117
-27
lines changed

1 file changed

+117
-27
lines changed

.github/workflows/ci.yml

Lines changed: 117 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,52 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525
steps:
2626
- uses: actions/checkout@v2
27-
27+
- uses: actions/cache@v2
28+
with:
29+
path: |
30+
~/.cargo/bin/
31+
~/.cargo/registry/index/
32+
~/.cargo/registry/cache/
33+
~/.cargo/git/db/
34+
target/
35+
key: ${{ runner.os }}-cargo-build-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }}
2836
- uses: actions-rs/toolchain@v1
2937
with:
3038
toolchain: ${{ matrix.toolchain }}
31-
components: rustfmt, clippy
3239
override: true
33-
3440
- name: Install alsa and udev
3541
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
3642
if: runner.os == 'linux'
37-
38-
- name: Check the format
39-
# See tools/ci/src/main.rs for the commands this runs
40-
run: cargo run -p ci
41-
if: runner.os == 'linux' && matrix.toolchain == 'stable'
42-
4343
- name: Build & run tests
4444
run: cargo test --workspace
4545
env:
4646
CARGO_INCREMENTAL: 0
4747
RUSTFLAGS: "-C debuginfo=0 -D warnings"
4848

49+
ci:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
- uses: actions/cache@v2
54+
with:
55+
path: |
56+
~/.cargo/bin/
57+
~/.cargo/registry/index/
58+
~/.cargo/registry/cache/
59+
~/.cargo/git/db/
60+
target/
61+
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('**/Cargo.toml') }}
62+
- uses: actions-rs/toolchain@v1
63+
with:
64+
toolchain: stable
65+
components: rustfmt, clippy
66+
override: true
67+
- name: Install alsa and udev
68+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
69+
- name: CI job
70+
# See tools/ci/src/main.rs for the commands this runs
71+
run: cargo run -p ci
72+
4973
build-wasm:
5074
strategy:
5175
matrix:
@@ -54,13 +78,20 @@ jobs:
5478
runs-on: ${{ matrix.os }}
5579
steps:
5680
- uses: actions/checkout@v2
57-
81+
- uses: actions/cache@v2
82+
with:
83+
path: |
84+
~/.cargo/bin/
85+
~/.cargo/registry/index/
86+
~/.cargo/registry/cache/
87+
~/.cargo/git/db/
88+
target/
89+
key: ${{ runner.os }}-cargo-build-wasm-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }}
5890
- uses: actions-rs/toolchain@v1
5991
with:
6092
toolchain: ${{ matrix.toolchain }}
6193
target: wasm32-unknown-unknown
6294
override: true
63-
6495
- name: Check wasm
6596
uses: actions-rs/cargo@v1
6697
with:
@@ -71,23 +102,33 @@ jobs:
71102
runs-on: ubuntu-latest
72103
steps:
73104
- uses: actions/checkout@v2
105+
- uses: actions/cache@v2
106+
with:
107+
path: |
108+
~/.cargo/bin/
109+
~/.cargo/registry/index/
110+
~/.cargo/registry/cache/
111+
~/.cargo/git/db/
112+
target/
113+
key: ${{ runner.os }}-cargo-build-android-${{ hashFiles('**/Cargo.toml') }}
74114
- name: Uninstall android-31
75115
run: $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --uninstall "platforms;android-31"
76116
- name: Install Android targets
77117
run: rustup target add aarch64-linux-android armv7-linux-androideabi
78118
- name: Install Cargo APK
79-
run: cargo install cargo-apk
119+
run: cargo install --force cargo-apk
80120
- name: Build APK
81121
run: cargo apk build --example android
82122

83123
markdownlint:
84124
runs-on: ubuntu-latest
125+
needs: check-missing-examples-in-docs
126+
if: always()
85127
steps:
86128
- uses: actions/checkout@v2
87129
with:
88130
# Full git history is needed to get a proper list of changed files within `super-linter`
89131
fetch-depth: 0
90-
91132
- name: Run Markdown Lint
92133
uses: docker://ghcr.io/github/super-linter:slim-v4
93134
env:
@@ -99,41 +140,83 @@ jobs:
99140

100141
check-markdown-links:
101142
runs-on: ubuntu-latest
143+
needs: markdownlint
144+
if: always()
102145
steps:
103146
- uses: actions/checkout@v2
104-
- uses: gaurav-nelson/github-action-markdown-link-check@9710f0fec812ce0a3b98bef4c9d842fc1f39d976
147+
- name: check dead links
148+
continue-on-error: true
149+
id: run1
150+
uses: gaurav-nelson/github-action-markdown-link-check@9710f0fec812ce0a3b98bef4c9d842fc1f39d976
151+
with:
152+
use-quiet-mode: 'yes'
153+
use-verbose-mode: 'yes'
154+
config-file: '.github/linters/markdown-link-check.json'
155+
- name: Sleep for 30 seconds
156+
if: steps.run1.outcome=='failure'
157+
run: sleep 30s
158+
shell: bash
159+
- name: check dead links (retry)
160+
continue-on-error: true
161+
id: run2
162+
if: steps.run1.outcome=='failure'
163+
uses: gaurav-nelson/github-action-markdown-link-check@9710f0fec812ce0a3b98bef4c9d842fc1f39d976
164+
with:
165+
use-quiet-mode: 'yes'
166+
use-verbose-mode: 'yes'
167+
config-file: '.github/linters/markdown-link-check.json'
168+
- name: Sleep for 30 seconds
169+
if: steps.run2.outcome=='failure'
170+
run: sleep 30s
171+
shell: bash
172+
- name: check dead links (retry 2)
173+
continue-on-error: true
174+
id: run3
175+
if: steps.run2.outcome=='failure'
176+
uses: gaurav-nelson/github-action-markdown-link-check@9710f0fec812ce0a3b98bef4c9d842fc1f39d976
105177
with:
106178
use-quiet-mode: 'yes'
107179
use-verbose-mode: 'yes'
108180
config-file: '.github/linters/markdown-link-check.json'
181+
- name: set the status
182+
if: always()
183+
run: |
184+
if ${{ steps.run1.outcome=='success' || steps.run2.outcome=='success' || steps.run3.outcome=='success' }}; then
185+
echo success
186+
else
187+
exit 1
188+
fi
109189
110190
run-examples:
111191
runs-on: ubuntu-latest
112-
113192
steps:
114193
- name: Install dependencies
115194
run: |
116195
sudo apt-get update;
117196
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
118197
libasound2-dev libudev-dev wget unzip xvfb;
119-
120198
- uses: actions/checkout@v2
121-
199+
- uses: actions/cache@v2
200+
with:
201+
path: |
202+
~/.cargo/bin/
203+
~/.cargo/registry/index/
204+
~/.cargo/registry/cache/
205+
~/.cargo/git/db/
206+
target/
207+
key: ${{ runner.os }}-cargo-run-examples-${{ hashFiles('**/Cargo.toml') }}
122208
- uses: actions-rs/toolchain@v1
123209
with:
124210
toolchain: stable
125-
126211
- name: Setup swiftshader
127212
run: |
128213
wget https://github.com/qarmin/gtk_library_store/releases/download/3.24.0/swiftshader.zip;
129214
unzip swiftshader.zip;
130215
curr="$(pwd)/libvk_swiftshader.so";
131216
sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json;
132-
133217
- name: Build bevy
134218
run: |
135219
cargo build --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_wgpu,bevy_winit,render,png,hdr,x11,bevy_ci_testing"
136-
137220
- name: Run examples
138221
run: |
139222
for example in .github/example-run/*.ron; do
@@ -145,19 +228,21 @@ jobs:
145228
146229
check-doc:
147230
runs-on: ubuntu-latest
231+
needs: check-markdown-links
232+
if: always()
148233
steps:
149234
- uses: actions/checkout@v2
150235
- name: Install alsa and udev
151236
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
152237
if: runner.os == 'linux'
153238
- name: Installs cargo-deadlinks
154-
run: cargo install cargo-deadlinks
239+
run: cargo install --force cargo-deadlinks
155240
- name: Build and check doc
156241
run: RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps
157242
- name: Checks dead links
158243
run: cargo deadlinks --dir target/doc/bevy
159244
continue-on-error: true
160-
245+
161246
check-missing-examples-in-docs:
162247
runs-on: ubuntu-latest
163248
steps:
@@ -175,17 +260,22 @@ jobs:
175260
runs-on: ubuntu-latest
176261
steps:
177262
- uses: actions/checkout@v2
178-
263+
- uses: actions/cache@v2
264+
with:
265+
path: |
266+
~/.cargo/bin/
267+
~/.cargo/registry/index/
268+
~/.cargo/registry/cache/
269+
~/.cargo/git/db/
270+
target/
271+
key: ${{ runner.os }}-cargo-check-unused-dependencies-${{ hashFiles('**/Cargo.toml') }}
179272
- uses: actions-rs/toolchain@v1
180273
with:
181274
toolchain: nightly
182275
override: true
183-
184276
- name: Installs cargo-udeps
185-
run: cargo install cargo-udeps
186-
277+
run: cargo install --force cargo-udeps
187278
- name: Install alsa and udev
188279
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
189-
190280
- name: Run cargo udeps
191281
run: cargo udeps

0 commit comments

Comments
 (0)