forked from BamPeers/rust-ci-github-actions-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (85 loc) · 2.88 KB
/
test-with-coverage.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
on:
pull_request:
push:
branches:
- main
name: Test with Code Coverage
permissions:
contents: read
issues: read
checks: write
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
env:
PROJECT_NAME_UNDERSCORE: test2
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
RUSTDOCFLAGS: -Cpanic=abort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Cache dependencies
uses: actions/cache@v4
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- name: Install grcov
uses: taiki-e/install-action@v2
with:
tool: grcov,cargo-llvm-cov
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo test --all-features
- name: Set env
run: echo "CARGO2JUNIT_VERSION=$(curl -sL https://api.github.com/repos/yonasBSD/cargo2junit/releases/latest | jq -r ".tag_name" | cut -d'v' -f2)" >> $GITHUB_ENV
- name: Generate test result and coverage report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/yonasBSD/cargo2junit/releases/download/v${CARGO2JUNIT_VERSION}/cargo2junit_${CARGO2JUNIT_VERSION}_amd64.deb
sudo dpkg -i cargo2junit_${CARGO2JUNIT_VERSION}_amd64.deb
rm cargo2junit_${CARGO2JUNIT_VERSION}_amd64.deb
cargo clean
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: results.xml
- name: Run xtask coverage
uses: actions-rs/cargo@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: xtask
args: coverage
#- name: Upload Coverage Report
# uses: codecov/codecov-action@v5
# with:
# verbose: true
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ${{ github.workspace }}/codecov.json
# - name: Upload to codecov.io
# uses: codecov/codecov-action@v5
# with:
# files: coverage/*.lcov
# fail_ci_if_error: true