mattpolzin / swift-codecov-action

MIT License
17 stars 1 forks source link

swift-codecov-action

A very simple code coverage summary tool for Swift. This tool takes in the JSON output of Swift's code coverage analysis and produces an overall coverage percentage and per-file coverage percentages.

Under the hood, this action uses the https://github.com/mattpolzin/swift-test-codecov tool (written in Swift).

Run this as a GitHub action in the same workflow job as your project's tests are run.

Note that the flow below will only work if your project can be built & tested in a Linux environment because GitHub Actions cannot run Docker on Mac machines and this action runs in a Docker container.

For example,

jobs:
  codecov:
    container:
      image: swift:5.7
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - run: swift test --enable-test-discovery --enable-code-coverage
    - uses: mattpolzin/swift-codecov-action@0.7.5
      with:
        MINIMUM_COVERAGE: 98
        INCLUDE_TESTS: 'true'

Note that you must execute your project's tests using swift test with the --enable-code-coverage argument to generate the file ingested by this action.

All boolean inputs below must be specified as strings (be sure to put them in quotes in your YAML file).

Inputs:

Outputs:

Regardless of whether or not you have chosen to have the action print to stdout, the code coverage table will be dumped to the ./codecov.txt file.