111 lines
2.6 KiB
YAML
111 lines
2.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, dev ]
|
|
pull_request:
|
|
branches: [ main, dev ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
|
|
- name: Install cargo-llvm-cov
|
|
run: |
|
|
mkdir -p $HOME/.cargo/bin
|
|
curl -LO https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
|
tar xf cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
|
chmod +x cargo-llvm-cov
|
|
mv cargo-llvm-cov $HOME/.cargo/bin/
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
rm cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
|
|
|
- name: Run tests
|
|
run: cargo test --verbose --tests
|
|
|
|
- name: Generate code coverage
|
|
run: |
|
|
cargo llvm-cov --lcov --output-path lcov.info
|
|
cargo llvm-cov --html
|
|
|
|
- name: Extract Coverage Percentage
|
|
id: coverage
|
|
run: |
|
|
COVERAGE=$(cargo llvm-cov --summary | grep -oP 'coverage: \K[0-9.]+%' || echo "0%")
|
|
echo "total_coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
|
echo "Coverage: $COVERAGE"
|
|
|
|
- name: Upload coverage HTML
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: code-coverage
|
|
path: target/llvm-cov/html
|
|
|
|
- name: Upload LCOV report
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: lcov-report
|
|
path: lcov.info
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
- name: Clippy
|
|
run: cargo clippy -- -D warnings
|
|
|