Add code coverage action #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Swift project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift | |
name: Swift | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build_and_test: | |
# TODO: once https://github.com/swift-actions/setup-swift/pull/684 is merged, revert to: | |
# runs-on: macos-latest | |
# steps: | |
# - uses: swift-actions/setup-swift@v2 | |
# with: | |
# swift-version: "6.0.1" | |
runs-on: macos-15 | |
steps: | |
- name: Get swift version | |
run: swift --version | |
- uses: actions/checkout@v4 | |
- name: Build | |
run: swift build -q | |
- name: Run tests | |
run: swift test -q --enable-code-coverage | |
# Upload code coverage | |
- uses: michaelhenry/swifty-code-coverage@v1.0.0 | |
with: | |
build-path: .build | |
target: MCPPackageTests.xctest | |
is-spm: true | |
- name: Upload to Codecov | |
run: | | |
bash <(curl https://codecov.io/bash) -f "coverage/*.info" | |
shell: bash | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
lint: | |
runs-on: macos-15 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run linter | |
run: swift package --allow-writing-to-package-directory format | |
- name: Verify that `swift package --allow-writing-to-package-directory format` did not change outputs (if it did, please re-run it and re-commit!) | |
run: git diff --exit-code |