Skip to content

Always upload test results #24

Always upload test results

Always upload test results #24

# Build and Test the Xcode App
# This tests the `AppPackage` as well as the `App` Xcode project.
name: Build and Test (Xcode)
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
build-and-test-xcode:
strategy:
matrix:
xcode-version:
- "16"
xcode-configuration:
- name: iOS Simulator
destination: "platform=iOS Simulator,name=iPhone 16"
- name: macOS
destination: "platform=macOS"
build-configuration:
- "Debug"
- "Release"
runs-on: macos-15
name: Build and Test (${{ matrix.xcode-configuration.name }}, ${{ matrix.build-configuration }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer
# When we specialize this template, we don't have permissions to change workflows, so we cant reference the name of the project here.
- name: Get Repository Name
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV
- name: Build
run: |
xcrun xcodebuild clean build \
-workspace ${REPO_NAME}.xcworkspace \
-scheme ${REPO_NAME}App \
-derivedDataPath ".build/Xcode.noindex/DerivedData" \
-configuration "${{ matrix.build-configuration }}" \
-destination "${{ matrix.xcode-configuration.destination }}"
- name: SwiftPM Tests
if: matrix.build-configuration == 'Debug'
run: |
REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}
xcrun xcodebuild test \
-workspace ${REPO_NAME}.xcworkspace \
-scheme ${REPO_NAME}AppPackage \
-derivedDataPath ".build/Xcode.noindex/DerivedData" \
-configuration "${{ matrix.build-configuration }}" \
-destination "${{ matrix.xcode-configuration.destination }}"
- name: UI Tests
run: |
xcrun xcodebuild test \
-workspace ${REPO_NAME}.xcworkspace \
-scheme ${REPO_NAME}AppUITests \
-derivedDataPath ".build/Xcode.noindex/DerivedData" \
-configuration "${{ matrix.build-configuration }}" \
-destination "${{ matrix.xcode-configuration.destination }}"
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (${{ matrix.xcode-configuration.name }}, ${{ matrix.build-configuration }})
path: .build/Xcode.noindex/DerivedData/Logs/Test
- name: Check that repository is clean
run:
git diff --exit-code