-
Notifications
You must be signed in to change notification settings - Fork 4
77 lines (70 loc) · 3.35 KB
/
Copy pathtests.yaml
File metadata and controls
77 lines (70 loc) · 3.35 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
name: Rust Tests
on:
push:
# Must be the default branch: a PR can only restore caches from its own ref or from it.
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# Cargo's default for dev/test is debug = 2 -- full DWARF, which is most of a ~280MB test
# binary and makes linking the slowest part of the job. Line tables keep file:line in panic
# backtraces, which is all CI reads. Set here rather than in [profile.*] so local debuggers
# keep full info.
CARGO_PROFILE_DEV_DEBUG: line-tables-only
CARGO_PROFILE_TEST_DEBUG: line-tables-only
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
clippy:
name: Clippy
# Fork PRs run untrusted code, so they stay on GitHub-hosted and can never reach the
# self-hosted host. Everything else (in-repo branches, push, dispatch) uses the faster
# self-hosted runner with a warm cargo cache. Runner groups can't gate by trigger, so the
# split has to live here in the workflow — not in the approval setting.
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) && fromJSON('["ubuntu-latest"]') || fromJSON('["self-hosted", "dev-server"]') }}
if: github.event_name == 'push' || !github.event.pull_request.draft
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
# Not shared with `test`: clippy's target dir holds check-only artifacts (.rmeta),
# while `cargo test` needs full codegen. One key for both meant clippy always won
# the race to write the immutable key, so test restored a codegen-less cache and
# rebuilt the whole graph every run -- 52s for clippy against 20+ min for test.
shared-key: rust-ci-clippy
cache-on-failure: true
- run: cargo clippy --all-targets --all-features -- -D clippy::correctness
fmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# rustfmt.toml uses nightly-only options (imports_granularity), so check with nightly.
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo +nightly fmt --all -- --check
test:
name: Test
# Fork PRs stay on GitHub-hosted (untrusted code); trusted events use self-hosted. See the
# clippy job above for the rationale.
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) && fromJSON('["ubuntu-latest"]') || fromJSON('["self-hosted", "dev-server"]') }}
if: github.event_name == 'push' || !github.event.pull_request.draft
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: rust-ci-test
cache-on-failure: true
# 8 cores, shared with the second runner -- which picks up this workflow's clippy job.
# cc(1) inherits NUM_JOBS, so this caps the RocksDB C++ build too.
- name: Run tests
run: cargo test --all-features --jobs 4