forked from BamPeers/rust-ci-github-actions-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (117 loc) · 4.24 KB
/
Copy pathtest-with-coverage.yaml
File metadata and controls
133 lines (117 loc) · 4.24 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Test with Code Coverage
on:
pull_request:
push:
branches:
- main
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:
- name: Harden Runner
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.deps.dev:443
api.github.com:443
api.osv.dev:443
api.scorecard.dev:443
fulcio.sigstore.dev:443
github.com:443
oss-fuzz-build-logs.storage.googleapis.com:443
rekor.sigstore.dev:443
tuf-repo-cdn.sigstore.dev:443
www.bestpractices.dev:443
objects.githubusercontent.com:443
release-assets.githubusercontent.com:443
static.rust-lang.org:443
static.crates.io:443
index.crates.io:443
just.systems:443
taskfile.dev:443
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # nightly
with:
toolchain: nightly
components: llvm-tools-preview
- name: Cache dependencies
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/git
~/.cargo/registry/index
~/.cargo/registry/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
# Cache target directory seperately to prevent cache invalidation of
# ~/.cargo when target changes
#- name: Cache target directory
# uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
# env:
# cache-name: cache-dependencies
# with:
# path: target
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- name: Install grcov
uses: taiki-e/install-action@f63c33fd96cc1e69a29bafd06541cf28588b43a4 # v2.58.21
with:
tool: grcov,cargo-llvm-cov
- name: Run tests
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
run: |
task test
- name: Generate test results and coverage report
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
run: |
cargo test ${CARGO_OPTIONS:+$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@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0
with:
check_name: Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: results.xml
# FIXME: https://github.com/yonasBSD/rust-ci-github-actions-workflow/issues/85
#- name: Run xtask coverage
# uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
# 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