summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-05-16 09:40:30 -0600
committerGitHub <noreply@github.com>2019-05-16 09:40:30 -0600
commit2cf69a82b7fcb4d61c853f54488e0b02d301033e (patch)
treed84889473d6bfe3f5b014c8afc945f918cda916b
parent90d6e6cf0b22520a5177e8e842acbb142482e4eb (diff)
ci: Fix CI to work with changes to Azure Pipelines build agent (#55)
-rw-r--r--.build/install-rust.yml12
-rw-r--r--azure-pipelines.yml84
-rw-r--r--ci/azure-install-rust.yml25
-rw-r--r--ci/azure-rustfmt.yml16
-rw-r--r--ci/azure-setup-test-env.yml16
-rw-r--r--ci/azure-test-nightly.yml13
-rw-r--r--ci/azure-test-stable.yml23
-rw-r--r--src/modules/directory.rs9
-rw-r--r--tests/Dockerfile2
-rw-r--r--tests/directory.rs10
-rw-r--r--tests/python.rs8
11 files changed, 125 insertions, 93 deletions
diff --git a/.build/install-rust.yml b/.build/install-rust.yml
deleted file mode 100644
index 765fdff40..000000000
--- a/.build/install-rust.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-steps:
- - script: |
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN%
- echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
- displayName: Windows install rust
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
- - script: |
- curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
- echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
- displayName: Install rust
- condition: ne( variables['Agent.OS'], 'Windows_NT' )
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 4d669a157..70ce2c233 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -1,73 +1,25 @@
jobs:
- # Run the Rust linter
- - job: "Clippy"
- pool:
- vmImage: "ubuntu-16.04"
- container: "rust:latest"
- steps:
- - script: rustup component add clippy
- displayName: Install Clippy
- - script: cargo clippy --all
- displayName: Run clippy
+ # Check formatting
+ - template: ci/azure-rustfmt.yml
+ parameters:
+ name: rustfmt
- # Run the Rust formatter
- - job: "Rustfmt"
- pool:
- vmImage: "ubuntu-16.04"
- container: "rust:latest"
- condition: eq(variables['Build.Reason'], 'PullRequest')
- steps:
- - script: rustup component add rustfmt
- displayName: Install Rustfmt
- - script: cargo fmt --all -- --check
- displayName: Run rustfmt
+ # Test with Rust stable
+ - template: ci/azure-test-stable.yml
+ parameters:
+ name: test_starship
+ displayName: Test starship
+
+ # Test with Rust nightly
+ - template: ci/azure-test-nightly.yml
+ parameters:
+ name: test_nightly
+ displayName: Check starship with nightly
# Run the integration tests in a Docker container
- - job: "Docker"
+ - job: test_docker
+ displayName: Test starship Docker
pool:
- vmImage: "ubuntu-16.04"
+ vmImage: ubuntu-16.04
steps:
- script: ./integration_test
- displayName: Dockerized tests
-
- # Run the integration tests on virtual machines
- - job: "Test"
- strategy:
- matrix:
- windows-stable:
- imageName: "vs2017-win2016"
- RUSTUP_TOOLCHAIN: stable
- mac-stable:
- imageName: "macos-10.13"
- RUSTUP_TOOLCHAIN: stable
- linux-stable:
- imageName: "ubuntu-16.04"
- RUSTUP_TOOLCHAIN: stable
- linux-beta:
- imageName: "ubuntu-16.04"
- RUSTUP_TOOLCHAIN: beta
- linux-nightly:
- imageName: "ubuntu-16.04"
- RUSTUP_TOOLCHAIN: nightly
- pool:
- vmImage: "ubuntu-16.04"
- steps:
- # Install Node.js
- - task: NodeTool@0
- inputs:
- versionSpec: "12.0.0"
- # Install Go
- - task: GoTool@0
- inputs:
- versionSpec: "1.10"
- # Install Python
- - task: UsePythonVersion@0
- inputs:
- versionSpec: "3.7.2"
- # Install Rust
- - template: ".build/install-rust.yml"
-
- - script: cargo build
- displayName: Cargo build
- - script: cargo test -- --ignored
- displayName: Cargo test
diff --git a/ci/azure-install-rust.yml b/ci/azure-install-rust.yml
new file mode 100644
index 000000000..122e8a981
--- /dev/null
+++ b/ci/azure-install-rust.yml
@@ -0,0 +1,25 @@
+steps:
+ # Linux and macOS
+ - script: |
+ set -e
+ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
+ echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin:/usr/local/cargo/bin"
+ env:
+ RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
+ displayName: "Install rust (*nix)"
+ condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
+ # Windows
+ - script: |
+ curl -sSf -o rustup-init.exe https://win.rustup.rs
+ rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN%
+ set PATH=%PATH%;%USERPROFILE%\.cargo\bin
+ echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
+ env:
+ RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
+ displayName: "Install rust (windows)"
+ condition: eq(variables['Agent.OS'], 'Windows_NT')
+ # All platforms.
+ - script: |
+ rustc -Vv
+ cargo -V
+ displayName: Query rust and cargo versions
diff --git a/ci/azure-rustfmt.yml b/ci/azure-rustfmt.yml
new file mode 100644
index 000000000..60bb51aa5
--- /dev/null
+++ b/ci/azure-rustfmt.yml
@@ -0,0 +1,16 @@
+jobs:
+# Check formatting
+- job: ${{ parameters.name }}
+ displayName: Check rustfmt
+ pool:
+ vmImage: ubuntu-16.04
+ steps:
+ - template: azure-install-rust.yml
+ parameters:
+ rust_version: stable
+ - script: |
+ rustup component add rustfmt
+ displayName: Install rustfmt
+ - script: |
+ cargo fmt --all -- --check
+ displayName: Check formatting
diff --git a/ci/azure-setup-test-env.yml b/ci/azure-setup-test-env.yml
new file mode 100644
index 000000000..c2c54b078
--- /dev/null
+++ b/ci/azure-setup-test-env.yml
@@ -0,0 +1,16 @@
+steps:
+ # Install Node.js
+ - task: NodeTool@0
+ inputs:
+ versionSpec: "12.0.0"
+ displayName: "Install a fixed version of Node"
+ # Install Go
+ - task: GoTool@0
+ inputs:
+ versionSpec: "1.10"
+ displayName: "Install a fixed version of Go"
+ # Install Python
+ - task: UsePythonVersion@0
+ inputs:
+ versionSpec: "3.6.8"
+ displayName: "Install a fixed version of Python"
diff --git a/ci/azure-test-nightly.yml b/ci/azure-test-nightly.yml
new file mode 100644
index 000000000..e6f507881
--- /dev/null
+++ b/ci/azure-test-nightly.yml
@@ -0,0 +1,13 @@
+jobs:
+- job: ${{ parameters.name }}
+ displayName: ${{ parameters.displayName }}
+ pool:
+ vmImage: ubuntu-16.04
+
+ steps:
+ - template: azure-install-rust.yml
+ parameters:
+ rust_version: nightly
+
+ - script: cargo check --all
+ displayName: cargo +nightly check --all
diff --git a/ci/azure-test-stable.yml b/ci/azure-test-stable.yml
new file mode 100644
index 000000000..031b69399
--- /dev/null
+++ b/ci/azure-test-stable.yml
@@ -0,0 +1,23 @@
+jobs:
+- job: ${{ parameters.name }}
+ displayName: ${{ parameters.displayName }}
+ strategy:
+ matrix:
+ Linux:
+ vmImage: ubuntu-16.04
+ MacOS:
+ vmImage: macOS-10.13
+ Windows:
+ vmImage: vs2017-win2016
+ pool:
+ vmImage: $(vmImage)
+
+ steps:
+ - template: azure-install-rust.yml
+ parameters:
+ rust_version: stable
+
+ - template: azure-setup-test-env.yml
+
+ - script: cargo test -- --ignored
+ displayName: cargo test
diff --git a/src/modules/directory.rs b/src/modules/directory.rs
index e0f4a9e12..710f73593 100644
--- a/src/modules/directory.rs
+++ b/src/modules/directory.rs
@@ -21,6 +21,7 @@ pub fn segment(context: &Context) -> Option<Module> {
module.set_style(module_color);
let current_dir = &context.current_dir;
+ log::debug!("Current directory: {:?}", current_dir);
let dir_string;
if let Some(repo_root) = &context.repo_root {
@@ -58,7 +59,7 @@ fn contract_path(full_path: &Path, top_level_path: &Path, top_level_replacement:
format!(
"{replacement}{separator}{path}",
replacement = top_level_replacement,
- separator = std::path::MAIN_SEPARATOR,
+ separator = "/",
path = full_path
.strip_prefix(top_level_path)
.unwrap()
@@ -76,15 +77,13 @@ fn truncate(dir_string: String, length: usize) -> String {
return dir_string;
}
- let components = dir_string
- .split(std::path::MAIN_SEPARATOR)
- .collect::<Vec<&str>>();
+ let components = dir_string.split("/").collect::<Vec<&str>>();
if components.len() <= length {
return dir_string;
}
let truncated_components = &components[components.len() - length..];
- truncated_components.join(&std::path::MAIN_SEPARATOR.to_string())
+ truncated_components.join("/")
}
#[cfg(test)]
diff --git a/tests/Dockerfile b/tests/Dockerfile
index 8218fd312..ef00a407d 100644
--- a/tests/Dockerfile
+++ b/tests/Dockerfile
@@ -28,7 +28,7 @@ RUN goenv global $GO_VERSION
RUN go version
# Install Python
-ENV PYTHON_VERSION 3.7.2
+ENV PYTHON_VERSION 3.6.8
ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN curl https://pyenv.run | bash \
diff --git a/tests/directory.rs b/tests/directory.rs
index 38efc2988..d14b7fc25 100644
--- a/tests/directory.rs
+++ b/tests/directory.rs
@@ -67,9 +67,9 @@ fn root_directory() -> io::Result<()> {
#[test]
fn directory_in_root() -> io::Result<()> {
- let dir = Path::new("/opt");
+ let dir = Path::new("/tmp");
- let expected = format!("via {} ", Color::Cyan.bold().paint("/opt").to_string());
+ let expected = format!("via {} ", Color::Cyan.bold().paint("/tmp").to_string());
let actual = common::render_module("dir", &dir);
assert_eq!(expected, actual);
@@ -79,7 +79,7 @@ fn directory_in_root() -> io::Result<()> {
#[test]
#[ignore]
fn truncated_directory_in_root() -> io::Result<()> {
- let dir = Path::new("/opt/starship/thrusters/rocket");
+ let dir = Path::new("/tmp/starship/thrusters/rocket");
fs::create_dir_all(&dir)?;
let expected = format!(
@@ -98,7 +98,7 @@ fn truncated_directory_in_root() -> io::Result<()> {
#[test]
#[ignore]
fn git_repo_root() -> io::Result<()> {
- let tmp_dir = TempDir::new()?;
+ let tmp_dir = TempDir::new_in(home_dir().unwrap())?;
let repo_dir = tmp_dir.path().join("rocket-controls");
fs::create_dir(&repo_dir)?;
@@ -117,7 +117,7 @@ fn git_repo_root() -> io::Result<()> {
#[test]
#[ignore]
fn directory_in_git_repo() -> io::Result<()> {
- let tmp_dir = TempDir::new()?;
+ let tmp_dir = TempDir::new_in(home_dir().unwrap())?;
let repo_dir = tmp_dir.path().join("rocket-controls");
let dir = repo_dir.join("src");
fs::create_dir_all(&dir)?;
diff --git a/tests/python.rs b/tests/python.rs
index f497e5716..237c1f306 100644
--- a/tests/python.rs
+++ b/tests/python.rs
@@ -15,7 +15,7 @@ fn folder_with_python_version() -> io::Result<()> {
let expected = format!(
"via {} ",
Segment::new("python")
- .set_value("🐍 v3.7.2")
+ .set_value("🐍 v3.6.8")
.set_style(Color::Yellow.bold())
);
let actual = common::render_module("python", &dir.path());
@@ -33,7 +33,7 @@ fn folder_with_requirements_txt() -> io::Result<()> {
let expected = format!(
"via {} ",
Segment::new("python")
- .set_value("🐍 v3.7.2")
+ .set_value("🐍 v3.6.8")
.set_style(Color::Yellow.bold())
);
let actual = common::render_module("python", &dir.path());
@@ -51,7 +51,7 @@ fn folder_with_pyproject_toml() -> io::Result<()> {
let expected = format!(
"via {} ",
Segment::new("python")
- .set_value("🐍 v3.7.2")
+ .set_value("🐍 v3.6.8")
.set_style(Color::Yellow.bold())
);
let actual = common::render_module("python", &dir.path());
@@ -69,7 +69,7 @@ fn folder_with_py_file() -> io::Result<()> {
let expected = format!(
"via {} ",
Segment::new("python")
- .set_value("🐍 v3.7.2")
+ .set_value("🐍 v3.6.8")
.set_style(Color::Yellow.bold())
);
let actual = common::render_module("python", &dir.path());