-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Add Rust Test Coverage GitHub Action and update workflows (#3)
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Rust Test | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
codecov_token: | ||
required: false | ||
|
||
jobs: | ||
test: | ||
permissions: | ||
# required for all workflows | ||
security-events: write | ||
checks: write | ||
pull-requests: write | ||
# only required for workflows in private repositories | ||
actions: read | ||
contents: read | ||
runs-on: ubuntu-latest | ||
name: Rust Test Coverage | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Rust Test | ||
uses: astraly-labs/workflows/rust/test@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Rust Test Coverage - Github Action | ||
|
||
This action runs Rust tests with code coverage using cargo-llvm-cov and nextest | ||
|
||
The action runs the following: | ||
- Sets up Rust toolchain | ||
- Installs cargo-llvm-cov and nextest | ||
- Runs tests with coverage collection | ||
- Uploads coverage reports to Codecov | ||
|
||
## Inputs | ||
|
||
```yaml | ||
fail_ci: | ||
description: 'Fail CI if coverage upload fails' | ||
required: false | ||
default: false | ||
token: | ||
description: 'Codecov token' | ||
required: false | ||
``` | ||
## Outputs | ||
- LCOV coverage report | ||
- Coverage data uploaded to Codecov | ||
## Detailed example | ||
```yaml | ||
name: Rust Test Coverage | ||
|
||
on: | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Rust Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run Tests | ||
uses: astraly-labs/workflows/rust/test@main | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci: false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Rust Test Coverage | ||
description: Rust Test Coverage using cargo-llvm-cov and nextest | ||
author: 'Yezz123' | ||
inputs: | ||
fail_ci: | ||
description: 'Fail CI if coverage upload fails' | ||
required: false | ||
default: false | ||
type: choice | ||
options: | ||
- 'true' | ||
- 'false' | ||
token: | ||
description: 'Codecov token' | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Rust toolchain | ||
shell: bash | ||
run: rustup show | ||
|
||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
|
||
- name: Install nextest | ||
uses: taiki-e/install-action@nextest | ||
|
||
- name: Clean workspace | ||
shell: bash | ||
run: cargo llvm-cov clean --workspace | ||
|
||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Run tests with coverage | ||
shell: bash | ||
run: cargo llvm-cov nextest --release --lcov --output-path lcov.info | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: lcov.info | ||
token: ${{ inputs.token }} | ||
fail_ci_if_error: ${{ inputs.fail_ci }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@rust/test", | ||
"version": "1.0.0", | ||
"description": "This action runs Rust tests with code coverage using cargo-llvm-cov and nextest", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/astraly-labs/workflows", | ||
"directory": "rust/test" | ||
}, | ||
"private": false, | ||
"author": "Astraly Labs", | ||
"license": "UNLICENSED" | ||
} |