15
15
CARGO_NET_RETRY : 10
16
16
CI : 1
17
17
RUST_BACKTRACE : short
18
- RUSTFLAGS : " -D warnings -D elided_lifetimes_in_paths -D explicit_outlives_requirements -D unsafe_op_in_unsafe_fn -D unused_extern_crates -D unused_lifetimes -D unreachable_pub"
19
18
RUSTUP_MAX_RETRIES : 10
20
19
21
20
jobs :
25
24
pull-requests : read
26
25
outputs :
27
26
typescript : ${{ steps.filter.outputs.typescript }}
28
- proc_macros : ${{ steps.filter.outputs.proc_macros }}
29
27
steps :
30
28
- uses : actions/checkout@v4
31
29
- uses : dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242
@@ -34,52 +32,54 @@ jobs:
34
32
filters : |
35
33
typescript:
36
34
- 'editors/code/**'
37
- proc_macros:
38
- - 'crates/tt/**'
39
- - 'crates/proc-macro-api/**'
40
- - 'crates/proc-macro-srv/**'
41
- - 'crates/proc-macro-srv-cli/**'
42
35
43
36
proc-macro-srv :
44
- needs : changes
45
- if : github.repository == 'rust-lang/rust-analyzer' && needs.changes.outputs.proc_macros == 'true'
37
+ if : github.repository == 'rust-lang/rust-analyzer'
46
38
name : proc-macro-srv
47
39
runs-on : ubuntu-latest
40
+ env :
41
+ RUSTFLAGS : " -D warnings"
42
+
48
43
steps :
49
44
- name : Checkout repository
50
45
uses : actions/checkout@v4
51
46
with :
52
47
ref : ${{ github.event.pull_request.head.sha }}
53
48
49
+ - name : Install rustup-toolchain-install-master
50
+ run : cargo install rustup-toolchain-install-master@1.6.0
51
+
52
+ # Install a pinned rustc commit to avoid surprises
54
53
- name : Install Rust toolchain
55
54
run : |
56
- rustup update --no-self-update nightly
57
- rustup default nightly
58
- rustup component add --toolchain nightly rust-src rustfmt
55
+ RUSTC_VERSION=`cat rust-version`
56
+ rustup-toolchain-install-master ${RUSTC_VERSION} -c rust-src -c rustfmt
57
+ rustup default ${RUSTC_VERSION}
58
+
59
+ # Emulate a nightly toolchain, because the toolchain installed above does not have "nightly"
60
+ # in its version string.
61
+ - name : Emulate a nightly toolchain
62
+ run : echo "RUSTC_BOOTSTRAP=1" >> $GITHUB_ENV
63
+
59
64
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
60
65
- name : Install Rust Problem Matcher
61
- if : matrix.os == 'ubuntu-latest'
62
66
run : echo "::add-matcher::.github/rust.json"
63
67
64
- - name : Cache Dependencies
65
- uses : Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
66
-
67
- - name : Bump opt-level
68
- if : matrix.os == 'ubuntu-latest'
69
- run : sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
70
-
71
68
- name : Test
72
- run : cargo test --features sysroot-abi -p rust-analyzer -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
69
+ run : cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
70
+
71
+ - name : Check salsa dependency
72
+ run : " ! (cargo tree -p proc-macro-srv-cli | grep -q salsa)"
73
73
74
74
rust :
75
75
if : github.repository == 'rust-lang/rust-analyzer'
76
76
name : Rust
77
77
runs-on : ${{ matrix.os }}
78
78
env :
79
+ RUSTFLAGS : " -Dwarnings"
79
80
CC : deny_c
80
81
81
82
strategy :
82
- fail-fast : false
83
83
matrix :
84
84
os : [ubuntu-latest, windows-latest, macos-latest]
85
85
93
93
run : |
94
94
rustup update --no-self-update stable
95
95
rustup default stable
96
- rustup component add --toolchain stable rust-src
96
+ rustup component add --toolchain stable rust-src clippy
97
97
# We always use a nightly rustfmt, regardless of channel, because we need
98
98
# --file-lines.
99
99
rustup toolchain install nightly --profile minimal --component rustfmt
@@ -102,63 +102,122 @@ jobs:
102
102
if : matrix.os == 'ubuntu-latest'
103
103
run : echo "::add-matcher::.github/rust.json"
104
104
105
- - name : Cache Dependencies
106
- uses : Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
105
+ # - name: Cache Dependencies
106
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
107
+ # with:
108
+ # workspaces: |
109
+ # . -> target
110
+ # ./crates/proc-macro-srv/proc-macro-test/imp -> target
107
111
108
- - name : Bump opt-level
109
- if : matrix.os == 'ubuntu-latest'
110
- run : sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
112
+ - name : Install nextest
113
+ uses : taiki-e/install-action@nextest
111
114
112
115
- name : Codegen checks (rust-analyzer)
116
+ if : matrix.os == 'ubuntu-latest'
113
117
run : cargo codegen --check
114
118
115
- - name : Compile ( tests)
116
- run : cargo test --no-run --locked
119
+ - name : Compile tests
120
+ run : cargo test --no-run
117
121
118
- # It's faster to `test` before `build` ¯\_(ツ)_/¯
119
- - name : Compile (rust-analyzer)
120
- if : matrix.os == 'ubuntu-latest'
121
- run : cargo build --quiet
122
+ - name : Run tests
123
+ run : cargo nextest run --no-fail-fast --hide-progress-bar --status-level fail
122
124
123
- - name : Test
124
- if : matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest' || github.event_name == 'push'
125
- run : cargo test -- --quiet
125
+ - name : Cancel parallel jobs
126
+ if : failure()
127
+ run : |
128
+ # https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run
129
+ curl -L \
130
+ -X POST \
131
+ -H "Accept: application/vnd.github.v3+json" \
132
+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
133
+ -H "X-GitHub-Api-Version: 2022-11-28" \
134
+ https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
135
+
136
+ - name : Run Clippy
137
+ if : matrix.os == 'macos-latest'
138
+ run : cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
126
139
127
- - name : Switch to stable toolchain
140
+ analysis-stats :
141
+ if : github.repository == 'rust-lang/rust-analyzer'
142
+ runs-on : ubuntu-latest
143
+ env :
144
+ RUSTC_BOOTSTRAP : 1
145
+
146
+ steps :
147
+ - name : Checkout repository
148
+ uses : actions/checkout@v4
149
+
150
+ - name : Install Rust toolchain
128
151
run : |
129
152
rustup update --no-self-update stable
130
- rustup component add --toolchain stable rust-src clippy
131
153
rustup default stable
154
+ rustup component add rustfmt
132
155
133
- - name : Run analysis-stats on rust-analyzer
134
- if : matrix.os == 'ubuntu-latest'
135
- run : target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .
156
+ # - name: Cache Dependencies
157
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
136
158
137
- - name : Run analysis-stats on the rust standard libraries
138
- if : matrix.os == 'ubuntu-latest'
139
- env :
140
- RUSTC_BOOTSTRAP : 1
141
- run : target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/
159
+ - name : Bump opt-level
160
+ run : sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
142
161
143
- - name : clippy
144
- if : matrix.os == 'windows-latest'
145
- run : cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
162
+ - run : cargo build -p rust-analyzer
146
163
147
- - name : rustfmt
148
- if : matrix.os == 'ubuntu-latest'
149
- run : cargo fmt -- --check
164
+ - name : ./rust-analyzer
165
+ run : ./target/debug/rust-analyzer analysis-stats . -q
166
+
167
+ - name : sysroot/lib/rustlib/src/rust/library/
168
+ run : ./target/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/ -q
169
+
170
+ rustfmt :
171
+ if : github.repository == 'rust-lang/rust-analyzer'
172
+ runs-on : ubuntu-latest
173
+
174
+ steps :
175
+ - name : Checkout repository
176
+ uses : actions/checkout@v4
177
+
178
+ - name : Install Rust toolchain
179
+ run : |
180
+ rustup update --no-self-update stable
181
+ rustup default stable
182
+ rustup component add rustfmt
183
+
184
+ - run : cargo fmt -- --check
185
+
186
+ miri :
187
+ if : github.repository == 'rust-lang/rust-analyzer'
188
+ runs-on : ubuntu-latest
189
+
190
+ steps :
191
+ - name : Checkout repository
192
+ uses : actions/checkout@v4
193
+
194
+ - name : Install Rust toolchain
195
+ run : |
196
+ rustup update --no-self-update nightly
197
+ rustup default nightly
198
+ rustup component add miri
199
+
200
+ # - name: Cache Dependencies
201
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
202
+
203
+ - run : cargo miri test -p intern
150
204
151
205
# Weird targets to catch non-portable code
152
206
rust-cross :
153
207
if : github.repository == 'rust-lang/rust-analyzer'
154
208
name : Rust Cross
155
209
runs-on : ubuntu-latest
156
210
211
+ strategy :
212
+ matrix :
213
+ target : [powerpc-unknown-linux-gnu, x86_64-unknown-linux-musl, wasm32-unknown-unknown]
214
+ include :
215
+ # The rust-analyzer binary is not expected to compile on WASM, but the IDE
216
+ # crate should
217
+ - target : wasm32-unknown-unknown
218
+ ide-only : true
157
219
env :
158
- targets : " powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
159
- # The rust-analyzer binary is not expected to compile on WASM, but the IDE
160
- # crate should
161
- targets_ide : " wasm32-unknown-unknown"
220
+ RUSTFLAGS : " -Dwarnings"
162
221
163
222
steps :
164
223
- name : Checkout repository
@@ -167,19 +226,15 @@ jobs:
167
226
- name : Install Rust toolchain
168
227
run : |
169
228
rustup update --no-self-update stable
170
- rustup target add ${{ env.targets }} ${{ env.targets_ide }}
229
+ rustup target add ${{ matrix.target }}
171
230
172
- - name : Cache Dependencies
173
- uses : Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
231
+ # - name: Cache Dependencies
232
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
174
233
175
- - name : Check
176
- run : |
177
- for target in ${{ env.targets }}; do
178
- cargo check --target=$target --all-targets
179
- done
180
- for target in ${{ env.targets_ide }}; do
181
- cargo check -p ide --target=$target --all-targets
182
- done
234
+ - run : cargo check --target=${{ matrix.target }} --all-targets -p ide
235
+ if : ${{ matrix.ide-only }}
236
+ - run : cargo check --target=${{ matrix.target }} --all-targets
237
+ if : ${{ !matrix.ide-only }}
183
238
184
239
typescript :
185
240
needs : changes
@@ -261,7 +316,7 @@ jobs:
261
316
run : typos
262
317
263
318
conclusion :
264
- needs : [rust, rust-cross, typescript, typo-check, proc-macro-srv]
319
+ needs : [rust, rust-cross, typescript, typo-check, proc-macro-srv, miri, rustfmt, analysis-stats ]
265
320
# We need to ensure this job does *not* get skipped if its dependencies fail,
266
321
# because a skipped job is considered a success by GitHub. So we have to
267
322
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
0 commit comments