Skip to content

A Github action that parses a swift test coverage report and outputs a percentage for displaying a badge.

License

Notifications You must be signed in to change notification settings

codefiesta/swift-coverage-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Swift 6.0+ License: MIT

Swift Coverage Action

Swift Coverage Action is a simple Github action that parses a swift test coverage report and outputs a percentage for displaying a badge.

Usage

The following is an example of how to setup a Github action that extracts the percentage output from the Swift Coverage Action and pushes the output (code coverage percentage) into the Dynamic Badges Action.

name: Swift Coverage

jobs:
  build:
    runs-on: macos-15
    steps:
    - uses: actions/checkout@v4
    - name: Build
      run: swift build -v
    - name: Test
      run: swift test --enable-code-coverage
    - id: coverage
      uses: codefiesta/swift-coverage-action@0.0.1
    - name: badge
      # Only run the badge update if we are pushing to main
      if: github.ref == 'refs/heads/main'
      uses: schneegans/dynamic-badges-action@v1.7.0
      with:
        auth: ${{secrets.GIST_SECRET}}
        gistID: <GIST_ID>
        filename: coverage.json
        label: Coverage
        message: ${{steps.coverage.outputs.percentage}}%
        color: white

About

A Github action that parses a swift test coverage report and outputs a percentage for displaying a badge.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published