Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish code coverage for unit tests #55

Open
dhebbeker opened this issue Nov 1, 2023 · 1 comment
Open

publish code coverage for unit tests #55

dhebbeker opened this issue Nov 1, 2023 · 1 comment
Labels
CI infrastructure Anything related to automatic builds and checks. help wanted Extra attention is needed testing Related to creating tests and its infrastructure.

Comments

@dhebbeker
Copy link
Member

dhebbeker commented Nov 1, 2023

See WIP.

Acceptance criteria:

  • for all executed unit tests the code coverage shall be published as HTML
  • the code coverage shall be prominently visible in each pull request
  • the intention is to motivate a high code coverage before requesting a merge

Depends on:

@dhebbeker dhebbeker added CI infrastructure Anything related to automatic builds and checks. testing Related to creating tests and its infrastructure. help wanted Extra attention is needed blocked Requires another issue to be resolved first. and removed blocked Requires another issue to be resolved first. labels Nov 1, 2023
@dhebbeker
Copy link
Member Author

The code coverage (GCDA and GCNO files) is already generated. The HTML report is missing.

This may be helpful (generated via ChatGPT):

name: Unit Test with Coverage

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Repository
      uses: actions/checkout@v2

    - name: Install PlatformIO
      run: sudo apt-get install -y python3-pip && pip3 install -U platformio

    - name: Install lcov
      run: sudo apt-get install lcov

    - name: Run Unit Tests with Coverage
      run: |
        platformio test --environment <your_environment> --project-option="build_flags=-ftest-coverage -fprofile-arcs"

    - name: Generate Coverage HTML Report
      run: |
        lcov --capture --directory . --output-file coverage.info
        lcov --remove coverage.info '/usr/*' --output-file coverage.info
        genhtml coverage.info --output-directory coverage-html

    - name: Upload Coverage HTML Report
      uses: actions/upload-artifact@v2
      with:
        name: coverage-report
        path: coverage-html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI infrastructure Anything related to automatic builds and checks. help wanted Extra attention is needed testing Related to creating tests and its infrastructure.
Projects
None yet
Development

No branches or pull requests

1 participant