-
-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (124 loc) · 4.52 KB
/
ci.yml
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
name: CI
on:
push:
branches:
- main
workflow_call:
# This is required to run checks on the translations PR.
# This is because actions are not triggered on PRs from an action.
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
permissions:
checks: write
env:
CARGO_TERM_COLOR: always
FROM_REF: ${{ github.event.pull_request.base.sha || (!github.event.forced && ( github.event.before != '0000000000000000000000000000000000000000' && github.event.before || github.sha )) || format('{0}~', github.sha) }}
TO_REF: ${{ github.sha }}
jobs:
test:
name: Test for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: llvm-tools-preview
cache: false
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: taiki-e/install-action@v2
with:
tool: cargo-deny,nextest,cargo-llvm-cov
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install pre-commit & gitlint
run: python -m pip install pre-commit gitlint
- run: python -m pip freeze --local
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: pre-commit validation
run: pre-commit run --show-diff-on-failure --color=always --from-ref ${{ env.FROM_REF }} --to-ref ${{ env.TO_REF }} --hook-stage manual
- name: gitlint validation
run: gitlint --commits ${{ env.FROM_REF }}..${{ env.TO_REF }}
if: always()
- name: Formatting
uses: clechasseur/rs-cargo@v3
with:
command: fmt
args: --check
- name: Check
uses: clechasseur/rs-cargo@v3
with:
command: check
args: --all-targets --all-features --locked
- name: Linting
uses: clechasseur/rs-cargo@v3
with:
command: clippy
args: --all-targets --all-features --locked -- -D warnings
- name: Tests
run: |
cargo llvm-cov --no-report nextest --profile ci --locked
# cargo llvm-cov --no-report --doc
# cargo llvm-cov report --doctests --lcov --output-path lcov-${{ matrix.os }}.info
cargo llvm-cov report --lcov --output-path lcov-${{ matrix.os }}.info
- name: Replace workspace in lcov
run: perl -i -pe's%\Q${{ github.workspace }}\E%WORKSPACE%g' lcov-${{ matrix.os }}.info
- name: Upload code coverage to GitHub
uses: actions/upload-artifact@v4
with:
name: code-coverage-${{ matrix.os }}
path: lcov-${{ matrix.os }}.info
continue-on-error: true
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure()
with:
report_paths: 'target/nextest/ci/junit.xml'
check_name: JUnit Test Report for ${{ matrix.os }}
detailed_summary: true
continue-on-error: true
coverage_report:
name: Generate coverage report
needs: test
runs-on: ubuntu-latest
permissions:
checks: write
issues: write
steps:
- name: Install LCOV
if: success() || failure()
uses: hrishikesh-kadam/setup-lcov@v1
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Download code coverage from GitHub
uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: code-coverage-*
- uses: taiki-e/install-action@v2
with:
tool: grcov
- name: Replace placeholder in lcov
run: find lcov-*.info -type f -print0 | xargs -0 -I {} sh -c 'sed "s%WORKSPACE%${{ github.workspace }}%g" {} > ${{ runner.temp }}/{}; grcov ${{ runner.temp }}/{} -s . --guess-directory-when-missing > {}'
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v4
if: success() || failure()
with:
coverage-files: lcov-*.info
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true