From 565e9fe0ebaaf6043f05d537d9e1fe787b16b1fb Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Fri, 24 Jan 2025 16:36:43 +0100 Subject: [PATCH 1/5] Run tests on GitHub Actions --- .github/workflows/test.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4d114a6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + name: Build and Test on iOS Simulator + runs-on: macos-latest + env: + scheme: ${{ 'CCCTube' }} + platform: ${{ 'iOS Simulator' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build + 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$//"` + if [ $scheme = default ]; then scheme=$(cat default); fi + if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + xcodebuild build-for-testing -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" + + - name: Test + 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$//"` + if [ $scheme = default ]; then scheme=$(cat default); fi + if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + xcodebuild test-without-building -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" From 30ae81cbc5a7ec8ad8f6590e07895489c26257df Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Fri, 24 Jan 2025 16:38:06 +0100 Subject: [PATCH 2/5] Set Xcode version in GitHub Actions to 16.1 --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d114a6..5e744d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "16.1" + - name: Build run: | # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) From 5dcd9530a47c93511cc7effe4f3b09e537c2b91a Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Fri, 24 Jan 2025 16:47:39 +0100 Subject: [PATCH 3/5] Fix test configuration --- CCCTube.xcodeproj/project.pbxproj | 8 ++++---- CCCTube.xcodeproj/xcshareddata/xcschemes/CCCTube.xcscheme | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CCCTube.xcodeproj/project.pbxproj b/CCCTube.xcodeproj/project.pbxproj index 9948ed3..9a26b17 100644 --- a/CCCTube.xcodeproj/project.pbxproj +++ b/CCCTube.xcodeproj/project.pbxproj @@ -58,9 +58,9 @@ D59139402895851300369402 /* TVServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TVServices.framework; path = System/Library/Frameworks/TVServices.framework; sourceTree = SDKROOT; }; D591395928958B2600369402 /* CCCTubeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CCCTubeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D5A156D4289462B3006989FF /* CCCTube.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CCCTube.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D5D2CB292D43EBB300E08E44 /* Screenshots.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Screenshots.xctestplan; sourceTree = ""; }; + D5D2CB2A2D43EBB300E08E44 /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UnitTests.xctestplan; sourceTree = ""; }; D5EFB19C2B407683008CFE82 /* CCCTubeUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CCCTubeUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - D5EFB1A72B407792008CFE82 /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UnitTests.xctestplan; sourceTree = SOURCE_ROOT; }; - D5EFB1A82B4077A3008CFE82 /* Screenshots.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Screenshots.xctestplan; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ @@ -156,8 +156,8 @@ isa = PBXGroup; children = ( D557E8BA2896F70400342EE2 /* README.md */, - D5EFB1A72B407792008CFE82 /* UnitTests.xctestplan */, - D5EFB1A82B4077A3008CFE82 /* Screenshots.xctestplan */, + D5D2CB292D43EBB300E08E44 /* Screenshots.xctestplan */, + D5D2CB2A2D43EBB300E08E44 /* UnitTests.xctestplan */, D5AFD6D92C9BFCF700BF89F5 /* CCCTube */, D50C6F7328956D770003D1D0 /* CCCApi */, D5AFD6FB2C9BFCFB00BF89F5 /* TopShelf */, diff --git a/CCCTube.xcodeproj/xcshareddata/xcschemes/CCCTube.xcscheme b/CCCTube.xcodeproj/xcshareddata/xcschemes/CCCTube.xcscheme index d0ca76e..a2dffa7 100644 --- a/CCCTube.xcodeproj/xcshareddata/xcschemes/CCCTube.xcscheme +++ b/CCCTube.xcodeproj/xcshareddata/xcschemes/CCCTube.xcscheme @@ -29,11 +29,11 @@ shouldUseLaunchSchemeArgsEnv = "YES"> + reference = "container:Screenshots.xctestplan"> + reference = "container:UnitTests.xctestplan" + default = "YES"> From c799ff225e1296939d7698f44f33c89964e44a5a Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Fri, 24 Jan 2025 16:47:44 +0100 Subject: [PATCH 4/5] Update screenshots script --- screenshots.sh | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/screenshots.sh b/screenshots.sh index 5947fd3..58510ac 100755 --- a/screenshots.sh +++ b/screenshots.sh @@ -2,6 +2,7 @@ # This script automates the process of taking screenshots for the App Store. # It uses UI tests target, which are configured in the Screenshots test plan. +# The final screenshots are saved in a folder named 'screenshots'. set -e @@ -17,23 +18,7 @@ then exit 1 fi -# xcrun simctl create "iPhone 15 Plus" "iPhone 15 Plus" "iOS17.5" -# xcrun simctl create "iPhone 8 Plus" "iPhone 8 Plus" "iOS16.4" -# xcrun simctl create "iPad Pro 13-inch (M4)" "iPad Pro 13-inch (M4)" "iOS17.5" -# xcrun simctl create "iPad Pro (12.9-inch) (2nd generation)" "iPad Pro (12.9-inch) (2nd generation)" "iOS17.5" - -# xcodebuild -verbose \ -# -project "CCCTube.xcodeproj" \ -# -scheme "CCCTube" \ -# -destination "platform=iOS Simulator,name=iPhone 8 Plus" \ -# -destination "platform=iOS Simulator,name=iPhone 15 Plus" \ -# -destination "platform=iOS Simulator,name=iPad Pro 13-inch (M4)" \ -# -destination "platform=iOS Simulator,name=iPad Pro (12.9-inch) (2nd generation)" \ -# -resultBundlePath "./Screenshots.xcresult" \ -# -testPlan Screenshots \ -# clean test - -declare -a destinations=("platform=iOS Simulator,name=iPhone 8 Plus" "platform=iOS Simulator,name=iPhone 15 Plus" "platform=iOS Simulator,name=iPad Pro 13-inch (M4)" "platform=iOS Simulator,name=iPad Pro (12.9-inch) (2nd generation)") +declare -a destinations=("platform=iOS Simulator,name=iPhone 16 Plus" "platform=iOS Simulator,name=iPad Pro 13-inch (M4)") rm -rf ./screenshots mkdir ./screenshots @@ -47,7 +32,7 @@ echo "Taking screenshots for $destination" xcodebuild -quiet \ -project "CCCTube.xcodeproj" \ -scheme "CCCTube" \ --destination "platform=iOS Simulator,name=iPhone 15 Plus" \ +-destination "$destination" \ -resultBundlePath "./Screenshots.xcresult" \ -testPlan Screenshots \ clean test @@ -58,5 +43,3 @@ done # Remove alpha channel from the screenshots, otherwise the App Store will reject them find ./screenshots -name "*.png" -exec convert "{}" -alpha off "{}" \; - -open ./screenshots From 138342e0801d43c363800ffe1143335b202f3cf1 Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Fri, 24 Jan 2025 16:53:50 +0100 Subject: [PATCH 5/5] Fix UI test to work with new tab bar --- CCCTubeUITests/CCCTubeUIScreenshotTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCCTubeUITests/CCCTubeUIScreenshotTests.swift b/CCCTubeUITests/CCCTubeUIScreenshotTests.swift index 0d0d7d8..6449380 100644 --- a/CCCTubeUITests/CCCTubeUIScreenshotTests.swift +++ b/CCCTubeUITests/CCCTubeUIScreenshotTests.swift @@ -23,7 +23,7 @@ final class CCCTubeUIScreenshotTests: XCTestCase { } func testConferences() { - app.tabBars.buttons["Conferences"].firstMatch.tap() + app.buttons["Conferences"].firstMatch.tap() XCTAssertTrue(app.otherElements["ConferencesGrid"].buttons.firstMatch.waitForExistence(timeout: 3.0)) wait(forTimeInterval: 2.0) // Give the app some time to load takeScreenshot("Conferences")