56 lines
2.1 KiB
YAML
56 lines
2.1 KiB
YAML
name: Rust
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Build
|
|
run: cargo build --all-features
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install lcov_cobertura
|
|
run: curl -O https://raw.githubusercontent.com/eriwen/lcov-to-cobertura-xml/master/lcov_cobertura/lcov_cobertura.py && chmod +x lcov_cobertura.py
|
|
- name: Install llvm-tools-preview
|
|
run: rustup component add llvm-tools-preview
|
|
- name: Install grcov
|
|
run: cargo install grcov
|
|
- name: Create coverage output dir
|
|
run: mkdir -p target/coverage
|
|
- name: All features
|
|
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --all-features
|
|
- name: No feature
|
|
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test
|
|
- name: otpauth feature
|
|
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=otpauth
|
|
- name: gen_secret feature
|
|
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=gen_secret
|
|
- name: otpauth+gensecret feature
|
|
run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=gen_secret,otpauth
|
|
- name: Create coverage file
|
|
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov
|
|
- name: Convert coverage file to cobertura
|
|
run: python3 lcov_cobertura.py target/coverage/tests.lcov -o cobertura.xml
|
|
- name: Upload to codecov.io
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
token: ${{secrets.CODECOV_TOKEN}}
|
|
|
|
- name: Archive code coverage results
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: code-coverage-report
|
|
path: cobertura.xml
|