mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-23 11:07:45 +02:00
feat: Add code coverage to CI
This commit is contained in:
parent
b05539b3ab
commit
ad449a53a3
4 changed files with 100 additions and 95 deletions
13
.github/actions/install-taskwarrior/action.yml
vendored
13
.github/actions/install-taskwarrior/action.yml
vendored
|
@ -1,7 +1,7 @@
|
|||
# This action definition may look complicated, but it only builds taskwarrior from the latest source release and installs it.
|
||||
# The rest of the file is caching of results and checks to avoid ambiguous failure in case taskwarrior changes their release strategy.
|
||||
name: 'Install Taskwarrior'
|
||||
description: 'Builds latests stable taskwarrior release install it'
|
||||
name: Install Taskwarrior
|
||||
description: Builds latests stable taskwarrior release install it
|
||||
inputs:
|
||||
secret_gh_token:
|
||||
description: "GH token used for downloading the release asset"
|
||||
|
@ -13,7 +13,7 @@ runs:
|
|||
using: "composite"
|
||||
steps:
|
||||
- name: Update apt
|
||||
run: sudo apt get update
|
||||
run: sudo apt-get update
|
||||
shell: bash
|
||||
- name: Install libuuid
|
||||
run: sudo apt-get install uuid-dev uuid-runtime
|
||||
|
@ -51,13 +51,13 @@ runs:
|
|||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: /tmp/task.deb
|
||||
key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }}
|
||||
key: ${{ runner.os }}-taskwarrior-${{ steps.calculate-task-sha256.outputs.task_sha256 }}-rust-${{ inputs.rust_toolchain }}
|
||||
|
||||
- name: Install rust toolchain and rust cache
|
||||
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: inputs.rust_toolchain
|
||||
toolchain: ${{ inputs.rust_toolchain }}
|
||||
override: false
|
||||
- name: Extract taskwarrior source code
|
||||
if: steps.cache-taskwarrior-restore.outputs.cache-hit != 'true'
|
||||
|
@ -101,3 +101,6 @@ runs:
|
|||
- name: Install taskwarrior
|
||||
run: sudo dpkg -i /tmp/task.deb
|
||||
shell: bash
|
||||
- name: Test if installation worked
|
||||
run: task --version
|
||||
shell: bash
|
80
.github/workflows/cd.yml
vendored
80
.github/workflows/cd.yml
vendored
|
@ -11,9 +11,12 @@ permissions:
|
|||
contents: write
|
||||
|
||||
jobs:
|
||||
call_build:
|
||||
build:
|
||||
uses: ./.github/workflows/build.yml
|
||||
|
||||
generate_coverage:
|
||||
uses: ./.github/workflows/generate_coverage.yml
|
||||
|
||||
homebrew:
|
||||
name: Bump Homebrew formula
|
||||
runs-on: macos-latest
|
||||
|
@ -96,77 +99,4 @@ jobs:
|
|||
- name: Install cargo-aur
|
||||
run: cargo install cargo-aur
|
||||
- name: Build aur package
|
||||
run: cargo aur
|
||||
|
||||
grcov:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TASKRC: taskwarrior-testdata/.taskrc
|
||||
TASKDATA: taskwarrior-testdata/.task
|
||||
RUST_BACKTRACE: full
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: sudo apt-get update
|
||||
- name: 'Install Taskwarrior'
|
||||
uses: ./.github/actions/install-taskwarrior
|
||||
with:
|
||||
secret_gh_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: |
|
||||
task --version
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kdheepak/taskwarrior-testdata
|
||||
path: taskwarrior-testdata
|
||||
- run: |
|
||||
# prepare taskwarrior, initial setup
|
||||
task rc.confirmation=off || echo 0
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: llvm-tools-preview
|
||||
- name: Clean environment for grcov
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: clean
|
||||
- name: Build taskwarrior-tui with coverage
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: build
|
||||
env:
|
||||
RUSTFLAGS: "-Cinstrument-coverage"
|
||||
- name: Run taskwarrior-tui tests in coverage environment
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: test
|
||||
args: --worksoace
|
||||
env:
|
||||
RUSTFLAGS: "-Cinstrument-coverage"
|
||||
LLVM_PROFILE_FILE: "your_name-%p-%m.profraw"
|
||||
- name: Install grcov
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: install
|
||||
args: grcov
|
||||
- name: Gather coverage data
|
||||
run: |
|
||||
mkdir ./target/debug/coverage/
|
||||
grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/
|
||||
shell: bash
|
||||
- name: Coveralls upload
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
parallel: true
|
||||
file: ./target/debug/coverage/lcov
|
||||
|
||||
grcov_finalize:
|
||||
runs-on: ubuntu-latest
|
||||
needs: grcov
|
||||
steps:
|
||||
- name: Coveralls finalization
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
parallel-finished: true
|
||||
run: cargo aur
|
34
.github/workflows/ci.yml
vendored
34
.github/workflows/ci.yml
vendored
|
@ -19,37 +19,41 @@ jobs:
|
|||
test:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TASKRC: taskwarrior-testdata/.taskrc
|
||||
TASKDATA: taskwarrior-testdata/.task
|
||||
RUST_BACKTRACE: full
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: sudo apt-get update
|
||||
- name: 'Install Taskwarrior'
|
||||
- name: Install Taskwarrior
|
||||
uses: ./.github/actions/install-taskwarrior
|
||||
with:
|
||||
secret_gh_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: |
|
||||
task --version
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kdheepak/taskwarrior-testdata
|
||||
path: taskwarrior-testdata
|
||||
- run: |
|
||||
# prepare taskwarrior, initial setup
|
||||
task rc.confirmation=off || echo 0
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
override: true
|
||||
- name: Install testdata
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kdheepak/taskwarrior-testdata
|
||||
path: taskwarrior-testdata
|
||||
- uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: test
|
||||
args: --workspace -- --nocapture
|
||||
env:
|
||||
TASKRC: taskwarrior-testdata/.taskrc
|
||||
TASKDATA: taskwarrior-testdata/.task
|
||||
RUST_BACKTRACE: full
|
||||
|
||||
|
||||
generate_coverage:
|
||||
uses: ./.github/workflows/generate_coverage.yml
|
||||
# Avoid double-compiling taskwarrior if not cached, or wasting CI time if tests fail
|
||||
needs: test
|
||||
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
name: Rustfm
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
@ -76,4 +80,4 @@ jobs:
|
|||
- uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
args: -- -D warnings
|
68
.github/workflows/generate_coverage.yml
vendored
Normal file
68
.github/workflows/generate_coverage.yml
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
name: generate_coverage
|
||||
|
||||
on:
|
||||
workflow_call
|
||||
|
||||
jobs:
|
||||
grcov:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Taskwarrior
|
||||
uses: ./.github/actions/install-taskwarrior
|
||||
with:
|
||||
secret_gh_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: |
|
||||
# prepare taskwarrior, initial setup
|
||||
task rc.confirmation=off || echo 0
|
||||
|
||||
- name: Install Rust toolchain for grcov compilation
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Install grcov
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: install
|
||||
args: grcov
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: llvm-tools-preview
|
||||
- name: Checkout testdata
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kdheepak/taskwarrior-testdata
|
||||
path: taskwarrior-testdata
|
||||
- name: Build taskwarrior-tui with coverage
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: build
|
||||
env:
|
||||
RUSTFLAGS: "-Cinstrument-coverage"
|
||||
- name: Run taskwarrior-tui tests in coverage environment
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
with:
|
||||
command: test
|
||||
args: --workspace -- --nocapture
|
||||
env:
|
||||
TASKRC: taskwarrior-testdata/.taskrc
|
||||
TASKDATA: taskwarrior-testdata/.task
|
||||
RUST_BACKTRACE: full
|
||||
RUSTFLAGS: "-Cinstrument-coverage"
|
||||
LLVM_PROFILE_FILE: "your_name-%p-%m.profraw"
|
||||
|
||||
- name: Gather coverage data
|
||||
run: |
|
||||
mkdir ./target/debug/coverage/
|
||||
grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/
|
||||
shell: bash
|
||||
- name: Coveralls upload
|
||||
uses: coverallsapp/github-action@v2
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: ./target/debug/coverage/lcov
|
Loading…
Add table
Add a link
Reference in a new issue