Skip to content

Commit b8ca479

Browse files
authored
Merge pull request #2756 from matklad/retasks
⬆️ crates
2 parents 9df1663 + 072f0d3 commit b8ca479

File tree

5 files changed

+71
-44
lines changed

5 files changed

+71
-44
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,13 @@ jobs:
5656
with:
5757
command: test
5858

59-
- name: Prepare build directory for cache (UNIX)
60-
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
61-
run: |
62-
find ./target/debug -maxdepth 1 -type f -delete \
63-
&& rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*heavy_test*,*gen_lsp*,*thread_worker*} \
64-
&& rm -f ./target/.rustc_info.json \
65-
&& rm ./target/.slow_tests_cookie
59+
- name: Prepare cache
60+
run: cargo xtask pre-cache
6661

67-
- name: Prepare build directory for cache (Windows)
62+
- name: Prepare cache 2
6863
if: matrix.os == 'windows-latest'
69-
run: >-
70-
(Get-ChildItem ./target/debug -Recurse -Depth 1 -File | Remove-Item) -and
71-
(Remove-Item -Force -Recurse ./target/debug/deps/*ra_*) -and
72-
(Remove-Item -Force -Recurse ./target/debug/deps/*heavy_test*) -and
73-
(Remove-Item -Force -Recurse ./target/debug/deps/*gen_lsp*) -and
74-
(Remove-Item -Force -Recurse ./target/debug/deps/*thread_worker*) -and
75-
(Remove-Item -Force -Recurse ./target/debug/.fingerprint/*ra_*) -and
76-
(Remove-Item -Force -Recurse ./target/debug/.fingerprint/*heavy_test*) -and
77-
(Remove-Item -Force -Recurse ./target/debug/.fingerprint/*gen_lsp*) -and
78-
(Remove-Item -Force -Recurse ./target/debug/.fingerprint/*thread_worker*) -and
79-
(Remove-Item -Force ./target/.rustc_info.json) -and
80-
(Remove-Item ./target/.slow_tests_cookie)
64+
run: Remove-Item ./target/debug/xtask.exe
65+
8166

8267
type-script:
8368
name: TypeScript

Cargo.lock

Lines changed: 21 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_lsp_server/src/caps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub fn server_capabilities() -> ServerCapabilities {
5656
color_provider: None,
5757
execute_command_provider: None,
5858
workspace: None,
59+
call_hierarchy_provider: None,
5960
experimental: Default::default(),
6061
}
6162
}

xtask/src/lib.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod ast_src;
99

1010
use anyhow::Context;
1111
use std::{
12-
env,
12+
env, fs,
1313
path::{Path, PathBuf},
1414
process::{Command, Stdio},
1515
};
@@ -101,3 +101,41 @@ pub fn run_fuzzer() -> Result<()> {
101101

102102
run("rustup run nightly -- cargo fuzz run parser", "./crates/ra_syntax")
103103
}
104+
105+
/// Cleans the `./target` dir after the build such that only
106+
/// dependencies are cached on CI.
107+
pub fn run_pre_cache() -> Result<()> {
108+
let slow_tests_cookie = Path::new("./target/.slow_tests_cookie");
109+
if !slow_tests_cookie.exists() {
110+
panic!("slow tests were skipped on CI!")
111+
}
112+
rm_rf(slow_tests_cookie)?;
113+
114+
for entry in Path::new("./target/debug").read_dir()? {
115+
let entry = entry?;
116+
if entry.file_type().map(|it| it.is_file()).ok() == Some(true) {
117+
// Can't delete yourself on windows :-(
118+
if !entry.path().ends_with("xtask.exe") {
119+
rm_rf(&entry.path())?
120+
}
121+
}
122+
}
123+
124+
fs::remove_file("./target/.rustc_info.json")?;
125+
let to_delete = ["ra_", "heavy_test"];
126+
for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() {
127+
for entry in Path::new(dir).read_dir()? {
128+
let entry = entry?;
129+
if to_delete.iter().any(|&it| entry.path().display().to_string().contains(it)) {
130+
rm_rf(&entry.path())?
131+
}
132+
}
133+
}
134+
135+
Ok(())
136+
}
137+
138+
fn rm_rf(path: &Path) -> Result<()> {
139+
if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) }
140+
.with_context(|| format!("failed to remove {:?}", path))
141+
}

xtask/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use pico_args::Arguments;
1414
use xtask::{
1515
codegen::{self, Mode},
1616
install::{ClientOpt, InstallCmd, ServerOpt},
17-
pre_commit, run_clippy, run_fuzzer, run_rustfmt, Result,
17+
pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result,
1818
};
1919

2020
fn main() -> Result<()> {
@@ -88,6 +88,10 @@ FLAGS:
8888
args.finish()?;
8989
run_fuzzer()
9090
}
91+
"pre-cache" => {
92+
args.finish()?;
93+
run_pre_cache()
94+
}
9195
_ => {
9296
eprintln!(
9397
"\

0 commit comments

Comments
 (0)