Skip to content

Send coverage report to Coveralls on all commits in main/develop branches #961

Send coverage report to Coveralls on all commits in main/develop branches

Send coverage report to Coveralls on all commits in main/develop branches #961

Workflow file for this run

name: Coverage
on:
push:
branches:
# Run coverage workflows on all the commits pushed to the following branches
# following the recommended CI configurations for Coveralls.
# https://docs.coveralls.io/build-types#recommended-ci-configurations
- develop
- main
# Run on pull requests from both branches and forks.
pull_request:
paths:
- .github/workflows/coverage.yml
- cmake/**
- include/**
- tests/**
- CMakeLists.txt
- Makefile
workflow_dispatch:
jobs:
coverage:
timeout-minutes: 10
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v7
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{github.event.pull_request.head.sha}}
persist-credentials: false
- name: Install lcov
run: |
sudo apt-get update
sudo apt-get install -y lcov
lcov -v
- name: Generate coverage
run: make html-coverage
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
file: ${{github.workspace}}/build_coverage/coverage/fkYAML.info
format: lcov
- name: Decide the artifact name
id: create_zip
env:
PR_NUMBER: ${{github.event.number}}
run: |
echo "artifact name: fkYAML_coverage.pr${{env.PR_NUMBER}}"
echo "artifact_name=fkYAML_coverage.pr${{env.PR_NUMBER}}" >> $GITHUB_OUTPUT
- name: Upload coverage as an artifact
id: upload_artifact_step
if: steps.create_zip.conclusion == 'success'
uses: actions/upload-artifact@v7
with:
name: ${{steps.create_zip.outputs.artifact_name}}
path: |
${{github.workspace}}/build_coverage/coverage/*
${{github.workspace}}/build_coverage/html/**
overwrite: true
- name: Notify the artifact URL
if: github.event_name == 'pull_request' && steps.upload_artifact_step.conclusion == 'success'
uses: thollander/actions-comment-pull-request@v3
with:
message: |
## :octocat: Upload Coverage Event Notification
Coverage data has been uploaded for the commit [${{github.event.pull_request.head.sha}}](https://github.com/${{github.repository}}/commit/${{github.event.pull_request.head.sha}}).
You can download the artifact which contains the same file uploaded to the Coveralls and its HTML version.
| Name | ${{steps.create_zip.outputs.artifact_name}}.zip |
|:-----|:-----------------------------------------------------|
| ID | ${{steps.upload_artifact_step.outputs.artifact-id}} |
| URL | ${{steps.upload_artifact_step.outputs.artifact-url}} |
comment-tag: coverage_notification