File tree Expand file tree Collapse file tree 5 files changed +144
-0
lines changed Expand file tree Collapse file tree 5 files changed +144
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Rust Test
2
+
3
+ on :
4
+ workflow_call :
5
+ secrets :
6
+ codecov_token :
7
+ required : false
8
+
9
+ jobs :
10
+ test :
11
+ permissions :
12
+ # required for all workflows
13
+ security-events : write
14
+ checks : write
15
+ pull-requests : write
16
+ # only required for workflows in private repositories
17
+ actions : read
18
+ contents : read
19
+ runs-on : ubuntu-latest
20
+ name : Rust Test Coverage
21
+ steps :
22
+ - name : Checkout
23
+ uses : actions/checkout@v4
24
+ with :
25
+ fetch-depth : 0
26
+ - name : Rust Test
27
+ uses : astraly-labs/workflows/rust/test@main
Original file line number Diff line number Diff line change 13
13
Scan :
14
14
uses : astraly-labs/workflows/.github/workflows/rust-scan.yaml@main
15
15
secrets : inherit
16
+ Test :
17
+ uses : astraly-labs/workflows/.github/workflows/rust-test.yaml@main
18
+ secrets : inherit
Original file line number Diff line number Diff line change
1
+ # Rust Test Coverage - Github Action
2
+
3
+ This action runs Rust tests with code coverage using cargo-llvm-cov and nextest
4
+
5
+ The action runs the following:
6
+ - Sets up Rust toolchain
7
+ - Installs cargo-llvm-cov and nextest
8
+ - Runs tests with coverage collection
9
+ - Uploads coverage reports to Codecov
10
+
11
+ ## Inputs
12
+
13
+ ``` yaml
14
+ fail_ci :
15
+ description : ' Fail CI if coverage upload fails'
16
+ required : false
17
+ default : false
18
+ token :
19
+ description : ' Codecov token'
20
+ required : false
21
+ ` ` `
22
+
23
+ ## Outputs
24
+
25
+ - LCOV coverage report
26
+ - Coverage data uploaded to Codecov
27
+
28
+ ## Detailed example
29
+
30
+ ` ` ` yaml
31
+ name : Rust Test Coverage
32
+
33
+ on :
34
+ pull_request : {}
35
+ workflow_dispatch : {}
36
+ push :
37
+ branches :
38
+ - main
39
+
40
+ jobs :
41
+ test :
42
+ name : Rust Tests
43
+ runs-on : ubuntu-latest
44
+
45
+ steps :
46
+ - name : Checkout source code
47
+ uses : actions/checkout@v3
48
+
49
+ - name : Run Tests
50
+ uses : astraly-labs/workflows/rust/test@main
51
+ with :
52
+ token : ${{ secrets.CODECOV_TOKEN }}
53
+ fail_ci : false
54
+ ` ` `
Original file line number Diff line number Diff line change
1
+ name : Rust Test Coverage
2
+ description : Rust Test Coverage using cargo-llvm-cov and nextest
3
+ author : ' Yezz123'
4
+ inputs :
5
+ fail_ci :
6
+ description : ' Fail CI if coverage upload fails'
7
+ required : false
8
+ default : false
9
+ type : choice
10
+ options :
11
+ - ' true'
12
+ - ' false'
13
+ token :
14
+ description : ' Codecov token'
15
+ required : false
16
+
17
+ runs :
18
+ using : composite
19
+ steps :
20
+ - name : Setup Rust toolchain
21
+ shell : bash
22
+ run : rustup show
23
+
24
+ - name : Install cargo-llvm-cov
25
+ uses : taiki-e/install-action@cargo-llvm-cov
26
+
27
+ - name : Install nextest
28
+ uses : taiki-e/install-action@nextest
29
+
30
+ - name : Clean workspace
31
+ shell : bash
32
+ run : cargo llvm-cov clean --workspace
33
+
34
+ - name : Setup Rust cache
35
+ uses : Swatinem/rust-cache@v2
36
+
37
+ - name : Run tests with coverage
38
+ shell : bash
39
+ run : cargo llvm-cov nextest --release --lcov --output-path lcov.info
40
+
41
+ - name : Upload coverage to Codecov
42
+ uses : codecov/codecov-action@v3
43
+ with :
44
+ files : lcov.info
45
+ token : ${{ inputs.token }}
46
+ fail_ci_if_error : ${{ inputs.fail_ci }}
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " @rust/test" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " This action runs Rust tests with code coverage using cargo-llvm-cov and nextest" ,
5
+ "main" : " index.js" ,
6
+ "repository" : {
7
+ "type" : " git" ,
8
+ "url" : " https://github.com/astraly-labs/workflows" ,
9
+ "directory" : " rust/test"
10
+ },
11
+ "private" : false ,
12
+ "author" : " Astraly Labs" ,
13
+ "license" : " UNLICENSED"
14
+ }
You can’t perform that action at this time.
0 commit comments