Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github: Initial actions-rs based GitHub Actions config #3

Merged
merged 1 commit into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 0 additions & 89 deletions .circleci/config.yml

This file was deleted.

292 changes: 292 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md

on:
pull_request: {}
push:
branches: develop

name: Rust

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v1

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- ubuntu-latest
- macos-latest
toolchain:
- stable
- 1.40.0
steps:
- name: Checkout sources
uses: actions/checkout@v1

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-rust-${{ matrix.toolchain }}-cargo-build-target-${{ hashFiles('Cargo.lock') }}

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true

- name: Run cargo build
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --release

- name: Run cargo build --all-features --examples
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --features=usb --release

- name: Run cargo build --benches
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --benches --release

- name: Run cargo build --features=usb
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --features=usb --release

- name: Run cargo build --no-default-features
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --release --no-default-features

- name: Run cargo build --no-default-features --features=passwords
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --release --no-default-features --features=passwords

coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-coverage-cargo-build-target-${{ hashFiles('Cargo.lock') }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
env:
CARGO_INCREMENTAL: 0
with:
version: 0.11.0
args: --all-features -- --test-threads 1

- name: Upload to codecov.io
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}

- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: cobertura.xml

test:
name: Test Suite
strategy:
matrix:
platform:
- ubuntu-latest
- macos-latest
toolchain:
- stable
- 1.40.0
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
uses: actions/checkout@v1

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-rust-${{ matrix.toolchain }}-cargo-build-target-${{ hashFiles('Cargo.lock') }}

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: test
args: --features=mockhsm,secp256k1,yolocrypto

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v1

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install rustfmt
run: rustup component add rustfmt

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v1

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install clippy
run: rustup component add clippy

- name: Run cargo clippy --features=secp256k1,usb,yolocrypto
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features=secp256k1,usb,yolocrypto

- name: Run cargo clippy --features=mockhsm
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features=mockhsm
Loading