mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:12:26 +00:00
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:
@@ -4,17 +4,22 @@
|
|||||||
name: Compound
|
name: Compound
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
push:
|
push:
|
||||||
branches: [ develop ]
|
branches: [ develop ]
|
||||||
paths: [ 'compound-ios/**' ]
|
paths:
|
||||||
|
- 'compound-ios/**'
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths: [ 'compound-ios/**' ]
|
types: [opened, synchronize, reopened]
|
||||||
|
paths:
|
||||||
|
- 'compound-ios/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
|
|
||||||
runs-on: macos-15
|
runs-on: macos-26
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
@@ -27,7 +32,7 @@ jobs:
|
|||||||
- uses: nschloe/action-cached-lfs-checkout@f46300cd8952454b9f0a21a3d133d4bd5684cfc2 #v1.2.3
|
- uses: nschloe/action-cached-lfs-checkout@f46300cd8952454b9f0a21a3d133d4bd5684cfc2 #v1.2.3
|
||||||
|
|
||||||
- name: Configure Xcode 26
|
- 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
|
- name: Install sourcery
|
||||||
run: brew install sourcery
|
run: brew install sourcery
|
||||||
@@ -37,11 +42,11 @@ jobs:
|
|||||||
run: sourcery --config Tools/Sourcery/PreviewTestsConfig.yml
|
run: sourcery --config Tools/Sourcery/PreviewTestsConfig.yml
|
||||||
|
|
||||||
- name: Create simulator
|
- 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
|
- name: Run tests
|
||||||
working-directory: compound-ios
|
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
|
- name: Zip artifacts
|
||||||
if: failure() # We only care about artefacts if the tests fail
|
if: failure() # We only care about artefacts if the tests fail
|
||||||
|
|||||||
@@ -15,10 +15,18 @@ import XCTest
|
|||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class PreviewTests: XCTestCase {
|
class PreviewTests: XCTestCase {
|
||||||
|
private struct SnapshotDevice {
|
||||||
|
let name: String
|
||||||
|
let device: String
|
||||||
|
}
|
||||||
|
|
||||||
private let deviceConfig: ViewImageConfig = .iPhoneX
|
private let deviceConfig: ViewImageConfig = .iPhoneX
|
||||||
private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
|
private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
|
||||||
private let requiredOSVersion = (major: 26, minor: 1)
|
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
|
private var recordMode: SnapshotTestingConfiguration.Record = .missing
|
||||||
|
|
||||||
override func setUp() {
|
override func setUp() {
|
||||||
@@ -78,9 +86,9 @@ class PreviewTests: XCTestCase {
|
|||||||
var sanitizedSuiteName = String(testName.suffix(testName.count - "test".count).dropLast(2))
|
var sanitizedSuiteName = String(testName.suffix(testName.count - "test".count).dropLast(2))
|
||||||
sanitizedSuiteName = sanitizedSuiteName.prefix(1).lowercased() + sanitizedSuiteName.dropFirst()
|
sanitizedSuiteName = sanitizedSuiteName.prefix(1).lowercased() + sanitizedSuiteName.dropFirst()
|
||||||
|
|
||||||
for deviceName in snapshotDevices {
|
for snapshotDevice in snapshotDevices {
|
||||||
guard var device = PreviewDevice(rawValue: deviceName).snapshotDevice() else {
|
guard var device = PreviewDevice(rawValue: snapshotDevice.device).snapshotDevice() else {
|
||||||
fatalError("Unknown device name: \(deviceName)")
|
fatalError("Unknown device name: \(snapshotDevice.device)")
|
||||||
}
|
}
|
||||||
// Ignore specific device safe area (using the workaround value to fix rendering issues).
|
// Ignore specific device safe area (using the workaround value to fix rendering issues).
|
||||||
device.safeArea = .one
|
device.safeArea = .one
|
||||||
@@ -89,9 +97,9 @@ class PreviewTests: XCTestCase {
|
|||||||
|
|
||||||
var testName = ""
|
var testName = ""
|
||||||
if let displayName = preview.displayName {
|
if let displayName = preview.displayName {
|
||||||
testName = "\(displayName)-\(deviceName)-\(localeCode)"
|
testName = "\(displayName)-\(snapshotDevice.name)-\(localeCode)"
|
||||||
} else {
|
} else {
|
||||||
testName = "\(deviceName)-\(localeCode)-\(step)"
|
testName = "\(snapshotDevice.name)-\(localeCode)-\(step)"
|
||||||
}
|
}
|
||||||
|
|
||||||
let isScreen = switch preview.layout {
|
let isScreen = switch preview.layout {
|
||||||
@@ -167,7 +175,7 @@ private class SnapshotPreferences: @unchecked Sendable {
|
|||||||
private extension PreviewDevice {
|
private extension PreviewDevice {
|
||||||
func snapshotDevice() -> ViewImageConfig? {
|
func snapshotDevice() -> ViewImageConfig? {
|
||||||
switch rawValue {
|
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
|
return .iPhoneX
|
||||||
case "iPhone 6", "iPhone 6s", "iPhone 7", "iPhone 8":
|
case "iPhone 6", "iPhone 6s", "iPhone 7", "iPhone 8":
|
||||||
return .iPhone8
|
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