forked from astarte-platform/stream-rust-test
-
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.
Signed-off-by: Riccardo Gallo <[email protected]>
- Loading branch information
Showing
4 changed files
with
113 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,28 @@ | ||
# This file is part of Astarte. | ||
# | ||
# Copyright 2024 SECO Mind Srl | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# ref: https://docs.codecov.com/docs/codecovyml-reference | ||
coverage: | ||
range: 60..100 | ||
round: down | ||
precision: 1 | ||
status: | ||
# ref: https://docs.codecov.com/docs/commit-status | ||
project: | ||
default: | ||
# Avoid false negatives | ||
threshold: 1% | ||
|
||
# Test files aren't important for coverage | ||
ignore: | ||
- "tests" | ||
- "e2e-test" | ||
- "benches" | ||
|
||
# Make comments less noisy | ||
comment: | ||
layout: "files" | ||
require_changes: yes |
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,40 @@ | ||
# This file is part of Astarte. | ||
# | ||
# Copyright 2024 SECO Mind Srl | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: coverage | ||
defaults: | ||
run: | ||
shell: bash | ||
on: | ||
workflow_run: | ||
workflows: ["ci"] | ||
types: [completed] | ||
permissions: | ||
contents: read | ||
actions: read | ||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
# Run only if originated from a PR | ||
if: ${{ github.event.workflow_run.event == 'pull_request' }} | ||
steps: | ||
- name: Download coverage artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage | ||
github-token: ${{ github.token }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
- name: Get PR number | ||
run: | | ||
echo "PR_NUMBER=$(cat ./pr_number)" >> "$GITHUB_ENV" | ||
- name: Upload to codecov.io | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
fail_ci_if_error: true | ||
override_branch: ${{ github.event.workflow_run.head_branch }} | ||
override_commit: ${{ github.event.workflow_run.head_sha }} | ||
override_pr: ${{ env.PR_NUMBER }} |
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 |
---|---|---|
|
@@ -65,3 +65,43 @@ jobs: | |
run: cargo generate-lockfile | ||
- name: cargo test | ||
run: cargo test --locked --all-features --all-targets --workspace | ||
coverage: | ||
runs-on: ubuntu-latest | ||
name: ubuntu / stable / coverage | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install stable | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: llvm-tools-preview | ||
- name: Install sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
- name: cargo install cargo-tarpaulin | ||
uses: taiki-e/install-action@cargo-tarpaulin | ||
- name: cargo generate-lockfile | ||
if: hashFiles('Cargo.lock') == '' | ||
run: cargo generate-lockfile | ||
- name: Run cargo-tarpaulin with xml output | ||
run: cargo tarpaulin --engine llvm --locked --all-features --ignore-tests --lib --out xml -- --test-threads 1 | ||
# Upload the coverage if we are not a PR from a fork, see ".github/workflows/coverage.yaml" | ||
- name: Upload to codecov.io | ||
if: ${{ github.event_name == 'push' }} | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
fail_ci_if_error: true | ||
# Save data to use in workflow_run | ||
- name: Save PR number | ||
if: ${{ github.event_name == 'pull_request' }} | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
run: | | ||
echo "$PR_NUMBER" > ./pr_number | ||
- name: Upload coverage artifact | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage | ||
path: | | ||
pr_number | ||
cobertura.xml |
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,5 @@ | ||
// This file is part of Astarte. | ||
// | ||
// Copyright 2024 SECO Mind Srl | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 |