Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually fail CI when tests fail #313

Merged
merged 14 commits into from
Apr 23, 2024
71 changes: 14 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ concurrency:
cancel-in-progress: true

jobs:
xcode-build-12:
name: Xcode 12 Build
runs-on: macOS-11
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I broke Xcode 12 in addition to Xcode 11 builds in #308. Not ideal, but for the same reason we let #308 through, we're okay letting this change through.

Latest supported Xcode is 14. It'll be 15 on Friday.

xcode-build-13:
name: Xcode 13 Build
runs-on: macOS-12
strategy:
matrix:
platforms: [
'iOS_14',
'tvOS_14',
'watchOS_7',
'iOS_13',
'tvOS_13',
'watchOS_6',
'iOS_15',
'tvOS_15',
]
fail-fast: false
timeout-minutes: 30
Expand All @@ -32,23 +28,21 @@ jobs:
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
run: sudo xcode-select --switch /Applications/Xcode_13.4.1.app/Contents/Developer
- name: Build and Test Framework
run: Scripts/build.swift ${{ matrix.platforms }} xcode
- name: Upload Coverage Reports
if: success()
run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }}
xcode-build-13:
name: Xcode 13 Build
runs-on: macOS-12
xcode-build-14:
name: Xcode 14 Build
runs-on: macOS-14
strategy:
matrix:
platforms: [
'iOS_15',
'tvOS_15',
'watchOS_8',
'iOS_16',
'tvOS_16',
'watchOS_9',
]
fail-fast: false
timeout-minutes: 30
Expand All @@ -58,7 +52,7 @@ jobs:
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_13.4.1.app/Contents/Developer
run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer
- name: Build and Test Framework
run: Scripts/build.swift ${{ matrix.platforms }} xcode
- name: Upload Coverage Reports
Expand All @@ -70,9 +64,6 @@ jobs:
strategy:
matrix:
platforms: [
'iOS_16',
'tvOS_16',
'watchOS_9',
'iOS_17',
'tvOS_17',
'watchOS_10',
Expand Down Expand Up @@ -119,40 +110,6 @@ jobs:
run: brew outdated carthage || brew upgrade carthage
- name: Build Framework
run: carthage build --verbose --no-skip-current --use-xcframeworks
spm-11:
name: SPM Build macOS 11
runs-on: macOS-11
timeout-minutes: 30
strategy:
matrix:
platforms: [
'iOS_14',
'tvOS_14',
'watchOS_7',
'iOS_13',
'tvOS_13',
'watchOS_6',
'macOS_11',
]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer
if: ${{ matrix.platforms == 'iOS_14,tvOS_14,watchOS_7' }}
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer
if: ${{ matrix.platforms == 'iOS_13,tvOS_13,watchOS_6' }}
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer
if: ${{ matrix.platforms == 'macOS_11' }}
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
- name: Build Framework
run: Scripts/build.swift ${{ matrix.platforms }} spm
spm-12:
name: SPM Build macOS 12
runs-on: macOS-12
Expand Down Expand Up @@ -196,7 +153,7 @@ jobs:
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_14.3.app/Contents/Developer
run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
- name: Build Framework
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Valet guarantees that reading and writing operations will succeed as long as wri

## Requirements

* Xcode 12.5 or later.
* Xcode 13.0 or later.
* iOS 9 or later.
* tvOS 9 or later.
* watchOS 2 or later.
Expand Down
103 changes: 18 additions & 85 deletions Scripts/build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,131 +21,75 @@ enum TaskError: Error {
}

enum Platform: String, CustomStringConvertible {
case iOS_13
case iOS_14
case iOS_15
case iOS_16
case iOS_17
case tvOS_13
case tvOS_14
case tvOS_15
case tvOS_16
case tvOS_17
case macOS_11
case macOS_12
case macOS_13
case macOS_14
case watchOS_6
case watchOS_7
case watchOS_8
case watchOS_9
case watchOS_10

var destination: String {
switch self {
case .iOS_13:
return "platform=iOS Simulator,OS=13.7,name=iPad Pro (12.9-inch) (4th generation)"
case .iOS_14:
return "platform=iOS Simulator,OS=14.4,name=iPad Pro (12.9-inch) (4th generation)"
case .iOS_15:
return "platform=iOS Simulator,OS=15.5,name=iPad Pro (12.9-inch) (5th generation)"
case .iOS_16:
return "platform=iOS Simulator,OS=16.4,name=iPad Pro (12.9-inch) (6th generation)"
case .iOS_17:
return "platform=iOS Simulator,OS=17.4,name=iPad Pro (12.9-inch) (6th generation)"

case .tvOS_13:
return "platform=tvOS Simulator,OS=13.4,name=Apple TV"
case .tvOS_14:
return "platform=tvOS Simulator,OS=14.3,name=Apple TV"
case .tvOS_15:
return "platform=tvOS Simulator,OS=15.4,name=Apple TV"
case .tvOS_16:
return "platform=tvOS Simulator,OS=16.4,name=Apple TV"
case .tvOS_17:
return "platform=tvOS Simulator,OS=17.4,name=Apple TV"

case .macOS_11,
.macOS_12,
case .macOS_12,
.macOS_13,
.macOS_14:
return "platform=OS X"

case .watchOS_6:
return "OS=6.2.1,name=Apple Watch Series 4 - 44mm"
case .watchOS_7:
return "OS=7.2,name=Apple Watch Series 6 - 44mm"
case .watchOS_8:
return "OS=8.5,name=Apple Watch Series 6 - 44mm"
case .watchOS_9:
return "OS=9.4,name=Apple Watch Series 6 - 44mm"
return "OS=9.4,name=Apple Watch Series 6 (44mm)"
case .watchOS_10:
return "OS=10.4,name=Apple Watch Series 6 - 44mm"
return "OS=10.4,name=Apple Watch Series 9 (45mm)"
}
}

var sdk: String {
switch self {
case .iOS_13,
.iOS_14,
.iOS_15,
case .iOS_15,
.iOS_16,
.iOS_17:
return "iphonesimulator"

case .tvOS_13,
.tvOS_14,
.tvOS_15,
case .tvOS_15,
.tvOS_16,
.tvOS_17:
return "appletvsimulator"

case .macOS_11:
return "macosx11.1"
case .macOS_12:
return "macosx12.3"
case .macOS_13:
return "macosx13.3"
case .macOS_14:
return "macosx14.0"
return "macosx14.4"

case .watchOS_6,
.watchOS_7,
.watchOS_8,
case .watchOS_8,
.watchOS_9,
.watchOS_10:
return "watchsimulator"
}
}

var shouldTest: Bool {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well this is nice at least! always true!

switch self {
case .iOS_13,
.iOS_14,
.iOS_15,
.iOS_16,
.iOS_17,
.tvOS_13,
.tvOS_14,
.tvOS_15,
.tvOS_16,
.tvOS_17,
.macOS_11,
.macOS_12,
.macOS_13,
.macOS_14,
.watchOS_8,
.watchOS_9,
.watchOS_10:
return true

case .watchOS_6,
.watchOS_7:
// watchOS did not support unit testing prior to Xcode 12.5.
return false
}
}

/// Whether the platform's Xcode version requires modern SPM integration in xcodebuild, given the removal of generate-xcodeproj.
var requiresModernSPMIntegration: Bool {
switch self {
Expand All @@ -163,29 +107,22 @@ enum Platform: String, CustomStringConvertible {

var scheme: String {
switch self {
case .iOS_13,
.iOS_14,
.iOS_15,
case .iOS_15,
.iOS_16,
.iOS_17:
return "Valet iOS"

case .tvOS_13,
.tvOS_14,
.tvOS_15,
case .tvOS_15,
.tvOS_16,
.tvOS_17:
return "Valet tvOS"

case .macOS_11,
.macOS_12,
case .macOS_12,
.macOS_13,
.macOS_14:
return "Valet Mac"

case .watchOS_6,
.watchOS_7,
.watchOS_8,
case .watchOS_8,
.watchOS_9,
.watchOS_10:
return "Valet watchOS"
Expand Down Expand Up @@ -271,27 +208,27 @@ enum Task: String, CustomStringConvertible {
// Our Package isn't set up with unit test targets, because SPM can't run unit tests in a codesigned environment.
return false
case .xcode:
return platform.shouldTest
return true
}
}
}

guard CommandLine.arguments.count > 2 else {
print("Usage: build.swift platforms [spm|xcode]")
exit(0)
throw TaskError.code(1)
Comment on lines -281 to +218
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #300. Reverting so we can catch errors.

}
let rawPlatforms = CommandLine.arguments[1].components(separatedBy: ",")
let rawTask = CommandLine.arguments[2]

guard let task = Task(rawValue: rawTask) else {
print("Received unknown task \(rawTask)")
exit(0)
throw TaskError.code(1)
}

let platforms = rawPlatforms.map { rawPlatform -> Platform in
let platforms = try rawPlatforms.map { rawPlatform -> Platform in
guard let platform = Platform(rawValue: rawPlatform) else {
print("Received unknown platform type \(rawPlatform)")
exit(0)
throw TaskError.code(1)
}

return platform
Expand All @@ -315,7 +252,7 @@ for platform in platforms {
deletedXcodeproj = true
} catch {
print("Could not delete Valet.xcodeproj due to error: \(error)")
exit(0)
throw TaskError.code(1)
}
}

Expand Down Expand Up @@ -349,11 +286,7 @@ for platform in platforms {
xcodeBuildArguments.append("test")
}

do {
try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments)
} catch {
print("xcodebuild failed with error: \(error)")
}
try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments)
Comment on lines -352 to +289
Copy link
Collaborator Author

@dfed dfed Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #300. This was the big bad.


if deletedXcodeproj {
do {
Expand Down
Loading