ci: Publish crate to Crates.io with CI

This commit is contained in:
Matan Kushner 2019-07-31 19:27:35 -04:00
parent 9a2af45835
commit 616b50b4e3
5 changed files with 88 additions and 79 deletions

View File

@ -4,80 +4,80 @@ trigger:
tags: tags:
include: ["*"] include: ["*"]
jobs: stages:
# Check formatting - stage: Checks
- template: ci/rustfmt.yml jobs:
parameters: # Check formatting
name: rustfmt - template: ci/rustfmt.yml
displayName: Check formatting parameters:
name: rustfmt
displayName: Check formatting
# Run linter # Run linter
- template: ci/cargo-clippy.yml - template: ci/cargo-clippy.yml
parameters: parameters:
name: cargo_clippy name: cargo_clippy
displayName: Run linter displayName: Run linter
# Cargo check # Cargo check
- template: ci/cargo-check.yml - template: ci/cargo-check.yml
parameters: parameters:
name: cargo_check name: cargo_check
displayName: Cargo check displayName: Cargo check
############## - stage: Test
# Test stage # 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 stable # Test nightly
- template: ci/test.yml - template: ci/test.yml
parameters: parameters:
dependsOn: name: cargo_test_nightly
- cargo_check displayName: Cargo test
name: cargo_test_stable rust_version: nightly
displayName: Cargo test
cross: true # Test on Windows and macOS
# Test nightly # Test docker
- template: ci/test.yml # Runs integration tests as a starship developer would run them locally
parameters: - template: ci/test-docker.yml
name: cargo_test_nightly parameters:
displayName: Cargo test name: test_docker
rust_version: nightly displayName: Docker test
# Test docker - stage: Release
# Runs integration tests as a starship developer would run them locally dependsOn:
- template: ci/test-docker.yml - Checks
parameters: - Test
name: test_docker condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
displayName: Docker test 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
################ # Publish package to Crates.io
# Release stage # - template: ci/cargo-publish.yml
################ parameters:
name: cargo_publish
# Release binary displayName: Publish to Crates.io
- 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

View File

@ -9,5 +9,5 @@ jobs:
steps: steps:
- template: install-rust.yml - 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 displayName: Run clippy

15
ci/cargo-publish.yml Normal file
View File

@ -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

View File

@ -3,15 +3,12 @@ parameters:
github: github:
isPreRelease: false isPreRelease: false
repositoryName: "$(Build.Repository.Name)" repositoryName: "$(Build.Repository.Name)"
dependsOn: []
displayName: "Release to GitHub" displayName: "Release to GitHub"
archiveName: "$(Build.Repository.Name)" archiveName: "$(Build.Repository.Name)"
jobs: jobs:
- job: ${{ parameters.name }} - job: ${{ parameters.name }}
condition: ${{ parameters.condition }}
displayName: ${{ parameters.displayName }} displayName: ${{ parameters.displayName }}
dependsOn: ${{ parameters.dependsOn }}
pool: pool:
vmImage: ubuntu-16.04 vmImage: ubuntu-16.04
steps: steps:
@ -63,9 +60,7 @@ jobs:
- ${{ each build_target in parameters.targets }}: - ${{ each build_target in parameters.targets }}:
- ${{ if eq(build_target, 'x86_64-apple-darwin') }}: - ${{ if eq(build_target, 'x86_64-apple-darwin') }}:
- job: ${{ parameters.name }}_macOS - job: ${{ parameters.name }}_macOS
condition: ${{ parameters.condition }}
displayName: ${{ parameters.displayName }} (macOS) displayName: ${{ parameters.displayName }} (macOS)
dependsOn: ${{ parameters.dependsOn }}
pool: pool:
vmImage: macOS-10.13 vmImage: macOS-10.13
steps: steps:
@ -114,9 +109,7 @@ jobs:
- ${{ if eq(build_target, 'x86_64-pc-windows-msvc') }}: - ${{ if eq(build_target, 'x86_64-pc-windows-msvc') }}:
- job: ${{ parameters.name }}_msvc - job: ${{ parameters.name }}_msvc
condition: ${{ parameters.condition }}
displayName: ${{ parameters.displayName }} (Windows) displayName: ${{ parameters.displayName }} (Windows)
dependsOn: ${{ parameters.dependsOn }}
pool: pool:
vmImage: vs2017-win2016 vmImage: vs2017-win2016
steps: steps:

View File

@ -149,6 +149,7 @@ impl Config for Table {
} }
} }
mod tests { mod tests {
use super::*; use super::*;