Consolidate CI Workflows into a Single Unified Workflow #3
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 runs CI tests for the main package and Examples package | |
name: CI | |
# Trigger the workflow on push to main, any pull request, or manual dispatch | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- '*' | |
workflow_dispatch: | |
# Ensure only one workflow per ref is running at a time | |
concurrency: | |
group: ci-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
macos: | |
name: macOS - ${{ matrix.package }} (Xcode ${{ matrix.xcode }}) | |
runs-on: macos-14 | |
strategy: | |
matrix: | |
xcode: | |
- '15.4' | |
- '15.0' | |
package: ['main', 'examples'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Select Xcode ${{ matrix.xcode }} | |
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app | |
- name: Print Swift version | |
run: swift --version | |
# Set working directory to Examples if testing the examples package | |
- name: Set working directory | |
run: | | |
if [ "${{ matrix.package }}" = "examples" ]; then | |
cd Examples | |
fi | |
- name: Build package | |
run: swift build | |
- name: Run tests | |
run: swift test -Xswiftc -Xfrontend -Xswiftc -dump-macro-expansions --enable-code-coverage | |
# Gather and upload code coverage only for the main package | |
- name: Gather code coverage | |
if: matrix.package == 'main' | |
run: | | |
BUILD_PATH=$(swift build --show-bin-path) | |
xcrun llvm-cov report \ | |
$BUILD_PATH/swift-spyablePackageTests.xctest/Contents/MacOS/swift-spyablePackageTests \ | |
-instr-profile=$BUILD_PATH/codecov/default.profdata \ | |
-ignore-filename-regex=".build|Tests" -use-color | |
xcrun llvm-cov export -format="lcov" \ | |
$BUILD_PATH/swift-spyablePackageTests.xctest/Contents/MacOS/swift-spyablePackageTests \ | |
-instr-profile=$BUILD_PATH/codecov/default.profdata \ | |
-ignore-filename-regex=".build|Tests" > coverage_report.lcov | |
- name: Upload coverage reports to Codecov | |
if: matrix.package == 'main' | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage_report.lcov | |
verbose: true | |
linux: | |
name: Ubuntu - ${{ matrix.package }} (Swift ${{ matrix.swift }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
swift: | |
- '5.10' | |
- '5.9' | |
package: ['main', 'examples'] | |
container: swift:${{ matrix.swift }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Set working directory to Examples if testing the examples package | |
- name: Set working directory | |
run: | | |
if [ "${{ matrix.package }}" = "examples" ]; then | |
cd Examples | |
fi | |
- name: Build package | |
run: swift build | |
- name: Run tests (debug) | |
run: swift test --parallel | |
- name: Run tests (release) | |
run: swift test -c release --parallel | |
windows: | |
name: Windows - ${{ matrix.package }} (Swift ${{ matrix.swift }}) | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
swift: | |
- '5.10' | |
- '5.9' | |
package: ['main', 'examples'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Swift | |
uses: compnerd/gha-setup-swift@main | |
with: | |
branch: swift-${{ matrix.swift }}-release | |
tag: ${{ matrix.swift }}-RELEASE | |
# Set working directory to Examples if testing the examples package | |
- name: Set working directory | |
run: | | |
if ("${{ matrix.package }}" -eq "examples") { | |
cd Examples | |
} | |
- name: Build package | |
run: swift build | |
# - name: Run tests (debug) | |
# run: swift test --parallel | |
# | |
# - name: Run tests (release) | |
# run: swift test -c release --parallel |