test: Migrate to Swift Testing #95
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 | |
permissions: | |
id-token: write | |
contents: read | |
checks: write | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
concurrency: | |
group: ci-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
macos: | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [macos-14, macos-14-arm64] | |
name: Build and test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Xcode Select Version | |
uses: mobiledevops/xcode-select-version-action@v1 | |
with: | |
xcode-select-version: 16_beta_6 | |
- name: Get xcodebuild version | |
run: xcodebuild -version | |
- name: Get swift version | |
run: swift --version | |
- name: Get macOS version | |
run: sw_vers | |
if: startsWith( matrix.os, 'macos' ) | |
- name: Set TEST_GITHUB_TOKEN env variable | |
shell: bash | |
env: | |
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} | |
run: | | |
echo "$TEST_GITHUB_TOKEN" > $HOME/.env | |
- name: Build | |
run: swift build --build-tests | |
- name: Run tests | |
run: swift test --parallel --xunit-output=results.xml | |
- name: Report test results | |
uses: phoenix-actions/test-reporting@v15 | |
id: test-report | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Swift tests on ${{ matrix.os }} | |
path: results.xml | |
reporter: java-junit | |
ubuntu: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
name: Build and test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
container: swiftlang/swift:nightly-6.0-jammy | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get swift version | |
run: swift --version | |
- name: Get macOS version | |
run: sw_vers | |
if: startsWith( matrix.os, 'macos' ) | |
- name: Set TEST_GITHUB_TOKEN env variable | |
shell: bash | |
env: | |
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} | |
run: | | |
echo "$TEST_GITHUB_TOKEN" > $HOME/.env | |
- name: Build | |
run: swift build --build-tests | |
- name: Run tests | |
run: swift test --parallel --xunit-output=results.xml | |
- name: Workaround for test-reporting issue 1169 | |
run: git config --system --add safe.directory /__w/github-stats/github-stats | |
if: success() || failure() # run this step even if previous step failed | |
- name: Report test results | |
uses: phoenix-actions/test-reporting@v15 | |
id: test-report | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Swift tests on ${{ matrix.os }} | |
path: results.xml | |
reporter: java-junit | |