2019-10-05 09:29:13 +00:00
|
|
|
name: Main workflow
|
2019-10-10 07:12:45 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths-ignore:
|
|
|
|
- "docs/**"
|
2019-10-14 15:34:26 +00:00
|
|
|
- "**.md"
|
2019-10-10 07:12:45 +00:00
|
|
|
pull_request: []
|
|
|
|
|
2019-10-04 06:12:48 +00:00
|
|
|
jobs:
|
|
|
|
# Run the `rustfmt` code formatter
|
|
|
|
rustfmt:
|
|
|
|
name: Rustfmt [Formatter]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
- run: rustup component add rustfmt
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: fmt
|
|
|
|
args: --all -- --check
|
|
|
|
|
|
|
|
# Run the `clippy` linting tool
|
|
|
|
clippy:
|
|
|
|
name: Clippy [Linter]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
- run: rustup component add clippy
|
|
|
|
- uses: actions-rs/clippy-check@v1
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
args: --all-targets --all-features -- -D clippy::all
|
|
|
|
|
|
|
|
# Run a security audit on dependencies
|
|
|
|
cargo_audit:
|
|
|
|
name: Cargo Audit [Security]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
- run: cargo install --force cargo-audit
|
|
|
|
- run: cargo generate-lockfile
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: audit
|
|
|
|
|
|
|
|
# Ensure that the project could be successfully compiled
|
|
|
|
cargo_check:
|
|
|
|
name: Compile
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
- uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: check
|
|
|
|
args: --all
|
|
|
|
|
2019-10-15 15:10:16 +00:00
|
|
|
# Run tests on Linux, macOS, and Windows
|
2019-10-04 06:12:48 +00:00
|
|
|
# On both Rust stable and Rust nightly
|
|
|
|
test:
|
|
|
|
name: Test Suite
|
|
|
|
needs: [cargo_check]
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2019-10-15 15:10:16 +00:00
|
|
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
2019-10-04 06:12:48 +00:00
|
|
|
rust: [stable, nightly]
|
|
|
|
steps:
|
|
|
|
# Checkout the branch being tested
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
|
|
|
|
# Install all the required dependencies for testing
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
|
|
|
|
# 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:
|
2019-10-15 15:10:16 +00:00
|
|
|
python-version: "3.7.4"
|
2019-10-04 06:12:48 +00:00
|
|
|
|
|
|
|
# Install dotnet at a fixed version
|
|
|
|
- uses: actions/setup-dotnet@master
|
|
|
|
with:
|
|
|
|
dotnet-version: "2.2.402"
|
|
|
|
|
|
|
|
# Run the ignored tests that expect the above setup
|
|
|
|
- name: Run all tests
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: test
|
|
|
|
args: -- -Z unstable-options --include-ignored
|
|
|
|
|
|
|
|
# Run the tests in the Docker image
|
|
|
|
docker_test:
|
|
|
|
name: Test in Docker
|
|
|
|
needs: [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
|
|
|
|
|
2019-10-04 15:17:29 +00:00
|
|
|
# Publish starship to Crates.io
|
2019-10-04 06:12:48 +00:00
|
|
|
cargo_publish:
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
2019-10-04 14:22:14 +00:00
|
|
|
name: Publish Cargo Package
|
2019-10-04 06:12:48 +00:00
|
|
|
needs: [test, docker_test]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
2019-10-04 14:22:14 +00:00
|
|
|
- run: cargo login $CRATES_IO_TOKEN
|
|
|
|
- run: cargo publish
|
2019-10-04 14:54:21 +00:00
|
|
|
env:
|
|
|
|
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
2019-10-04 06:12:48 +00:00
|
|
|
|
2019-10-04 14:36:49 +00:00
|
|
|
# Create a PR to bump the brew formula version
|
|
|
|
brew_bump_formula:
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
name: Bump Brew Formula
|
|
|
|
needs: [test, docker_test]
|
|
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
2019-10-14 16:05:51 +00:00
|
|
|
- run: |
|
|
|
|
cd $(brew --prefix)
|
|
|
|
git fetch origin
|
|
|
|
sudo git reset --hard origin/master
|
|
|
|
cd -
|
2019-10-06 15:19:35 +00:00
|
|
|
- run: brew bump-formula-pr --url=https://github.com/starship/starship/archive/$(git describe --tags).tar.gz --message="Automated release pull request using continuous integration." --no-browse -v starship --force
|
2019-10-04 14:36:49 +00:00
|
|
|
env:
|
2019-10-13 04:58:25 +00:00
|
|
|
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
2019-10-04 14:36:49 +00:00
|
|
|
|
|
|
|
# Create GitHub release with Rust build targets and release notes
|
2019-10-04 06:12:48 +00:00
|
|
|
github_release:
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
2019-10-04 14:36:49 +00:00
|
|
|
name: Create GitHub Release
|
2019-10-04 06:12:48 +00:00
|
|
|
needs: [test, docker_test]
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2019-10-04 12:47:09 +00:00
|
|
|
target:
|
|
|
|
- x86_64-unknown-linux-gnu
|
|
|
|
- x86_64-unknown-linux-musl
|
|
|
|
- x86_64-apple-darwin
|
2019-10-15 15:10:16 +00:00
|
|
|
- x86_64-pc-windows-gnu
|
|
|
|
- x86_64-pc-windows-msvc
|
2019-10-04 06:12:48 +00:00
|
|
|
include:
|
2019-10-04 12:47:09 +00:00
|
|
|
- target: x86_64-unknown-linux-gnu
|
|
|
|
os: ubuntu-latest
|
2019-10-04 06:12:48 +00:00
|
|
|
name: starship-x86_64-unknown-linux-gnu.tar.gz
|
2019-10-04 12:47:09 +00:00
|
|
|
- target: x86_64-unknown-linux-musl
|
|
|
|
os: ubuntu-latest
|
2019-10-04 06:12:48 +00:00
|
|
|
name: starship-x86_64-unknown-linux-musl.tar.gz
|
2019-10-04 12:47:09 +00:00
|
|
|
- target: x86_64-apple-darwin
|
|
|
|
os: macOS-latest
|
2019-10-04 06:12:48 +00:00
|
|
|
name: starship-x86_64-apple-darwin.tar.gz
|
2019-10-15 15:10:16 +00:00
|
|
|
- target: x86_64-pc-windows-gnu
|
|
|
|
os: windows-latest
|
|
|
|
name: starship-x86_64-pc-windows-gnu.zip
|
|
|
|
- target: x86_64-pc-windows-msvc
|
|
|
|
os: windows-latest
|
|
|
|
name: starship-x86_64-pc-windows-msvc.zip
|
2019-10-04 06:12:48 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Install musl tools
|
|
|
|
if: matrix.target == 'x86_64-unknown-linux-musl'
|
|
|
|
run: sudo apt-get install -y musl-tools
|
|
|
|
|
|
|
|
- name: Build target
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: build
|
|
|
|
args: --release --target ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Prepare build artifacts
|
|
|
|
run: |
|
2019-10-04 12:47:09 +00:00
|
|
|
strip target/${{ matrix.target }}/release/starship
|
2019-10-04 06:12:48 +00:00
|
|
|
cd target/${{ matrix.target }}/release
|
|
|
|
if [[ "${{ matrix.os }}" == "windows-latest" ]]
|
|
|
|
then
|
2019-10-15 15:10:16 +00:00
|
|
|
7z a ../../../${{ matrix.name }} starship.exe
|
2019-10-04 06:12:48 +00:00
|
|
|
else
|
2019-10-04 12:47:09 +00:00
|
|
|
tar czvf ../../../${{ matrix.name }} starship
|
2019-10-04 06:12:48 +00:00
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
|
|
|
|
- name: Generate release notes
|
|
|
|
run: |
|
|
|
|
# Temporary fix for https://github.com/actions/setup-go/issues/14
|
|
|
|
export PATH=$PATH:$(go env GOPATH)/bin
|
|
|
|
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
|
2019-10-04 14:54:21 +00:00
|
|
|
git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md
|
2019-10-04 06:12:48 +00:00
|
|
|
|
|
|
|
- name: Create GitHub release ${{ matrix.target }}
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
with:
|
|
|
|
files: ${{ matrix.name }}
|
2019-10-04 14:54:21 +00:00
|
|
|
body_path: RELEASE.md
|
2019-10-04 06:12:48 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|