Skip to content

Commit

Permalink
.github: Initial actions-rs based GitHub Actions config
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-iqlusion committed Mar 3, 2020
1 parent 5766955 commit 6070a5d
Show file tree
Hide file tree
Showing 6 changed files with 357 additions and 72 deletions.
67 changes: 0 additions & 67 deletions .circleci/config.yml

This file was deleted.

326 changes: 326 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
# 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: Install libudev-dev
run: sudo apt-get install libudev-dev

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

build:
name: Build
strategy:
matrix:
toolchain:
- stable
- 1.40.0
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: 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: Install libudev-dev
run: sudo apt-get install libudev-dev

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

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

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

# NOTE: softsign backend alone is tested via the test harness job
- name: Run cargo build --features=yubihsm-server,ledgertm,softsign
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: build
args: --features=yubihsm-server,ledgertm,softsign --release

test:
name: Test Suite
strategy:
matrix:
toolchain:
- stable
- 1.40.0
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: 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: Install libudev-dev
run: sudo apt-get install libudev-dev

- name: Run cargo test
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
with:
command: test
args: --all-features -- --test-threads 1

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: Install libudev-dev
run: sudo apt-get install libudev-dev

- 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

validate:
name: Validate against test harness
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: 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: stable
override: true

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

# TODO(tarcieri): install test harness components. See build failure here:
# <https://github.com/iqlusioninc/tmkms/pull/9/checks?check_run_id=481126544>
# - name: Run test harness
# env:
# TMKMS_BIN: ./target/debug/tmkms
# run: sh tests/support/run-harness-tests.sh

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 libudev-dev
run: sudo apt-get install libudev-dev

- name: Install clippy
run: rustup component add clippy

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

0 comments on commit 6070a5d

Please sign in to comment.