-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (142 loc) · 4.66 KB
/
rust-test.yml
File metadata and controls
169 lines (142 loc) · 4.66 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Rust Test & Coverage
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
statuses: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
# Cancel previous runs on new push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Cross-platform tests
test:
name: Test (${{ matrix.os }}, ${{ matrix.allocator }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
allocator: [system, jemalloc, mimalloc]
exclude:
# jemalloc has limited Windows support and tikv-jemalloc-sys fails to build on Windows MSVC
- os: windows-latest
allocator: jemalloc
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Setup sccache (Unix)
id: sccache-unix
if: matrix.os != 'windows-latest'
uses: mozilla-actions/sccache-action@v0.0.9
continue-on-error: true
- name: Setup sccache (Windows)
id: sccache-windows
if: matrix.os == 'windows-latest'
uses: mozilla-actions/sccache-action@v0.0.9
continue-on-error: true
- name: Configure sccache
if: steps.sccache-unix.outcome == 'success' || steps.sccache-windows.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
shell: bash
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-${{ matrix.os }}"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Set allocator features
id: features
run: |
if [ "${{ matrix.allocator }}" = "jemalloc" ]; then
echo "features=jemalloc,schema-validation,compression,http-server" >> $GITHUB_OUTPUT
elif [ "${{ matrix.allocator }}" = "mimalloc" ]; then
echo "features=mimalloc,schema-validation,compression,http-server" >> $GITHUB_OUTPUT
else
echo "features=schema-validation,compression,http-server" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Build workspace
run: cargo build --workspace --all-targets --features "${{ steps.features.outputs.features }}"
- name: Run tests (nextest)
run: |
echo "Running tests with Rust nightly for GAT zero-cost abstractions"
echo "Allocator: ${{ matrix.allocator }}"
rustc --version
cargo nextest run --workspace --features "${{ steps.features.outputs.features }}" --no-fail-fast
- name: Run doctests
run: cargo test --workspace --doc --features "${{ steps.features.outputs.features }}"
- name: sccache stats
if: always()
run: sccache --show-stats || echo "sccache not available"
continue-on-error: true
shell: bash
# Code coverage (Linux only)
coverage:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Install llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: "coverage"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Generate coverage
run: |
cargo llvm-cov --features "schema-validation,compression,http-server" --workspace --lcov \
--output-path lcov.info nextest
- name: Upload to codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
verbose: true
flags: unittests
name: codecov-pjs
- name: Archive coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: lcov.info
retention-days: 30
- name: Generate HTML coverage report
run: cargo llvm-cov --features "schema-validation,compression,http-server" --workspace --html
- name: Upload HTML coverage
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: target/llvm-cov/html/
retention-days: 30