mirror of
https://github.com/starship/starship.git
synced 2024-11-26 02:04:12 +01:00
ci: Add GitHub releases to CI (#95)
This commit is contained in:
parent
77ba97df19
commit
0703a74048
@ -1,23 +1,77 @@
|
||||
jobs:
|
||||
# Check formatting
|
||||
- template: ci/azure-rustfmt.yml
|
||||
- template: ci/rustfmt.yml
|
||||
parameters:
|
||||
name: rustfmt
|
||||
displayName: Check formatting
|
||||
|
||||
# Test with Rust stable
|
||||
- template: ci/azure-test-stable.yml
|
||||
# Run linter
|
||||
- template: ci/cargo-clippy.yml
|
||||
parameters:
|
||||
name: test_starship
|
||||
displayName: Test starship
|
||||
name: cargo_clippy
|
||||
displayName: Run linter
|
||||
|
||||
# Test with Rust nightly
|
||||
- template: ci/azure-test-nightly.yml
|
||||
# Cargo check
|
||||
- template: ci/cargo-check.yml
|
||||
parameters:
|
||||
name: test_nightly
|
||||
displayName: Check starship with nightly
|
||||
name: cargo_check
|
||||
displayName: Cargo check
|
||||
|
||||
# Run the integration tests in a Docker container
|
||||
- template: ci/azure-test-docker.yml
|
||||
parameters:
|
||||
##############
|
||||
# Test stage #
|
||||
##############
|
||||
|
||||
# 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 nightly
|
||||
- template: ci/test.yml
|
||||
parameters:
|
||||
name: cargo_test_nightly
|
||||
displayName: Cargo test
|
||||
rust_version: nightly
|
||||
|
||||
# Test docker
|
||||
# Runs integration tests as a starship developer would run them locally
|
||||
- template: ci/test-docker.yml
|
||||
parameters:
|
||||
name: test_docker
|
||||
displayName: Test starship 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: true
|
||||
|
@ -1,16 +0,0 @@
|
||||
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
|
@ -1,13 +0,0 @@
|
||||
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
|
@ -1,26 +0,0 @@
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: ${{ parameters.displayName }}
|
||||
strategy:
|
||||
matrix:
|
||||
Linux:
|
||||
vmImage: ubuntu-16.04
|
||||
MacOS:
|
||||
vmImage: macOS-10.13
|
||||
# # Temporarily disabling Windows tests while I'm away
|
||||
# # Will reenable Windows tests once I'm able to troubleshoot Windows bugs
|
||||
# Windows:
|
||||
# vmImage: vs2017-win2016
|
||||
pool:
|
||||
vmImage: $(vmImage)
|
||||
|
||||
steps:
|
||||
- template: azure-install-rust.yml
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
- template: azure-setup-test-env.yml
|
||||
|
||||
# "-Z unstable-options" is required for "--include-ignored"
|
||||
- script: cargo test -- -Z unstable-options --include-ignored
|
||||
displayName: cargo test
|
13
ci/cargo-check.yml
Normal file
13
ci/cargo-check.yml
Normal file
@ -0,0 +1,13 @@
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: ${{ parameters.displayName }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: install-rust.yml
|
||||
|
||||
- script: cargo check
|
||||
displayName: Check features
|
13
ci/cargo-clippy.yml
Normal file
13
ci/cargo-clippy.yml
Normal file
@ -0,0 +1,13 @@
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: ${{ parameters.displayName }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: install-rust.yml
|
||||
|
||||
- script: cargo clippy --all
|
||||
displayName: Run clippy
|
166
ci/github-release.yml
Normal file
166
ci/github-release.yml
Normal file
@ -0,0 +1,166 @@
|
||||
parameters:
|
||||
rust_version: stable
|
||||
github:
|
||||
isPreRelease: false
|
||||
repositoryName: "$(Build.Repository.Name)"
|
||||
dependsOn: []
|
||||
displayName: "Release to github"
|
||||
tarCompression: "none"
|
||||
archiveType: "zip"
|
||||
archiveName: "$(Build.Repository.Name)"
|
||||
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
condition: ${{ parameters.condition }}
|
||||
displayName: ${{ parameters.displayName }}
|
||||
dependsOn: ${{ parameters.dependsOn }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: install-cross-rust.yml
|
||||
|
||||
- bash: |
|
||||
MY_TAG="$(Build.SourceBranch)"
|
||||
MY_TAG=${MY_TAG#refs/tags/}
|
||||
echo $MY_TAG
|
||||
echo "##vso[task.setvariable variable=build.my_tag]$MY_TAG"
|
||||
DATE="$(date +%Y-%m-%d)"
|
||||
echo "##vso[task.setvariable variable=build.date]$DATE"
|
||||
displayName: "Create date and tag variables"
|
||||
- ${{ each build_target in parameters.targets }}:
|
||||
- ? ${{ if not(or(eq(build_target, 'x86_64-apple-darwin'), eq(build_target, 'x86_64-pc-windows-msvc'))) }}
|
||||
: - script: |
|
||||
echo Start building ${{ build_target }}
|
||||
cross build --target ${{ build_target }} --release
|
||||
ls -l
|
||||
ls -l target/${{ build_target }}/release/*
|
||||
displayName: Relase build for target ${{ build_target }}
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy files for target ${{ build_target }}
|
||||
inputs:
|
||||
sourceFolder: "$(Build.SourcesDirectory)/target/${{ build_target }}/release"
|
||||
contents: ${{ parameters.contents }}
|
||||
targetFolder: "$(Build.BinariesDirectory)/${{ build_target }}"
|
||||
- task: ArchiveFiles@2
|
||||
displayName: Gather assets
|
||||
inputs:
|
||||
rootFolderOrFile: "$(Build.BinariesDirectory)/${{ build_target }}"
|
||||
archiveType: ${{ parameters.archiveType }}
|
||||
tarCompression: ${{ parameters.tarCompression }}
|
||||
archiveFile: "$(Build.ArtifactStagingDirectory)/${{ parameters.archiveName }}-$(build.my_tag)-${{ build_target }}.zip"
|
||||
|
||||
- task: GitHubRelease@0
|
||||
displayName: Create release
|
||||
inputs:
|
||||
gitHubConnection: ${{ parameters.github.gitHubConnection }}
|
||||
tagSource: manual
|
||||
title: "$(build.my_tag) - $(build.date)"
|
||||
tag: "$(build.my_tag)"
|
||||
assetUploadMode: replace
|
||||
action: edit
|
||||
assets: "$(Build.ArtifactStagingDirectory)/${{ parameters.archiveName }}*"
|
||||
repositoryName: ${{ parameters.github.repositoryName }}
|
||||
isPreRelease: ${{ parameters.github.isPreRelease }}
|
||||
|
||||
- ${{ 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:
|
||||
- template: install-rust.yml
|
||||
|
||||
- bash: |
|
||||
MY_TAG="$(Build.SourceBranch)"
|
||||
MY_TAG=${MY_TAG#refs/tags/}
|
||||
echo $MY_TAG
|
||||
echo "##vso[task.setvariable variable=build.my_tag]$MY_TAG"
|
||||
DATE="$(date +%Y-%m-%d)"
|
||||
echo "##vso[task.setvariable variable=build.date]$DATE"
|
||||
displayName: "Create date and tag variables"
|
||||
- script: |
|
||||
echo Start building ${{ build_target }}
|
||||
cargo build --release
|
||||
ls -l
|
||||
ls -l target/release/*
|
||||
displayName: Relase build for target ${{ build_target }}
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy files for target ${{ build_target }}
|
||||
inputs:
|
||||
sourceFolder: "$(Build.SourcesDirectory)/target/release"
|
||||
contents: ${{ parameters.contents }}
|
||||
targetFolder: "$(Build.BinariesDirectory)/${{ build_target }}"
|
||||
- task: ArchiveFiles@2
|
||||
displayName: Gather assets
|
||||
inputs:
|
||||
rootFolderOrFile: "$(Build.BinariesDirectory)/${{ build_target }}"
|
||||
archiveType: ${{ parameters.archiveType }}
|
||||
tarCompression: ${{ parameters.tarCompression }}
|
||||
archiveFile: "$(Build.ArtifactStagingDirectory)/${{ parameters.archiveName }}-$(build.my_tag)-${{ build_target }}.zip"
|
||||
|
||||
- task: GitHubRelease@0
|
||||
displayName: Create release
|
||||
inputs:
|
||||
gitHubConnection: ${{ parameters.github.gitHubConnection }}
|
||||
tagSource: manual
|
||||
title: "$(build.my_tag) - $(build.date)"
|
||||
tag: "$(build.my_tag)"
|
||||
assetUploadMode: replace
|
||||
action: edit
|
||||
assets: "$(Build.ArtifactStagingDirectory)/${{ parameters.archiveName }}*"
|
||||
repositoryName: ${{ parameters.github.repositoryName }}
|
||||
isPreRelease: ${{ parameters.github.isPreRelease }}
|
||||
|
||||
- ${{ 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:
|
||||
- template: install-rust.yml
|
||||
|
||||
- bash: |
|
||||
MY_TAG="$(Build.SourceBranch)"
|
||||
MY_TAG=${MY_TAG#refs/tags/}
|
||||
echo $MY_TAG
|
||||
echo "##vso[task.setvariable variable=build.my_tag]$MY_TAG"
|
||||
DATE="$(date +%Y-%m-%d)"
|
||||
echo "##vso[task.setvariable variable=build.date]$DATE"
|
||||
displayName: "Create date and tag variables"
|
||||
- script: |
|
||||
echo Start building ${{ build_target }}
|
||||
cargo build --release
|
||||
ls -l
|
||||
ls -l target/release/*
|
||||
displayName: Relase build for target ${{ build_target }}
|
||||
- task: CopyFiles@2
|
||||
displayName: Copy files for target ${{ build_target }}
|
||||
inputs:
|
||||
sourceFolder: "$(Build.SourcesDirectory)/target/release"
|
||||
contents: ${{ parameters.contents }}
|
||||
targetFolder: "$(Build.BinariesDirectory)/${{ build_target }}"
|
||||
- task: ArchiveFiles@2
|
||||
displayName: Gather assets
|
||||
inputs:
|
||||
rootFolderOrFile: "$(Build.BinariesDirectory)/${{ build_target }}"
|
||||
archiveType: ${{ parameters.archiveType }}
|
||||
tarCompression: ${{ parameters.tarCompression }}
|
||||
archiveFile: "$(Build.ArtifactStagingDirectory)/${{ parameters.archiveName }}-$(build.my_tag)-${{ build_target }}.zip"
|
||||
|
||||
- task: GitHubRelease@0
|
||||
displayName: Create release
|
||||
inputs:
|
||||
gitHubConnection: ${{ parameters.github.gitHubConnection }}
|
||||
tagSource: manual
|
||||
title: "$(build.my_tag) - $(build.date)"
|
||||
tag: "$(build.my_tag)"
|
||||
assetUploadMode: replace
|
||||
action: edit
|
||||
assets: "$(Build.ArtifactStagingDirectory)/${{ parameters.archiveName }}*"
|
||||
repositoryName: ${{ parameters.github.repositoryName }}
|
||||
isPreRelease: ${{ parameters.github.isPreRelease }}
|
47
ci/install-cross-rust.yml
Normal file
47
ci/install-cross-rust.yml
Normal file
@ -0,0 +1,47 @@
|
||||
# defaults for any parameters that aren't specified
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
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')
|
||||
# Install additional components:
|
||||
- ${{ each component in parameters.components }}:
|
||||
- script: rustup component add ${{ component }}
|
||||
|
||||
# TEMPORATY FIX UNTIL https://github.com/rust-embedded/cross/pull/169 is merged.
|
||||
- script: |
|
||||
git config --global user.email "not_necessery@dont.need"
|
||||
git config --global user.name "I merge the things"
|
||||
git clone https://github.com/rust-embedded/cross
|
||||
cd cross
|
||||
git remote add pitkley https://github.com/pitkley/cross
|
||||
git fetch pitkley
|
||||
git checkout 718a19c
|
||||
git merge -m "No pseudo tty" pitkley/docker-no-pseudo-tty
|
||||
cargo install --force --path .
|
||||
displayName: Instaling cross supprot
|
||||
# All platforms
|
||||
- script: |
|
||||
rustup -V
|
||||
rustup component list --installed
|
||||
rustc -Vv
|
||||
cargo -V
|
||||
displayName: Query rust and cargo versions
|
@ -1,3 +1,7 @@
|
||||
# defaults for any parameters that aren't specified
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
steps:
|
||||
# Linux and macOS
|
||||
- script: |
|
||||
@ -18,8 +22,14 @@ steps:
|
||||
RUSTUP_TOOLCHAIN: ${{parameters.rust_version}}
|
||||
displayName: "Install rust (windows)"
|
||||
condition: eq(variables['Agent.OS'], 'Windows_NT')
|
||||
# All platforms.
|
||||
# Install additional components:
|
||||
- ${{ each component in parameters.components }}:
|
||||
- script: rustup component add ${{ component }}
|
||||
|
||||
# All platforms
|
||||
- script: |
|
||||
rustc -Vv
|
||||
cargo -V
|
||||
rustup -V
|
||||
rustup component list --installed
|
||||
rustc -Vv
|
||||
cargo -V
|
||||
displayName: Query rust and cargo versions
|
16
ci/rustfmt.yml
Normal file
16
ci/rustfmt.yml
Normal file
@ -0,0 +1,16 @@
|
||||
jobs:
|
||||
# Check formatting
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: Check rustfmt
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: install-rust.yml
|
||||
parameters:
|
||||
rust_version: stable
|
||||
- script: |
|
||||
rustup component add rustfmt
|
||||
displayName: Install rustfmt
|
||||
- script: |
|
||||
cargo fmt --all -- --check
|
||||
displayName: Check formatting
|
28
ci/test.yml
Normal file
28
ci/test.yml
Normal file
@ -0,0 +1,28 @@
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: ${{ parameters.displayName }} ${{parameters.rust_version}}
|
||||
strategy:
|
||||
matrix:
|
||||
Linux:
|
||||
vmImage: ubuntu-16.04
|
||||
|
||||
${{ if parameters.cross }}:
|
||||
MacOS:
|
||||
vmImage: macOS-10.13
|
||||
# Temporarily disable Windows support
|
||||
# Windows:
|
||||
# vmImage: vs2017-win2016
|
||||
pool:
|
||||
vmImage: $(vmImage)
|
||||
|
||||
steps:
|
||||
- template: install-rust.yml
|
||||
- template: setup-test-env.yml
|
||||
- script: |
|
||||
cargo test -- -Z unstable-options --include-ignored
|
||||
env:
|
||||
CI: "true"
|
||||
displayName: cargo test
|
@ -146,7 +146,7 @@ impl<'a> ScanDir<'a> {
|
||||
|
||||
/// checks to see if the pathbuf matches a file or folder name
|
||||
pub fn path_has_name<'a>(dir_entry: &PathBuf, names: &'a [&'a str]) -> bool {
|
||||
let found_file_or_folder_name = names.into_iter().find(|file_or_folder_name| {
|
||||
let found_file_or_folder_name = names.iter().find(|file_or_folder_name| {
|
||||
dir_entry
|
||||
.file_name()
|
||||
.and_then(OsStr::to_str)
|
||||
@ -162,7 +162,7 @@ pub fn path_has_name<'a>(dir_entry: &PathBuf, names: &'a [&'a str]) -> bool {
|
||||
|
||||
/// checks if pathbuf matches the extension provided
|
||||
pub fn has_extension<'a>(dir_entry: &PathBuf, extensions: &'a [&'a str]) -> bool {
|
||||
let found_ext = extensions.into_iter().find(|ext| {
|
||||
let found_ext = extensions.iter().find(|ext| {
|
||||
dir_entry
|
||||
.extension()
|
||||
.and_then(OsStr::to_str)
|
||||
|
@ -30,11 +30,3 @@ pub fn init(shell_name: &str) {
|
||||
print!("{}", script);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Shell {
|
||||
Bash,
|
||||
Fish,
|
||||
Zsh,
|
||||
Unsupported(String),
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ fn truncate(dir_string: String, length: usize) -> String {
|
||||
return dir_string;
|
||||
}
|
||||
|
||||
let components = dir_string.split("/").collect::<Vec<&str>>();
|
||||
let components = dir_string.split('/').collect::<Vec<&str>>();
|
||||
if components.len() <= length {
|
||||
return dir_string;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ fn get_rust_version() -> Option<String> {
|
||||
}
|
||||
|
||||
fn format_rustc_version(mut rustc_stdout: String) -> String {
|
||||
let offset = &rustc_stdout.find('(').unwrap_or(rustc_stdout.len());
|
||||
let offset = &rustc_stdout.find('(').unwrap_or_else(|| rustc_stdout.len());
|
||||
let formatted_version: String = rustc_stdout.drain(..offset).collect();
|
||||
|
||||
format!("v{}", formatted_version.replace("rustc", "").trim())
|
||||
|
Loading…
Reference in New Issue
Block a user