Skip to content

Commit ee7e23f

Browse files
committed
chore: speed up rust ci
1 parent 9d7372b commit ee7e23f

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

.github/workflows/rust_ci.yaml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ env:
2121
CARGO_TERM_COLOR: always
2222
CLOUD_VERSION: latest-amd64
2323
RUST_TOOLCHAIN: "1.92.0"
24+
CARGO_PROFILE_TEST_DEBUG: "0"
25+
# Speed up crate downloads with sparse registry
26+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
27+
# Faster for git dependencies
28+
CARGO_NET_GIT_FETCH_WITH_CLI: true
29+
# Disable incremental compilation in CI (faster clean builds)
30+
CARGO_INCREMENTAL: "0"
2431

2532
concurrency:
2633
group: ${{ github.workflow }}-${{ github.event.client_payload.pr_number || github.event.inputs.pr_number || github.ref }}
@@ -57,10 +64,21 @@ jobs:
5764
override: true
5865
components: rustfmt, clippy
5966
profile: minimal
67+
68+
- name: Setup sccache
69+
uses: mozilla-actions/sccache-action@v0.0.6
70+
71+
- name: Configure sccache
72+
run: |
73+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
74+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
75+
6076
- uses: Swatinem/rust-cache@v2
6177
with:
6278
prefix-key: ${{ runner.os }}
79+
shared-key: "rust-ci"
6380
cache-on-failure: true
81+
save-if: ${{ github.ref == 'refs/heads/main' }}
6482
workspaces: |
6583
frontend/rust-lib
6684
@@ -147,7 +165,13 @@ jobs:
147165
git config --global credential.helper store
148166
echo "https://${{ secrets.ADMIN_GITHUB_TOKEN }}:x-oauth-basic@github.com" > ~/.git-credentials
149167
150-
- name: Run rust-lib tests (non-af_cloud)
168+
- name: Fetch dependencies
169+
working-directory: frontend/rust-lib
170+
env:
171+
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
172+
run: cargo fetch
173+
174+
- name: Run rust-lib cloud tests (serialized)
151175
working-directory: frontend/rust-lib
152176
env:
153177
RUST_LOG: info
@@ -157,9 +181,9 @@ jobs:
157181
af_cloud_test_gotrue_url: http://localhost/gotrue
158182
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
159183
run: |
160-
DISABLE_CI_TEST_LOG="true" cargo test --no-default-features --features="dart" -- --skip af_cloud --skip local_ai_test --test-threads=1
184+
DISABLE_CI_TEST_LOG="true" cargo test -j 1 --workspace --no-default-features --features="dart" af_cloud -- --skip local_ai_test --test-threads=1
161185
162-
- name: Run rust-lib af_cloud tests (serialized)
186+
- name: Run rust-lib tests (non-cloud)
163187
working-directory: frontend/rust-lib
164188
env:
165189
RUST_LOG: info
@@ -169,7 +193,8 @@ jobs:
169193
af_cloud_test_gotrue_url: http://localhost/gotrue
170194
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
171195
run: |
172-
DISABLE_CI_TEST_LOG="true" cargo test -j 1 --no-default-features --features="dart" af_cloud -- --skip local_ai_test --test-threads=1
196+
DISABLE_CI_TEST_LOG="true" cargo test --workspace --no-default-features --features="dart" -- --skip af_cloud --skip local_ai_test --test-threads=1
197+
173198
174199
- name: rustfmt rust-lib
175200
run: cargo fmt --all -- --check
@@ -189,6 +214,10 @@ jobs:
189214
run: |
190215
docker compose -f docker-compose-ci.yml logs appflowy_cloud
191216
217+
- name: Show sccache stats
218+
if: always()
219+
run: sccache --show-stats
220+
192221
- name: Clean up Docker images
193222
run: |
194223
docker image prune -af

0 commit comments

Comments
 (0)