mirror of
https://github.com/starship/starship.git
synced 2024-12-23 23:58:51 +01:00
ci: Migrate CI from Azure Pipelines to GitHub Actions (#233)
Migrated CI from Azure Pipelines to GitHub Actions. Until the release process is figured out in Actions, we'll stick to using Azure pipelines for releases.
This commit is contained in:
parent
68754208c1
commit
e66d7bae1c
93
.github/workflows/continuous-integration.yml
vendored
Normal file
93
.github/workflows/continuous-integration.yml
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
name: Continuous Integration
|
||||
on: push
|
||||
jobs:
|
||||
# Run the `rustfmt` code formatter
|
||||
rustfmt:
|
||||
name: Rustfmt [Formatter]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: hecrj/setup-rust-action@master
|
||||
- uses: actions/checkout@master
|
||||
- name: Install rustfmt
|
||||
run: rustup component add rustfmt
|
||||
- name: Run rustfmt
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
# Run the `clippy` linting tool
|
||||
clippy:
|
||||
name: Clippy [Linter]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: hecrj/setup-rust-action@master
|
||||
- uses: actions/checkout@master
|
||||
- name: Install clippy
|
||||
run: rustup component add clippy
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-targets --all-features -- -D clippy::all
|
||||
|
||||
# Ensure that the project could be successfully compiled
|
||||
cargo_check:
|
||||
name: Compile
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: hecrj/setup-rust-action@master
|
||||
- uses: actions/checkout@master
|
||||
- run: cargo check --all
|
||||
|
||||
# Run tests on Linux, and macOS
|
||||
# On both Rust stable and Rust nightly
|
||||
test:
|
||||
name: Test Suite
|
||||
needs: [rustfmt, clippy, cargo_check]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest]
|
||||
rust: [stable, nightly]
|
||||
steps:
|
||||
# Install all the required dependencies for testing
|
||||
- uses: hecrj/setup-rust-action@master
|
||||
with:
|
||||
rust-version: ${{ matrix.rust }}
|
||||
|
||||
# Install Node.js at a fixed version
|
||||
- uses: actions/setup-node@master
|
||||
with:
|
||||
node-version: "12.0.0"
|
||||
|
||||
# Install Golang at a fixed version
|
||||
- uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: "1.12.1"
|
||||
|
||||
# Install Ruby at a fixed version
|
||||
- uses: actions/setup-ruby@master
|
||||
with:
|
||||
ruby-version: "2.6.3"
|
||||
|
||||
# Install Python at a fixed version
|
||||
- uses: actions/setup-python@master
|
||||
with:
|
||||
python-version: "3.6.9"
|
||||
|
||||
# Run the ignored tests that expect the above setup
|
||||
- uses: actions/checkout@master
|
||||
- name: Run all tests
|
||||
run: cargo test -- -Z unstable-options --include-ignored
|
||||
|
||||
# Run the tests in the Docker image
|
||||
docker_test:
|
||||
name: Test in Docker
|
||||
needs: [rustfmt, clippy, cargo_check]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Pull the pre-built Docker image
|
||||
run: docker pull starshipcommand/starship-test
|
||||
- name: Fix file permissions
|
||||
run: chmod -R a+w .
|
||||
- name: Build the Docker image
|
||||
run: docker build -f tests/Dockerfile --tag starshipcommand/starship-test --cache-from starshipcommand/starship-test .
|
||||
- name: Run tests in Docker
|
||||
run: docker run --rm -v $(pwd):/src/starship starshipcommand/starship-test
|
@ -1,59 +1,10 @@
|
||||
trigger:
|
||||
branches:
|
||||
include: ["*"]
|
||||
tags:
|
||||
include: ["*"]
|
||||
|
||||
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
|
||||
|
||||
# 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 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: Docker test
|
||||
|
||||
- stage: Release
|
||||
dependsOn:
|
||||
- Checks
|
||||
- Test
|
||||
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
||||
jobs:
|
||||
# Release binary on GitHub
|
||||
- template: ci/github-release.yml
|
||||
|
@ -1,13 +0,0 @@
|
||||
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
|
@ -1,13 +0,0 @@
|
||||
parameters:
|
||||
rust_version: stable
|
||||
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: ${{ parameters.displayName }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: install-rust.yml
|
||||
|
||||
- script: cargo clippy -- -D clippy::all
|
||||
displayName: Run clippy
|
@ -1,16 +0,0 @@
|
||||
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
|
@ -1,32 +0,0 @@
|
||||
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 Ruby
|
||||
- task: UseRubyVersion@0
|
||||
inputs:
|
||||
versionSpec: "2.5.5"
|
||||
displayName: "Install a fixed version of Ruby"
|
||||
|
||||
# We are using pyenv to install Python for integration tests
|
||||
# Install Python
|
||||
- script: |
|
||||
echo "##vso[task.setvariable variable=PYTHON_VERSION;]3.6.9"
|
||||
echo "##vso[task.setvariable variable=PYENV_ROOT;]$HOME/.pyenv"
|
||||
- script: |
|
||||
curl https://pyenv.run | bash
|
||||
echo "##vso[task.setvariable variable=PATH;]$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
|
||||
- script: |
|
||||
eval "$(pyenv init -)"
|
||||
pyenv install $PYTHON_VERSION
|
||||
pyenv global $PYTHON_VERSION
|
||||
displayName: "Install a fixed version of Python"
|
@ -1,23 +0,0 @@
|
||||
jobs:
|
||||
- job: ${{ parameters.name }}
|
||||
displayName: ${{ parameters.displayName }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
|
||||
steps:
|
||||
- script: docker pull starshipcommand/starship-test
|
||||
displayName: Pull docker image
|
||||
|
||||
- script: |
|
||||
# In order to run tests as a non-root user in docker,
|
||||
# the files need to be accessible to non-root users
|
||||
chmod -R a+w .
|
||||
./integration_test
|
||||
displayName: Run integration test suite
|
||||
|
||||
- script: |
|
||||
docker login -u $(dockerUsername) -p $(dockerPassword)
|
||||
docker push starshipcommand/starship-test
|
||||
# Only push new image if on master and build is passing
|
||||
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
displayName: Push image to dockerhub
|
28
ci/test.yml
28
ci/test.yml
@ -1,28 +0,0 @@
|
||||
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
|
@ -4,8 +4,6 @@ use std::process::Command;
|
||||
|
||||
use ansi_term::Color;
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
use super::{Context, Module};
|
||||
|
||||
/// Creates a module with the current Python version
|
||||
|
@ -16,7 +16,7 @@ RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | ba
|
||||
RUN node --version
|
||||
|
||||
# Install Go
|
||||
ENV GO_VERSION 1.10.0
|
||||
ENV GO_VERSION 1.12.1
|
||||
ENV GOENV_ROOT /home/nonroot/.goenv
|
||||
ENV PATH $GOENV_ROOT/bin:$GOENV_ROOT/shims:$PATH
|
||||
RUN git clone https://github.com/syndbg/goenv.git $GOENV_ROOT \
|
||||
@ -28,7 +28,7 @@ RUN git clone https://github.com/syndbg/goenv.git $GOENV_ROOT \
|
||||
RUN go version
|
||||
|
||||
# Install Ruby
|
||||
ENV RUBY_VERSION 2.5.5
|
||||
ENV RUBY_VERSION 2.6.3
|
||||
ENV RBENV_ROOT /home/nonroot/.rbenv
|
||||
ENV PATH $RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH
|
||||
RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash \
|
||||
|
@ -90,13 +90,13 @@ fn test_truncate_length(
|
||||
expected_name: &str,
|
||||
truncation_symbol: &str,
|
||||
) -> io::Result<()> {
|
||||
return test_truncate_length_with_config(
|
||||
test_truncate_length_with_config(
|
||||
branch_name,
|
||||
truncate_length,
|
||||
expected_name,
|
||||
truncation_symbol,
|
||||
"",
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
fn test_truncate_length_with_config(
|
||||
|
@ -31,7 +31,7 @@ fn folder_with_go_file() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -48,7 +48,7 @@ fn folder_with_go_mod() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -65,7 +65,7 @@ fn folder_with_go_sum() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -83,7 +83,7 @@ fn folder_with_godeps() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -100,7 +100,7 @@ fn folder_with_glide_yaml() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -117,7 +117,7 @@ fn folder_with_gopkg_yml() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -134,7 +134,7 @@ fn folder_with_gopkg_lock() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.10"));
|
||||
let expected = format!("via {} ", Color::Cyan.bold().paint("🐹 v1.12.1"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
use ansi_term::Color;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::common::{self, TestCommand};
|
||||
|
||||
|
@ -4,7 +4,6 @@ use std::io;
|
||||
use ansi_term::Color;
|
||||
|
||||
use crate::common;
|
||||
use crate::common::TestCommand;
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
@ -110,42 +109,3 @@ fn with_virtual_env() -> io::Result<()> {
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn with_pyenv() -> io::Result<()> {
|
||||
let dir = common::new_tempdir()?;
|
||||
File::create(dir.path().join("main.py"))?;
|
||||
let output = common::render_module("python")
|
||||
.use_config(toml::toml! {
|
||||
[python]
|
||||
pyenv_version_name = true
|
||||
})
|
||||
.env("VIRTUAL_ENV", "/foo/bar/my_venv")
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 pyenv system"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn with_pyenv_no_output() -> io::Result<()> {
|
||||
let dir = common::new_tempdir()?;
|
||||
File::create(dir.path().join("main.py"))?;
|
||||
let output = common::render_module("python")
|
||||
.use_config(toml::toml! {
|
||||
[python]
|
||||
pyenv_version_name = true
|
||||
})
|
||||
.env("PATH", "")
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
assert_eq!("", actual);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use ansi_term::Color;
|
||||
use std::fs::{self, File};
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
|
||||
use crate::common;
|
||||
@ -31,7 +31,7 @@ fn folder_with_gemfile() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Red.bold().paint("💎 v2.5.5"));
|
||||
let expected = format!("via {} ", Color::Red.bold().paint("💎 v2.6.3"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
@ -48,7 +48,7 @@ fn folder_with_rb_file() -> io::Result<()> {
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Red.bold().paint("💎 v2.5.5"));
|
||||
let expected = format!("via {} ", Color::Red.bold().paint("💎 v2.6.3"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user