May 2024 template project update #1
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
name: Run tests | |
on: | |
pull_request: | |
branches: ["main"] | |
env: | |
XCODE_PROJECT: TemplateApp.xcodeproj | |
SCHEME: TemplateApp | |
TEST_PLAN: AllTests | |
TEST_RESULT_BUNDLE: TestResults.xcresult | |
jobs: | |
build: | |
name: Run tests | |
runs-on: [self-hosted, macOS] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache Swift Package Manager dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ runner.temp }}/SourcePackages | |
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} | |
restore-keys: | | |
${{ runner.os }}-spm- | |
- name: Install Swift packages | |
run: | | |
xcodebuild -project "${{ env.XCODE_PROJECT }}" \ | |
-scheme "${{ env.SCHEME }}" \ | |
-onlyUsePackageVersionsFromResolvedFile \ | |
-resolvePackageDependencies \ | |
-clonedSourcePackagesDirPath "${{ runner.temp }}/SourcePackages" | |
- name: Install code signing certificate | |
uses: "./.github/actions/code-signing-setup" | |
with: | |
build-certificate-base64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | |
p12-password: ${{ secrets.P12_PASSWORD }} | |
keychain-password: ${{ secrets.KEYCHAIN_PASSWORD }} | |
- name: Install App Store Connect API key | |
run: | | |
echo -n "${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}" | base64 --decode -o "${{ runner.temp }}/AuthKey.p8" | |
- name: Run tests | |
env: | |
PLATFORM: ${{ 'iOS Simulator' }} | |
run: | | |
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) | |
DEVICE=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` | |
xcodebuild test -project "${{ env.XCODE_PROJECT }}" \ | |
-scheme "${{ env.SCHEME }}" \ | |
-testPlan "${{ env.TEST_PLAN }}" \ | |
-destination "platform=$PLATFORM,name=$DEVICE" \ | |
-resultBundlePath "${{ env.TEST_RESULT_BUNDLE }}" \ | |
-clonedSourcePackagesDirPath "${{ runner.temp }}/SourcePackages" \ | |
-disableAutomaticPackageResolution | |
- name: Upload test result bundle | |
uses: actions/upload-artifact@v4 | |
if: ${{ failure() }} | |
with: | |
name: Xcode test results | |
path: ${{ env.TEST_RESULT_BUNDLE }} |