diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 73568a16b..73118a3f9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,80 +4,80 @@ trigger: tags: include: ["*"] -jobs: - # Check formatting - - template: ci/rustfmt.yml - parameters: - name: rustfmt - displayName: Check formatting +stages: + - stage: Checks + jobs: + # Check formatting + - template: ci/rustfmt.yml + parameters: + name: rustfmt + displayName: Check formatting - # Run linter - - template: ci/cargo-clippy.yml - parameters: - name: cargo_clippy - displayName: Run linter + # Run linter + - template: ci/cargo-clippy.yml + parameters: + name: cargo_clippy + displayName: Run linter - # Cargo check - - template: ci/cargo-check.yml - parameters: - name: cargo_check - displayName: Cargo check + # Cargo check + - template: ci/cargo-check.yml + parameters: + name: cargo_check + displayName: Cargo check + + - stage: Test + dependsOn: Checks + jobs: + # Test stable + - template: ci/test.yml + parameters: + name: cargo_test_stable + displayName: Cargo test + cross: true # Test on Windows and macOS - ############## - # Test stage # - ############## + # Test nightly + - template: ci/test.yml + parameters: + name: cargo_test_nightly + displayName: Cargo test + rust_version: nightly - # Test stable - - template: ci/test.yml - parameters: - dependsOn: - - cargo_check - name: cargo_test_stable - displayName: Cargo test - cross: true # Test on Windows and macOS + # Test docker + # Runs integration tests as a starship developer would run them locally + - template: ci/test-docker.yml + parameters: + name: test_docker + displayName: Docker test - # Test nightly - - template: ci/test.yml - parameters: - name: cargo_test_nightly - displayName: Cargo test - rust_version: nightly + - stage: Release + dependsOn: + - Checks + - Test + condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) + jobs: + # Release binary on GitHub + - template: ci/github-release.yml + parameters: + name: github_release + rust_version: stable + contents: | + * + !*.rlib + !*.d + !.* + targets: + - x86_64-unknown-linux-gnu + # Windows support temporarily disabled + # - x86_64-pc-windows-gnu + # - x86_64-pc-windows-msvc + - x86_64-apple-darwin + github: + gitHubConnection: StarshipRelease + repositoryName: starship/starship + isPreRelease: false - # Test docker - # Runs integration tests as a starship developer would run them locally - - template: ci/test-docker.yml - parameters: - name: test_docker - displayName: Docker test - - ################ - # Release stage # - ################ - - # Release binary - - template: ci/github-release.yml - parameters: - name: github_release - dependsOn: - - rustfmt - - cargo_check - - cargo_clippy - - cargo_test_stable - - test_docker - rust_version: stable - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) - contents: | - * - !*.rlib - !*.d - !.* - targets: - - x86_64-unknown-linux-gnu - # Windows support temporarily disabled - # - x86_64-pc-windows-gnu - # - x86_64-pc-windows-msvc - - x86_64-apple-darwin - github: - gitHubConnection: StarshipRelease - repositoryName: starship/starship - isPreRelease: false + # Publish package to Crates.io + - template: ci/cargo-publish.yml + parameters: + name: cargo_publish + displayName: Publish to Crates.io diff --git a/ci/cargo-clippy.yml b/ci/cargo-clippy.yml index 218d2160c..76680ceb7 100644 --- a/ci/cargo-clippy.yml +++ b/ci/cargo-clippy.yml @@ -9,5 +9,5 @@ jobs: steps: - template: install-rust.yml - - script: cargo clippy --all + - script: cargo clippy -- -D warnings -D clippy::all -D clippy::nursery -D clippy::pedantic displayName: Run clippy diff --git a/ci/cargo-publish.yml b/ci/cargo-publish.yml new file mode 100644 index 000000000..7d5141c84 --- /dev/null +++ b/ci/cargo-publish.yml @@ -0,0 +1,15 @@ +parameters: + rust_version: stable + +jobs: + - job: ${{ parameters.name }} + displayName: ${{ parameters.displayName }} + pool: + vmImage: ubuntu-16.04 + steps: + - template: install-rust.yml + + - script: | + cargo login $(CARGO_TOKEN) + cargo publish + displayName: Publish package to Crates.io diff --git a/ci/github-release.yml b/ci/github-release.yml index 7b86d4448..68167d230 100644 --- a/ci/github-release.yml +++ b/ci/github-release.yml @@ -3,15 +3,12 @@ parameters: github: isPreRelease: false repositoryName: "$(Build.Repository.Name)" - dependsOn: [] displayName: "Release to GitHub" archiveName: "$(Build.Repository.Name)" jobs: - job: ${{ parameters.name }} - condition: ${{ parameters.condition }} displayName: ${{ parameters.displayName }} - dependsOn: ${{ parameters.dependsOn }} pool: vmImage: ubuntu-16.04 steps: @@ -63,9 +60,7 @@ jobs: - ${{ each build_target in parameters.targets }}: - ${{ if eq(build_target, 'x86_64-apple-darwin') }}: - job: ${{ parameters.name }}_macOS - condition: ${{ parameters.condition }} displayName: ${{ parameters.displayName }} (macOS) - dependsOn: ${{ parameters.dependsOn }} pool: vmImage: macOS-10.13 steps: @@ -114,9 +109,7 @@ jobs: - ${{ if eq(build_target, 'x86_64-pc-windows-msvc') }}: - job: ${{ parameters.name }}_msvc - condition: ${{ parameters.condition }} displayName: ${{ parameters.displayName }} (Windows) - dependsOn: ${{ parameters.dependsOn }} pool: vmImage: vs2017-win2016 steps: diff --git a/src/config.rs b/src/config.rs index c06541eeb..92073b5f6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -149,6 +149,7 @@ impl Config for Table { } } + mod tests { use super::*;