summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-09-04 19:13:53 -0400
committerGitHub <noreply@github.com>2019-09-04 19:13:53 -0400
commite66d7bae1cdf753d4106980fa35305a8375cb73a (patch)
treeaf969600f2c0256a62f4211cefa1132e50be63ee
parent68754208c1fae976c71747fe87d8ab558922cd3f (diff)
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.
-rw-r--r--.github/workflows/continuous-integration.yml93
-rw-r--r--azure-pipelines.yml51
-rw-r--r--ci/cargo-check.yml13
-rw-r--r--ci/cargo-clippy.yml13
-rw-r--r--ci/rustfmt.yml16
-rw-r--r--ci/setup-test-env.yml32
-rw-r--r--ci/test-docker.yml23
-rw-r--r--ci/test.yml28
-rw-r--r--src/modules/python.rs2
-rw-r--r--tests/Dockerfile4
-rw-r--r--tests/testsuite/git_branch.rs4
-rw-r--r--tests/testsuite/golang.rs14
-rw-r--r--tests/testsuite/jobs.rs3
-rw-r--r--tests/testsuite/python.rs40
-rw-r--r--tests/testsuite/ruby.rs6
15 files changed, 108 insertions, 234 deletions
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
new file mode 100644
index 000000000..b6dd1376e
--- /dev/null
+++ b/.github/workflows/continuous-integration.yml
@@ -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
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 73118a3f9..ca36fff9c 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -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
diff --git a/ci/cargo-check.yml b/ci/cargo-check.yml
deleted file mode 100644
index 5bdd2f4f1..000000000
--- a/ci/cargo-check.yml
+++ /dev/null
@@ -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
diff --git a/ci/cargo-clippy.yml b/ci/cargo-clippy.yml
deleted file mode 100644
index 154acfe26..000000000
--- a/ci/cargo-clippy.yml
+++ /dev/null
@@ -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
diff --git a/ci/rustfmt.yml b/ci/rustfmt.yml
deleted file mode 100644
index 0672cdb1b..000000000
--- a/ci/rustfmt.yml
+++ /dev/null
@@ -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
diff --git a/ci/setup-test-env.yml b/ci/setup-test-env.yml
deleted file mode 100644
index e91e9453d..000000000
--- a/ci/setup-test-env.yml
+++ /dev/null
@@ -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"
diff --git a/ci/test-docker.yml b/ci/test-docker.yml
deleted file mode 100644
index 99a7d5078..000000000
--- a/ci/test-docker.yml
+++ /dev/null
@@ -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
diff --git a/ci/test.yml b/ci/test.yml
deleted file mode 100644
index ddde2722f..000000000
--- a/ci/test.yml
+++ /dev/null
@@ -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
diff --git a/src/modules/python.rs b/src/modules/python.rs
index d465e6da5..e12511633 100644
--- a/src/modules/python.rs
+++ b/src/modules/python.rs
@@ -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
diff --git a/tests/Dockerfile b/tests/Dockerfile
index 8a9dfae00..f7fcae661 100644
--- a/tests/Dockerfile
+++ b/tests/Dockerfile
@@ -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 \
diff --git a/tests/testsuite/git_branch.rs b/tests/testsuite/git_branch.rs
index c1cd31015..d7f64850c 100644
--- a/tests/testsuite/git_branch.rs
+++ b/tests/testsuite/git_branch.rs
@@ -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(
diff --git a/tests/testsuite/golang.rs b/tests/testsuite/golang.rs
index c63e25c0b..b5d37bc1f 100644
--- a/tests/testsuite/golang.rs
+++ b/tests/testsuite/golang.rs
@@ -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(())
}
diff --git a/tests/testsuite/jobs.rs b/tests/testsuite/jobs.rs
index 885684abb..b69e38035 100644
--- a/tests/testsuite/jobs.rs
+++ b/tests/testsuite/jobs.rs
@@ -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};
diff --git a/tests/testsuite/python.rs b/tests/testsuite/python.rs
index 6b90695a6..e978baba9 100644
--- a/tests/testsuite/python.rs
+++ b/tests/testsuite/python.rs
@@ -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(())
-}
diff --git a/tests/testsuite/ruby.rs b/tests/testsuite/ruby.rs
index f1911f6b4..e313c8ce3 100644
--- a/tests/testsuite/ruby.rs
+++ b/tests/testsuite/ruby.rs
@@ -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(())
}