- Create a Github action for your SwiftPM project.
- Add a step to build:
swift build
- Add a step to run tests:
swift test --enable-code-coverage
- Fetch coverage value (see below)
- Write coverage value to gist and generate badge from it
For step #4, we need to do some sleuthing and digging around into artifacts created by the Swift toolchain. First, we need to find the location of the XCTest bundle that step #3 generated and save it in an environment variable: