mirror of
https://github.com/starship/starship.git
synced 2024-11-25 09:43:36 +01:00
ci: Fix CI to work with changes to Azure Pipelines build agent (#55)
This commit is contained in:
parent
90d6e6cf0b
commit
2cf69a82b7
@ -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' )
|
@ -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
|
||||
|
25
ci/azure-install-rust.yml
Normal file
25
ci/azure-install-rust.yml
Normal file
@ -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
|
16
ci/azure-rustfmt.yml
Normal file
16
ci/azure-rustfmt.yml
Normal file
@ -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
|
16
ci/azure-setup-test-env.yml
Normal file
16
ci/azure-setup-test-env.yml
Normal file
@ -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"
|
13
ci/azure-test-nightly.yml
Normal file
13
ci/azure-test-nightly.yml
Normal file
@ -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
|
23
ci/azure-test-stable.yml
Normal file
23
ci/azure-test-stable.yml
Normal file
@ -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
|
@ -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)]
|
||||
|
@ -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 \
|
||||
|
@ -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)?;
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user