Skip to content

Commit

Permalink
Simple Code Coverage analysis (#378)
Browse files Browse the repository at this point in the history
Closes #350.

Adds simple code coverage analysis. Until the GitHub token is set up in this repo, you can see the results including a comment on the PR here: mattpolzin#2

* Adding codecov CI workflow.

* doh. forgot to skip build.

* drop unneeded llvm env var from build invocation. make comment always run.

* try a way to update a previous comment

* try to get comments to run on failure.

* use bug fix to codecov action.

* fix comment search string and drop min coverage

* use replace on comment updates

* attempt at diffing coverage from main branch

* comment out tests to affect test coverage

* try method for multiline outputs

* do i need to put it in its own script file

* right, switch coverage gen order to have branch checked out second.

* attempt to get code quotation around diff output.

* switch to git diff

* add note about the new script.

* try echoing a warning.

* post warning on success and error on failure.

* uncomment tests
  • Loading branch information
mattpolzin committed Feb 5, 2021
1 parent 53b474c commit ea94ef9
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

name: Codecov

on:
pull_request:
push:
branches: [main]

jobs:
codecov:
container:
image: swift:5.3.2-bionic
runs-on: ubuntu-latest
steps:
- run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0
- name: Checkout Branch
uses: actions/checkout@v2
- name: Build Test Target
run: swift build --enable-test-discovery -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests
- name: Run Tests
run: swift test --enable-test-discovery --enable-code-coverage --skip-build
- name: Generate Branch Coverage Report
uses: mattpolzin/swift-codecov-action@0.6.1
id: cov
with:
MINIMUM_COVERAGE: 20
- name: Post Positive Results
if: ${{ success() }}
run: |
echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)."
- name: Post Negative Results
if: ${{ failure() }}
run: |
echo "::error file=Package.swift,line=1,col=1::The current code coverage percentage is failing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)."

0 comments on commit ea94ef9

Please sign in to comment.