Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 725adda

Browse files
authored
Merge pull request #1498 from rust-lang/azure-pipelines
Set up Azure Pipelines CI
2 parents 97cbb01 + 3494627 commit 725adda

File tree

8 files changed

+135
-49
lines changed

8 files changed

+135
-49
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ script:
2626
# Since the rls-* subcrates use crates.io-based dependencies of themselves it
2727
# makes sense to test them in isolation rather than just RLS itself
2828
(cd rls-analysis && cargo test -v && cargo fmt -- --check)
29-
(cd rls-blacklist && cargo test -v && cargo fmt -- --check)
3029
(cd rls-data && cargo test -v && cargo fmt -- --check)
3130
(cd rls-rustc && cargo test -v && cargo fmt -- --check)
3231
(cd rls-span && cargo test -v && cargo fmt -- --check)

azure-pipelines.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
trigger: ["master"]
2+
pr: ["master"]
3+
4+
variables:
5+
CARGO_INCREMENTAL: 0
6+
RUST_BACKTRACE: 1
7+
RLS_TEST_WAIT_FOR_AGES: 1
8+
9+
jobs:
10+
# Check formatting
11+
- template: ci/azure-rustfmt.yml
12+
parameters:
13+
rust: nightly-2019-08-01 # Use last well-known available nightly
14+
name: rustfmt
15+
crates:
16+
rls-analysis: []
17+
rls-data: []
18+
rls-rustc: []
19+
rls-span: []
20+
rls-vfs: []
21+
".": []
22+
23+
# Run unit and integration tests
24+
- template: ci/azure-test.yml
25+
parameters:
26+
rust: nightly
27+
name: tests
28+
crates:
29+
rls-analysis: []
30+
rls-data: []
31+
rls-rustc: []
32+
rls-span: []
33+
rls-vfs: []
34+
".":
35+
- test_name: test_tooltip_std
36+
args: --ignored

build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ fn main() {
1515
);
1616
println!(
1717
"cargo:rustc-env=FIXTURES_DIR={}",
18-
Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("tests/fixtures").display()
18+
Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap())
19+
.join("tests")
20+
.join("fixtures")
21+
.display()
1922
);
2023
}

ci/azure-install-rust.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
steps:
2+
# Linux and macOS.
3+
- script: |
4+
set -e
5+
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
6+
export PATH=$PATH:$HOME/.cargo/bin
7+
rustup toolchain install $RUSTUP_TOOLCHAIN
8+
rustup default $RUSTUP_TOOLCHAIN
9+
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
10+
env:
11+
RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
12+
displayName: "Install rust (*nix)"
13+
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
14+
15+
# Windows.
16+
- script: |
17+
curl -sSf -o rustup-init.exe https://win.rustup.rs
18+
rustup-init.exe -y --default-toolchain none
19+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
20+
rustup toolchain install %RUSTUP_TOOLCHAIN%
21+
rustup default %RUSTUP_TOOLCHAIN%
22+
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
23+
env:
24+
RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
25+
displayName: "Install rust (windows)"
26+
condition: eq(variables['Agent.OS'], 'Windows_NT')
27+
28+
# All platforms.
29+
- script: |
30+
rustup toolchain list
31+
rustc -Vv
32+
cargo -V
33+
displayName: Query rust and cargo versions

ci/azure-rustfmt.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
jobs:
2+
# Check formatting
3+
- job: ${{ parameters.name }}
4+
displayName: Check formatting
5+
pool:
6+
vmImage: ubuntu-16.04
7+
steps:
8+
- template: azure-install-rust.yml
9+
parameters:
10+
rust_version: ${{ parameters.rust }}
11+
- script: |
12+
rustup component add rustfmt
13+
cargo fmt --version
14+
displayName: Install rustfmt
15+
- ${{ each crate in parameters.crates }}:
16+
- script: cargo fmt --all -- --check
17+
displayName: Check formatting - ${{ crate.key }}
18+
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}

ci/azure-test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
jobs:
2+
# Check formatting
3+
- job: ${{ parameters.name }}
4+
displayName: Run tests on
5+
strategy:
6+
matrix:
7+
linux:
8+
imageName: 'ubuntu-16.04'
9+
mac:
10+
imageName: 'macos-10.14'
11+
windows:
12+
imageName: 'vs2017-win2016'
13+
pool:
14+
vmImage: $(imageName)
15+
steps:
16+
- template: azure-install-rust.yml
17+
parameters:
18+
rust_version: ${{ parameters.rust }}
19+
- script: |
20+
rustup component add rust-src rust-analysis
21+
displayName: Install distributed Rust source code for Racer autocompletion
22+
- ${{ each crate in parameters.crates }}:
23+
- script: cargo test -v
24+
displayName: Run tests - ${{ crate.key }}
25+
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
26+
- ${{ each extra in crate.value }}:
27+
- script: cargo test -v ${{ extra.test_name }} -- ${{ extra.args }}
28+
displayName: Run tests - ${{ crate.key }} - ${{ extra.test_name }}
29+
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}

rls-vfs/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,7 @@ mod tests {
921921

922922
assert_eq!(
923923
'😢'.len_utf8(),
924-
byte_in_str_utf16("😢a", Column::new_zero_indexed('😢'.len_utf16() as u32))
925-
.unwrap()
924+
byte_in_str_utf16("😢a", Column::new_zero_indexed('😢'.len_utf16() as u32)).unwrap()
926925
);
927926

928927
// 😢 is represented by 2 u16s - we can't index in the middle of a character

rls/src/actions/hover.rs

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -504,43 +504,6 @@ fn create_tooltip(
504504
tooltip
505505
}
506506

507-
/// Skips `skip_components` from the `path` if the path starts with `prefix`.
508-
/// Returns the original path if there is no match.
509-
///
510-
/// # Examples
511-
///
512-
/// ```ignore
513-
/// # use std::path::Path;
514-
///
515-
/// let base_path = Path::new(".rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/liballoc/string.rs");
516-
/// let tidy_path = skip_path_components(base_path, ".rustup", 7);
517-
/// assert_eq!(tidy_path, Some(PathBuf::from("liballoc/string.rs")));
518-
///
519-
/// let base_path = Path::new("/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.2/lib.rs");
520-
/// let tidy_path = skip_path_components(base_path, "/home/user/.cargo", 3);
521-
/// assert_eq!(tidy_path, Some(PathBuf::from("smallvec-0.6.2/lib.rs")));
522-
///
523-
/// let base_path = Path::new("/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.2/lib.rs");
524-
/// let tidy_path = skip_path_components(base_path, ".cargo", 3);
525-
/// assert_eq!(tidy_path, None);
526-
///
527-
/// let base_path = Path::new("some/unknown/path/lib.rs");
528-
/// let tidy_path = skip_path_components(base_path, ".rustup", 4);
529-
/// assert_eq!(tidy_path, None);
530-
/// ```
531-
fn skip_path_components<P: AsRef<Path>>(
532-
path: &Path,
533-
prefix: P,
534-
skip_components: usize,
535-
) -> Option<PathBuf> {
536-
path.strip_prefix(prefix).ok().map(|stripped| {
537-
stripped.components().skip(skip_components).fold(PathBuf::new(), |mut comps, comp| {
538-
comps.push(comp);
539-
comps
540-
})
541-
})
542-
}
543-
544507
/// Collapses parent directory references inside of paths.
545508
///
546509
/// # Example
@@ -613,22 +576,28 @@ fn racer_match_to_def(ctx: &InitActionContext, m: &racer::Match) -> Option<Def>
613576
use std::env;
614577

615578
let home = home::home_dir().unwrap_or_default();
616-
let rustup_home =
617-
env::var("RUSTUP_HOME").map(PathBuf::from).unwrap_or_else(|_| home.join(".rustup"));
618579
let cargo_home =
619580
env::var("CARGO_HOME").map(PathBuf::from).unwrap_or_else(|_| home.join(".cargo"));
581+
let cargo_registry_src =
582+
cargo_home.join("registry").join("src").join("github.com-1ecc6299db9ec823");
583+
let rust_src_path = racer::get_rust_src_path().ok();
620584

621585
let contextstr = m.contextstr.replacen("\\\\?\\", "", 1);
622586
let contextstr_path = PathBuf::from(&contextstr);
623587
let contextstr_path = collapse_parents(contextstr_path);
624588

625-
// Tidy up the module path.
626-
// Skips `toolchains/$TOOLCHAIN/lib/rustlib/src/rust/src`.
627-
skip_path_components(&contextstr_path, rustup_home, 7)
628-
// Skips `/registry/src/github.com-1ecc6299db9ec823/`.
629-
.or_else(|| skip_path_components(&contextstr_path, cargo_home, 3))
630-
// Make the path relative to the root of the project, if possible.
589+
// Attempt to tidy up the module path
590+
rust_src_path
591+
.and_then(|rust_src_path| {
592+
// Make the path relative to Rust src root
593+
contextstr_path.strip_prefix(rust_src_path).ok().map(ToOwned::to_owned)
594+
})
595+
.or_else(|| {
596+
// Make the path relative to the package root cached in Cargo registry
597+
contextstr_path.strip_prefix(cargo_registry_src).ok().map(ToOwned::to_owned)
598+
})
631599
.or_else(|| {
600+
// Make the path relative to the root of the project
632601
contextstr_path.strip_prefix(&ctx.current_project).ok().map(ToOwned::to_owned)
633602
})
634603
.and_then(|path| path.to_str().map(ToOwned::to_owned))

0 commit comments

Comments
 (0)