-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (92 loc) · 2.93 KB
/
code_check.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
name: CI - Code Checks & Tests
run-name: Checks Rust code on ${{ github.event_name }}
on:
push:
paths:
- ".github/workflows/build.yml"
- "Cargo.*"
- "src/**"
pull_request:
paths:
- ".github/workflows/build.yml"
- "Cargo.*"
- "src/**"
env:
CARGO_TERM_COLOR: always
jobs:
readme:
name: Readme
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Install rust-toolchain stable"
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-readme
run: cargo install cargo-readme
- name: Check if readme is up to date
run: diff README.md <(cargo readme)
ci_code_checks_ans_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Code Checks and Tests
steps:
- name: "Install rust-toolchain stable"
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: "Show environment"
run: |
rustc -vV
cargo -vV
- name: "Checkout"
uses: actions/checkout@v4
- name: Install cargo-readme
run: cargo install cargo-readme
- name: Check if readme is up to date
id: cargo_readme
if: $${{ always() }}
run: diff README.md <(cargo readme)
- name: "Cargo clippy"
id: cargo_clippy
if: $${{ always() }}
run: |
cargo clippy --profile=test
- name: "Cargo test"
id: cargo_test
if: $${{ always() }}
run: |
cargo test
- name: "Cargo formatting"
id: cargo_fmt
if: $${{ always() }}
run: |
cargo fmt --all -- --check
- name: "Cargo doc"
id: cargo_doc
env:
RUSTDOCFLAGS: "-D warnings"
if: $${{ always() }}
run: |
cargo doc
- name: "Some checks failed"
if: ${{ failure() }}
run: |
echo "### :x: Checks Failed!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "|Job|Status|" >> $GITHUB_STEP_SUMMARY
echo "|---|------|" >> $GITHUB_STEP_SUMMARY
echo "|Cargo readme|${{ steps.cargo_readme.outcome }}|" >> $GITHUB_STEP_SUMMARY
echo "|Cargo clippy|${{ steps.cargo_clippy.outcome }}|" >> $GITHUB_STEP_SUMMARY
echo "|Cargo test|${{ steps.cargo_test.outcome }}|" >> $GITHUB_STEP_SUMMARY
echo "|Cargo fmt|${{ steps.cargo_fmt.outcome }}|" >> $GITHUB_STEP_SUMMARY
echo "|Cargo doc|${{ steps.cargo_doc.outcome }}|" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please check the failed jobs and fix where needed." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
exit 1
- name: "All checks passed"
if: ${{ success() }}
run: |
echo "### :white_check_mark: Checks Passed!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY