1010 CARGO_TERM_COLOR : always
1111
1212jobs :
13- commitlint :
14- name : Commitlint
13+ lint :
1514 runs-on : ubuntu-latest
16- if : github.event_name == 'pull_request'
1715 permissions :
1816 contents : read
1917 pull-requests : read
@@ -23,38 +21,13 @@ jobs:
2321 with :
2422 fetch-depth : 0
2523
26- - name : Run commitlint
24+ - name : Lint commit messages
2725 uses : wagoid/commitlint-github-action@v6.2.1
2826
29- format :
30- name : Format
31- runs-on : ubuntu-latest
32- needs : commitlint
33- if : always() && (needs.commitlint.result == 'success' || needs.commitlint.result == 'skipped')
34- steps :
35- - name : Checkout repository
36- uses : actions/checkout@v6.0.2
37-
3827 - name : Set up Rust
3928 uses : dtolnay/rust-toolchain@stable
4029 with :
41- components : rustfmt
42-
43- - name : Check formatting
44- run : cargo fmt --all -- --check
45-
46- lint :
47- name : Lint
48- runs-on : ubuntu-latest
49- needs : format
50- steps :
51- - name : Checkout repository
52- uses : actions/checkout@v6.0.2
53-
54- - name : Set up Rust
55- uses : dtolnay/rust-toolchain@stable
56- with :
57- components : clippy
30+ components : rustfmt, clippy
5831
5932 - name : Cache dependencies
6033 uses : actions/cache@v5.0.4
@@ -63,15 +36,19 @@ jobs:
6336 ~/.cargo/registry
6437 ~/.cargo/git
6538 target
66- key : ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
39+ key : ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
40+
41+ - name : Check formatting
42+ run : cargo fmt --all -- --check
6743
6844 - name : Run Clippy
6945 run : cargo clippy --all-targets --all-features -- -D warnings
7046
7147 build :
72- name : Build
73- runs-on : ubuntu-latest
7448 needs : lint
49+ runs-on : ubuntu-latest
50+ permissions :
51+ contents : read
7552 steps :
7653 - name : Checkout repository
7754 uses : actions/checkout@v6.0.2
9269 run : cargo build --verbose
9370
9471 test :
95- name : Test
9672 needs : build
9773 runs-on : ubuntu-latest
74+ permissions :
75+ contents : read
9876 steps :
9977 - name : Checkout repository
10078 uses : actions/checkout@v6.0.2
@@ -113,3 +91,36 @@ jobs:
11391
11492 - name : Run tests
11593 run : cargo test --verbose
94+
95+ coverage :
96+ needs : test
97+ runs-on : ubuntu-latest
98+ permissions :
99+ contents : read
100+ steps :
101+ - name : Checkout repository
102+ uses : actions/checkout@v6.0.2
103+
104+ - name : Set up Rust
105+ uses : dtolnay/rust-toolchain@stable
106+
107+ - name : Cache dependencies
108+ uses : actions/cache@v5.0.4
109+ with :
110+ path : |
111+ ~/.cargo/registry
112+ ~/.cargo/git
113+ target
114+ key : ${{ runner.os }}-cargo-tarpaulin-${{ hashFiles('**/Cargo.lock') }}
115+
116+ - name : Install cargo-tarpaulin
117+ run : cargo install cargo-tarpaulin
118+
119+ - name : Generate coverage report
120+ run : cargo tarpaulin --out xml
121+
122+ - name : Upload coverage report to Codecov
123+ uses : codecov/codecov-action@v5
124+ with :
125+ token : ${{ secrets.CODECOV_TOKEN }}
126+ slug : nanotaboada/rust-samples-rocket-restful
0 commit comments