From faa0b6c01f7451678df14c8d4bde97414cf03a31 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 20 Mar 2024 14:49:27 +0100 Subject: [PATCH] Add test coverage PR comment action (#2150) ### New Pull Request Checklist - [ ] I have read the [Documentation](https://pub.dev/documentation/dio/latest/) - [ ] I have searched for a similar pull request in the [project](https://github.com/cfug/dio/pulls) and found none - [ ] I have updated this branch with the latest `main` branch to avoid conflicts (via merge from master or rebase) - [ ] I have added the required tests to prove the fix/feature I'm adding - [ ] I have updated the documentation (if necessary) - [ ] I have run the tests without failures - [ ] I have updated the `CHANGELOG.md` in the corresponding package ### Additional context and info (if any) --- .github/workflows/tests.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aaba3e345..90344511f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,6 +19,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +permissions: + pull-requests: write + defaults: run: shell: bash -leo pipefail {0} @@ -96,7 +99,15 @@ jobs: run: melos run coverage:show - name: '[Coverage] Coverage Report' uses: clearlyip/code-coverage-report-action@v4 + id: code_coverage_report if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]'}} with: - artifact_download_workflow_names: 'tests,coverage_base' + artifact_download_workflow_names: 'Verify packages abilities,coverage_baseline' filename: 'coverage/cobertura.xml' + - name: '[Coverage] Add PR comment' + uses: marocchino/sticky-pull-request-comment@v2 + #Make sure the report was generated and that the event is actually a pull request, run if failed or success + if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]' && steps.code_coverage_report.outputs.file != '' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && (success() || failure()) }} + with: + recreate: true + path: code-coverage-results.md