Skip to content

Improve test coverage calculation #663

Improve test coverage calculation

Improve test coverage calculation #663

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
jobs:
xcodebuild-15:
name: Build with xcodebuild on Xcode 15
runs-on: macos-14
strategy:
matrix:
platforms: [
'generic/platform=ios',
'platform=macos',
'generic/platform=tvos',
'generic/platform=watchos',
'generic/platform=visionos'
]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer
- name: Build Framework
run: xcrun xcodebuild -skipMacroValidation -skipPackagePluginValidation build -scheme SafeDI-Package -destination ${{ matrix.platforms }}
spm-package-integration-15:
name: Build Package Integration on Xcode 15
runs-on: macos-14
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer
- name: Build Package Integration
run: xcrun swift build --package-path Examples/ExamplePackageIntegration
spm-project-integration-15:
name: Build Project Integration on Xcode 15
runs-on: macos-14
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer
- name: Replace 'main' branch with the current branch
if: github.event.pull_request.head.repo.full_name == github.repository # Only do this if the branch is from our repo.
run: sed -i '' "s#branch = main;#branch = ${{ github.head_ref || github.ref_name }};#" "Examples/ExampleProjectIntegration/ExampleProjectIntegration.xcodeproj/project.pbxproj"
- name: Build Project Integration
run: pushd Examples/ExampleProjectIntegration; xcrun xcodebuild build -skipPackagePluginValidation -skipMacroValidation -scheme ExampleProjectIntegration; popd
spm-multi-project-integration-15:
name: Build Multi Project Integration on Xcode 15
runs-on: macos-14
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer
- name: Replace 'main' branch with the current branch
if: github.event.pull_request.head.repo.full_name == github.repository # Only do this if the branch is from our repo.
run: sed -i '' "s#branch = main;#branch = ${{ github.head_ref || github.ref_name }};#" "Examples/ExampleMultiProjectIntegration/ExampleMultiProjectIntegration.xcodeproj/project.pbxproj"
- name: Build Project Integration
run: pushd Examples/ExampleMultiProjectIntegration; xcrun xcodebuild build -skipPackagePluginValidation -skipMacroValidation -scheme ExampleMultiProjectIntegration; popd
spm-15:
name: Build and Test on Xcode 15
runs-on: macos-14
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer
- name: Build and Test Framework
run: |
for i in {1..5}; do # Run tests a few times to ensure code-gen is stable.
xcrun swift test -c release --enable-code-coverage -Xswiftc -enable-testing
done
- name: Prepare Coverage Reports
run: ./Scripts/prepare-coverage-reports.sh
- name: Upload Coverage Reports
if: success()
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
os: macos
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
linux:
name: Build and Test on Linux
runs-on: ubuntu-latest
container: swift:5.10
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Build and Test Framework
run: swift test -c release --enable-code-coverage -Xswiftc -enable-testing
- name: Prepare Coverage Reports
run: |
llvm-cov export -format="lcov" .build/x86_64-unknown-linux-gnu/release/SafeDIPackageTests.xctest -instr-profile .build/x86_64-unknown-linux-gnu/release/codecov/default.profdata > coverage.lcov
- name: Upload Coverage Reports
if: success()
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
os: linux
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
readme-validation:
name: Check Markdown links
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Validate Markdown
uses: gaurav-nelson/github-action-markdown-link-check@v1
lint-swift:
name: Lint Swift
runs-on: ubuntu-latest
container: swift:5.10
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Lint Swift
run: swift run --package-path CLI swiftformat --swiftversion 5.10 . --lint