From 311c8786ab0fcf95ff7117fc4f2b879c062fcf52 Mon Sep 17 00:00:00 2001 From: Brady Fomegne Date: Sun, 14 Apr 2024 20:16:56 +0100 Subject: [PATCH] ci: add test coverage (#59) --- .github/workflows/coverage.yml | 75 ++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..4cfb4ca --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,75 @@ +name: Coverage + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +jobs: + coverage: + runs-on: ubuntu-latest + env: + DISPLAY: ":99" + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libxtst-dev libevdev-dev libxdo-dev + version: 1.0 + + - name: Setup headless environment + run: | + Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + + - name: Dependencies + run: | + sudo apt-get install libxtst-dev libevdev-dev libxdo-dev --assume-yes + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: Swatinem/rust-cache@v2 + with: + # To only cache runs from `main` + save-if: ${{ github.ref == 'refs/heads/main' }} + - run: rustup component add llvm-tools-preview + + - name: Install grcov + uses: actions-rs/install@v0.1 + with: + crate: grcov + version: latest + use-tool-cache: true + + - name: build + env: + RUSTFLAGS: -Cinstrument-coverage + run: cargo build --verbose + + - name: test + env: + RUSTFLAGS: -Cinstrument-coverage + LLVM_PROFILE_FILE: name-%p-%m.profraw + run: cargo test --verbose + + - name: Run grcov + run: | + mkdir coverage + grcov . \ + --binary-path ./target/debug/ \ + -s . \ + -t lcov \ + --branch \ + --ignore-not-existing \ + --ignore "/*" \ + --excl-line "#\\[derive\\(" \ + -o ./coverage/lcov.info + + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 8b5a9a8..4e04a57 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Afrim Wish [![crates.io](https://img.shields.io/crates/v/afrim-wish.svg)](https://crates.io/crates/afrim-wish) [![LICENSE](https://img.shields.io/crates/l/afrim-wish.svg)](https://github.com/pythonbrad/afrim-wish/blob/main/LICENSE) ![Rust](https://github.com/pythonbrad/afrim-wish/workflows/Rust/badge.svg) + [![Coverage Status](https://coveralls.io/repos/github/pythonbrad/afrim-wish/badge.svg?branch=main)](https://coveralls.io/github/pythonbrad/afrim-wish?branch=main) Afrim Wish is a frontend alternative for [afrim](https://github.com/pythonbrad/afrim).