Rename snapshots (#4756)
* renaming snapshots so that it's easier to diff them when an upgrade happens. * fix macOS runner version for the compound tests * os version update in the yml * possible fix to run compound-ios tests
This commit is contained in:
17
.github/workflows/compound-ios.yml
vendored
17
.github/workflows/compound-ios.yml
vendored
@@ -4,17 +4,22 @@
|
||||
name: Compound
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
push:
|
||||
branches: [ develop ]
|
||||
paths: [ 'compound-ios/**' ]
|
||||
paths:
|
||||
- 'compound-ios/**'
|
||||
|
||||
pull_request:
|
||||
paths: [ 'compound-ios/**' ]
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- 'compound-ios/**'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
|
||||
runs-on: macos-15
|
||||
runs-on: macos-26
|
||||
timeout-minutes: 15
|
||||
|
||||
concurrency:
|
||||
@@ -27,7 +32,7 @@ jobs:
|
||||
- uses: nschloe/action-cached-lfs-checkout@f46300cd8952454b9f0a21a3d133d4bd5684cfc2 #v1.2.3
|
||||
|
||||
- name: Configure Xcode 26
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.0.app
|
||||
run: sudo xcode-select -s /Applications/Xcode_26.1_Release_Candidate.app
|
||||
|
||||
- name: Install sourcery
|
||||
run: brew install sourcery
|
||||
@@ -37,11 +42,11 @@ jobs:
|
||||
run: sourcery --config Tools/Sourcery/PreviewTestsConfig.yml
|
||||
|
||||
- name: Create simulator
|
||||
run: xcrun simctl create "Snapshots" "iPhone SE (3rd generation)" "com.apple.CoreSimulator.SimRuntime.iOS-26-0"
|
||||
run: xcrun simctl create "Snapshots" "iPhone SE (3rd generation)" "com.apple.CoreSimulator.SimRuntime.iOS-26-1"
|
||||
|
||||
- name: Run tests
|
||||
working-directory: compound-ios
|
||||
run: set -o pipefail && xcodebuild test -scheme 'Compound' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=Snapshots,OS=26.0.1' -skipPackagePluginValidation -resultBundlePath Logs/CompoundTests.xcresult | xcbeautify --renderer github-actions
|
||||
run: set -o pipefail && xcodebuild test -scheme 'Compound' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=Snapshots,OS=26.1' -skipPackagePluginValidation -resultBundlePath Logs/CompoundTests.xcresult | xcbeautify --renderer github-actions
|
||||
|
||||
- name: Zip artifacts
|
||||
if: failure() # We only care about artefacts if the tests fail
|
||||
|
||||
@@ -15,10 +15,18 @@ import XCTest
|
||||
|
||||
@MainActor
|
||||
class PreviewTests: XCTestCase {
|
||||
private struct SnapshotDevice {
|
||||
let name: String
|
||||
let device: String
|
||||
}
|
||||
|
||||
private let deviceConfig: ViewImageConfig = .iPhoneX
|
||||
private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
|
||||
private let requiredOSVersion = (major: 26, minor: 1)
|
||||
private let snapshotDevices = ["iPhone 16", "iPad"]
|
||||
// The key is the name we will give to the snapshot
|
||||
// The value is the actual device that will be used to render the preview
|
||||
private let snapshotDevices: [SnapshotDevice] = [.init(name: "iPhone", device: "iPhone 17"),
|
||||
.init(name: "iPad", device: "iPad")]
|
||||
private var recordMode: SnapshotTestingConfiguration.Record = .missing
|
||||
|
||||
override func setUp() {
|
||||
@@ -78,9 +86,9 @@ class PreviewTests: XCTestCase {
|
||||
var sanitizedSuiteName = String(testName.suffix(testName.count - "test".count).dropLast(2))
|
||||
sanitizedSuiteName = sanitizedSuiteName.prefix(1).lowercased() + sanitizedSuiteName.dropFirst()
|
||||
|
||||
for deviceName in snapshotDevices {
|
||||
guard var device = PreviewDevice(rawValue: deviceName).snapshotDevice() else {
|
||||
fatalError("Unknown device name: \(deviceName)")
|
||||
for snapshotDevice in snapshotDevices {
|
||||
guard var device = PreviewDevice(rawValue: snapshotDevice.device).snapshotDevice() else {
|
||||
fatalError("Unknown device name: \(snapshotDevice.device)")
|
||||
}
|
||||
// Ignore specific device safe area (using the workaround value to fix rendering issues).
|
||||
device.safeArea = .one
|
||||
@@ -89,9 +97,9 @@ class PreviewTests: XCTestCase {
|
||||
|
||||
var testName = ""
|
||||
if let displayName = preview.displayName {
|
||||
testName = "\(displayName)-\(deviceName)-\(localeCode)"
|
||||
testName = "\(displayName)-\(snapshotDevice.name)-\(localeCode)"
|
||||
} else {
|
||||
testName = "\(deviceName)-\(localeCode)-\(step)"
|
||||
testName = "\(snapshotDevice.name)-\(localeCode)-\(step)"
|
||||
}
|
||||
|
||||
let isScreen = switch preview.layout {
|
||||
@@ -167,7 +175,7 @@ private class SnapshotPreferences: @unchecked Sendable {
|
||||
private extension PreviewDevice {
|
||||
func snapshotDevice() -> ViewImageConfig? {
|
||||
switch rawValue {
|
||||
case "iPhone 16", "iPhone 15", "iPhone 14", "iPhone 13", "iPhone 12", "iPhone 11", "iPhone 10":
|
||||
case "iPhone 17", "iPhone 16", "iPhone 15", "iPhone 14", "iPhone 13", "iPhone 12", "iPhone 11", "iPhone 10":
|
||||
return .iPhoneX
|
||||
case "iPhone 6", "iPhone 6s", "iPhone 7", "iPhone 8":
|
||||
return .iPhone8
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user