-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (77 loc) · 2.88 KB
/
build.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
name: Build
on: [push]
jobs:
rustfmt:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
NUM_JOBS: 2
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
# Run the build, clippy, and test commands in the same job in serial so they can share the same
# build directory, and hopefully run faster.
build-lint-test:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
CARGO_TERM_COLOR: always
NUM_JOBS: 2
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-targets --all-features
- name: Lint
uses: actions-rs/cargo@v1
with:
command: clippy
args: --release --all-targets --all-features
- name: Test
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: --release --all-features --out xml
# TODO: Code coverage badge on README
- name: Get Pull Request Number
id: pr
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "Found PR number '${{ steps.pr.outputs.pull_request_number }}' with the github CLI"
- name: PR coverage report comment
uses: 5monkeys/cobertura-action@v13
if: github.ref != 'refs/heads/main'
with:
path: 'cobertura.xml'
repo_token: ${{ secrets.GITHUB_TOKEN }}
pull_request_number: ${{ steps.pr.outputs.pull_request_number }}
only_changed_files: true
show_line: true
show_branch: true
skip_covered: false
# If we want to enforce a minimum coverage percentage, this is how.
minimum_coverage: 0
fail_below_threshold: false