Skip to content

Commit

Permalink
Merge pull request #15 from mojoX911/github-action
Browse files Browse the repository at this point in the history
Added CI and Code Coverage toolings
  • Loading branch information
chris-belcher authored May 14, 2021
2 parents aa1a60b + 9cc3a06 commit 90e71ba
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on: [push, pull_request]

name: Continuous Integration

jobs:

build_and_test:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
features:
- default
steps:
- name: checkout
uses: actions/checkout@v2
- name: Generate cache key
run: echo "${{ matrix.rust }} ${{ matrix.features }}" | tee .cache_key
- name: cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Set default toolchain
run: rustup default ${{ matrix.rust }}
- name: Set profile
run: rustup set profile minimal
- name: Add clippy
run: rustup component add clippy
- name: Update toolchain
run: rustup update
- name: Build
run: cargo build --features ${{ matrix.features }} --no-default-features
# Uncomment clippy check after failures are removed
# - name: Clippy
# run: cargo clippy --all-targets --features ${{ matrix.features }} --no-default-features -- -D warnings
- name: Test
run: cargo test --features ${{ matrix.features }} --no-default-features
32 changes: 32 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on: [push, pull_request]

name: Code Coverage

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

- name: Set default toolchain
run: rustup default nightly
- name: Set profile
run: rustup set profile minimal

- name: Run cargo test
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off'
run: cargo test
- id: coverage
name: Generate coverage
uses: actions-rs/[email protected]

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ${{ steps.coverage.outputs.report }}
directory: ./coverage/reports/
23 changes: 23 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

on: [push, pull_request]

name: Lint Checking

jobs:

fmt:
name: Rust fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set default toolchain
run: rustup default stable
- name: Set profile
run: rustup set profile minimal
- name: Add rustfmt
run: rustup component add rustfmt
- name: Update toolchain
run: rustup update
- name: Check fmt
run: cargo fmt --all -- --check
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ rand = "0.7.3"
itertools = "0.9.0"
structopt = "0.3.21"
dirs = "3.0.1"

#Empty default feature set, (helpful to generalise in github actions)
[features]
default = []

13 changes: 13 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
coverage:
status:
project:
default:
target: auto
threshold: 1%
base: auto
informational: false
patch:
default:
target: auto
threshold: 100%
base: auto

0 comments on commit 90e71ba

Please sign in to comment.