Skip to content

Commit

Permalink
Replace travis with GH actions (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored Oct 15, 2019
1 parent f9de4ff commit 48eef7c
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 341 deletions.
12 changes: 0 additions & 12 deletions .ci/checksum.ps1

This file was deleted.

14 changes: 0 additions & 14 deletions .ci/install_musl.sh

This file was deleted.

30 changes: 0 additions & 30 deletions .ci/lint.sh

This file was deleted.

58 changes: 0 additions & 58 deletions .ci/prep_deploy.sh

This file was deleted.

48 changes: 0 additions & 48 deletions .ci/test.sh

This file was deleted.

221 changes: 221 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
on: [push, pull_request]
name: CI
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

# make sure all code has been formatted with rustfmt
- run: rustup component add rustfmt
- name: check rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check --color always

# run clippy to verify we have no warnings
- run: rustup component add clippy
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --lib --tests -- -D warnings

test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo test build
uses: actions-rs/cargo@v1
with:
command: build
args: --tests --release
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --release

# Remove this check if you don't use cargo-deny in the repo
deny-check:
name: cargo-deny check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: download cargo-deny
shell: bash
env:
DVS: 0.3.0-beta
DREPO: EmbarkStudios/cargo-deny
TARGET: x86_64-unknown-linux-musl
run: |
temp_archive=$(mktemp --suffix=.tar.gz)
curl -L --output "$temp_archive" https://github.com/$DREPO/releases/download/$DVS/cargo-deny-$DVS-$TARGET.tar.gz
tar -xzvf "$temp_archive" -C . --strip-components=1 --wildcards "*/cargo-deny"
- name: cargo-deny check licenses
run: ./cargo-deny -L debug check license
- name: cargo-deny check bans
run: ./cargo-deny -L debug check ban

# Remove this check if you don't publish the crate(s) from this repo
publish-check:
name: Publish Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: copy README
shell: bash
run: |
cp README.md lib
cp README.md cli
- name: cargo publish lib
uses: actions-rs/cargo@v1
with:
command: publish
args: --dry-run --allow-dirty --manifest-path lib/Cargo.toml
- name: cargo publish cli
uses: actions-rs/cargo@v1
with:
command: publish
args: --dry-run --allow-dirty --manifest-path cli/Cargo.toml

# Remove this job if you don't publish the crate(s) from this repo
# You must add a crates.io API token to your GH secrets called CRATES_IO_TOKEN
publish:
name: Publish
needs: [test, deny-check, publish-check]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo publish
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
with:
command: publish

# Remove this job if you don't release binaries
# Replace occurances of $BIN_NAME with the name of your binary
release:
name: Release
needs: [test, deny-check]
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
bin: $BIN_NAME
# We don't enable the progress feature when targeting
# musl since there are some dependencies on shared libs
features: ""
- os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
bin: $BIN_NAME.exe
features: --features=progress
- os: macOS-latest
rust: stable
target: x86_64-apple-darwin
bin: $BIN_NAME
features: --features=progress
runs-on: ${{ matrix.os }}
steps:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
target: ${{ matrix.target }}
- name: Install musl tools
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y musl-tools
- name: Checkout
uses: actions/checkout@v1
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
args: --target ${{ matrix.target }}
- name: Release build
uses: actions-rs/cargo@v1
if: matrix.os != 'ubuntu-latest'
with:
command: build
args: --release --target ${{ matrix.target }} ${{ matrix.features }}
- name: Package
shell: bash
run: |
name=$BIN_NAME
tag=$(git describe --tags --abbrev=0)
release_name="$name-$tag-${{ matrix.target }}"
release_tar="${release_name}.tar.gz"
mkdir "$release_name"
if [ "${{ matrix.target }}" != "x86_64-pc-windows-msvc" ]; then
strip "target/${{ matrix.target }}/release/${{ matrix.bin }}"
fi
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$release_name/"
cp README.md LICENSE-APACHE LICENSE-MIT "$release_name/"
tar czvf "$release_tar" "$release_name"
rm -r "$release_name"
# Windows environments in github actions don't have the gnu coreutils installed,
# which includes the shasum exe, so we just use powershell instead
if [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c -
else
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256"
fi
- name: Publish
uses: softprops/action-gh-release@v1
with:
draft: true
files: '$BIN_NAME*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 48eef7c

Please sign in to comment.