From 9a646cb709e4038f19606a7c2dc22553af43c656 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 19 Sep 2024 13:56:12 -0400 Subject: [PATCH] Update CI for latest macOS and Xcode --- .bazelrc | 8 - .bazelversion | 1 - .github/workflows/ci.yml | 45 +---- BUILD.bazel | 71 ------- Bazel/0001-Patch-testonly-swift_library.patch | 20 -- Bazel/BUILD.bazel | 0 Bazel/non_bzlmod_deps.bzl | 28 --- MODULE.bazel | 29 --- Scripts/build.swift | 178 ------------------ 9 files changed, 7 insertions(+), 373 deletions(-) delete mode 100644 .bazelrc delete mode 100644 .bazelversion delete mode 100644 BUILD.bazel delete mode 100644 Bazel/0001-Patch-testonly-swift_library.patch delete mode 100644 Bazel/BUILD.bazel delete mode 100644 Bazel/non_bzlmod_deps.bzl delete mode 100644 MODULE.bazel delete mode 100755 Scripts/build.swift diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index 08658cc..0000000 --- a/.bazelrc +++ /dev/null @@ -1,8 +0,0 @@ -# TODO: remove when using Bazel 7 where bzlmod is on by default -common --enable_bzlmod - -# Use the apple_support macOS toolchains -common --enable_platform_specific_config -common:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain -common:macos --crosstool_top=@local_config_apple_cc//:toolchain -common:macos --host_crosstool_top=@local_config_apple_cc//:toolchain diff --git a/.bazelversion b/.bazelversion deleted file mode 100644 index 19b860c..0000000 --- a/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -6.4.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad589ac..a95fc2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,36 +7,12 @@ on: pull_request: jobs: - xcode-build: - name: Xcode Build - runs-on: macOS-11 - strategy: - matrix: - platform: ['iOS_13'] - fail-fast: false - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - name: Bundle Install - run: bundle install --gemfile=Example/Gemfile - - name: Prepare Simulator Runtimes - run: Scripts/github/prepare-simulators.sh ${{ matrix.platform }} - - name: Pod Install - run: bundle exec --gemfile=Example/Gemfile pod install --project-directory=Example - - name: Build and Test - run: Scripts/build.swift xcode ${{ matrix.platform }} `which xcpretty` - - name: Upload Results - uses: actions/upload-artifact@v2 - if: failure() - with: - name: Test Results - path: .build/derivedData/**/Logs/Test/*.xcresult pod-lint: name: Pod Lint - runs-on: macOS-11 + runs-on: macos-latest steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Bundle Install run: bundle install --gemfile=Example/Gemfile - name: Pod Install @@ -47,10 +23,8 @@ jobs: run: bundle exec --gemfile=Example/Gemfile pod lib lint --verbose --fail-fast --include-podspecs=Stagehand.podspec StagehandTesting.podspec spm: name: SPM Build - runs-on: macOS-11 + runs-on: macos-latest strategy: - matrix: - platform: ['iOS_13'] fail-fast: false steps: - name: Checkout Repo @@ -58,12 +32,7 @@ jobs: - name: Prepare Simulator Runtimes run: Scripts/github/prepare-simulators.sh ${{ matrix.platform }} - name: Build - run: Scripts/build.swift spm ${{ matrix.platform }} - bazel: - name: Bazel - runs-on: macOS-13 - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - name: Build - run: bazel build //... + run: | + swift build \ + --sdk "$(xcode-select -p)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" \ + --triple "arm64-apple-ios13.0" diff --git a/BUILD.bazel b/BUILD.bazel deleted file mode 100644 index 2967554..0000000 --- a/BUILD.bazel +++ /dev/null @@ -1,71 +0,0 @@ -load( - "@rules_apple//apple:ios.bzl", - "ios_framework", - "ios_unit_test", -) -load( - "@build_bazel_rules_swift//swift:swift.bzl", - "swift_library", -) - -swift_library( - name = "Stagehand.lib", - srcs = glob(["Sources/Stagehand/**/*.swift"]), - module_name = "Stagehand", - tags = ["manual"], - visibility = ["//visibility:public"], - deps = [], -) - -swift_library( - name = "StagehandTestingCore.lib", - testonly = True, - srcs = glob(["Sources/StagehandTesting/Core/**/*.swift"]), - defines = ["BAZEL_PACKAGE"], - module_name = "StagehandTestingCore", - tags = ["manual"], - visibility = ["//visibility:public"], - deps = [":Stagehand.lib"], -) - -swift_library( - name = "StagehandTesting_iOSSnapshotTestCase.lib", - testonly = True, - srcs = glob(["Sources/StagehandTesting/iOSSnapshotTestCase/**/*.swift"]), - defines = ["BAZEL_PACKAGE"], - module_name = "StagehandTesting_iOSSnapshotTestCase", - tags = ["manual"], - visibility = ["//visibility:public"], - deps = [ - ":Stagehand.lib", - ":StagehandTestingCore.lib", - "@ios_snapshot_test_case//:iOSSnapshotTestCase", - ], -) - -ios_framework( - name = "Stagehand", - bundle_id = "com.squareup.Stagehand", - families = [ - "iphone", - "ipad", - ], - infoplists = ["Sources/Info.plist"], - minimum_os_version = "12.0", - visibility = ["//visibility:public"], - deps = [":Stagehand.lib"], -) - -ios_framework( - name = "StagehandTesting_iOSSnapshotTestCase", - testonly = True, - bundle_id = "com.squareup.StagehandTesting", - families = [ - "iphone", - "ipad", - ], - infoplists = ["Sources/Info.plist"], - minimum_os_version = "12.0", - visibility = ["//visibility:public"], - deps = [":StagehandTesting_iOSSnapshotTestCase.lib"], -) diff --git a/Bazel/0001-Patch-testonly-swift_library.patch b/Bazel/0001-Patch-testonly-swift_library.patch deleted file mode 100644 index da7fae2..0000000 --- a/Bazel/0001-Patch-testonly-swift_library.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Luis Padron -Date: Fri, 19 Jan 2024 15:17:39 -0500 -Subject: Patch testonly swift_library - - -diff --git a/BUILD.bazel b/BUILD.bazel -index 0ae5406..42e81b5 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -25,5 +25,6 @@ swift_library( - deps = [ - ":iOSSnapshotTestCaseCore" - ], -+ testonly = True, - visibility = ["//visibility:public"] - ) --- -2.42.1 - diff --git a/Bazel/BUILD.bazel b/Bazel/BUILD.bazel deleted file mode 100644 index e69de29..0000000 diff --git a/Bazel/non_bzlmod_deps.bzl b/Bazel/non_bzlmod_deps.bzl deleted file mode 100644 index cde5b2b..0000000 --- a/Bazel/non_bzlmod_deps.bzl +++ /dev/null @@ -1,28 +0,0 @@ -"""Defines extensions and macros for MODULE.bazel""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# -- Non-bzlmod versions - -IOS_SNAPSHOT_TEST_CASE_VERSION = "57b023c8bb3df361e2fae01532cd066ec0b65d2e" - -# -- Module extension - -def non_bzlmod_repositories(): - """Defines external dependencies which do not support bzlmod""" - - http_archive( - name = "ios_snapshot_test_case", - url = "https://github.com/uber/ios-snapshot-test-case/archive/%s.zip" % IOS_SNAPSHOT_TEST_CASE_VERSION, - strip_prefix = "ios-snapshot-test-case-%s" % IOS_SNAPSHOT_TEST_CASE_VERSION, - sha256 = "fae7ec6bfdc35bb026a2e898295c16240eeb001bed188972ddcc0d7dc388cda3", - patches = ["//Bazel:0001-Patch-testonly-swift_library.patch"], - patch_args = ["-p1"], - ) - -def _non_bzlmod_deps_impl(_): - non_bzlmod_repositories() - -non_bzlmod_deps = module_extension( - implementation = _non_bzlmod_deps_impl, -) diff --git a/MODULE.bazel b/MODULE.bazel deleted file mode 100644 index 9035335..0000000 --- a/MODULE.bazel +++ /dev/null @@ -1,29 +0,0 @@ -module( - name = "stagehand", - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep( - name = "apple_support", - version = "1.11.1", -) -bazel_dep( - name = "rules_apple", - version = "3.1.1", -) -bazel_dep( - name = "rules_swift", - version = "1.14.0", - repo_name = "build_bazel_rules_swift", -) - -# Load non-bzlmod dependencies -non_bzlmod_deps = use_extension("//Bazel:non_bzlmod_deps.bzl", "non_bzlmod_deps") -use_repo( - non_bzlmod_deps, - "ios_snapshot_test_case", -) - -apple_cc_configure = use_extension("@apple_support//crosstool:setup.bzl", "apple_cc_configure_extension") -use_repo(apple_cc_configure, "local_config_apple_cc") diff --git a/Scripts/build.swift b/Scripts/build.swift deleted file mode 100755 index 6d3e767..0000000 --- a/Scripts/build.swift +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env swift - -import Foundation - -// Usage: build.swift [] - -func execute(commandPath: String, arguments: [String], pipedTo pipeProcess: Process? = nil) throws { - let task = Process() - task.launchPath = commandPath - task.arguments = arguments - - let argumentsString = arguments - .map { argument in - if argument.contains(" ") { - return "\"\(argument)\"" - } else { - return argument - } - } - .joined(separator: " ") - - if let pipeProcess = pipeProcess, let pipePath = pipeProcess.launchPath { - let pipe = Pipe() - task.standardOutput = pipe - pipeProcess.standardInput = pipe - - print("Launching command: \(commandPath) \(argumentsString) | \(pipePath)") - - } else { - print("Launching command: \(commandPath) \(argumentsString)") - } - - task.launch() - - pipeProcess?.launch() - - task.waitUntilExit() - - guard task.terminationStatus == 0 else { - throw TaskError.code(task.terminationStatus) - } -} - -enum TaskError: Error { - case code(Int32) -} - -enum Platform: String, CustomStringConvertible { - case iOS_13 - - var destination: String { - switch self { - case .iOS_13: - return "platform=iOS Simulator,OS=13.7,name=iPhone 11 Pro" - } - } - - var derivedDataPath: String { - return ".build/derivedData/\(rawValue)" - } - - var description: String { - return rawValue - } -} - -enum Task: String, CustomStringConvertible { - case spm - case xcode - - var workspace: String? { - switch self { - case .xcode: - return "Example/Stagehand.xcworkspace" - case .spm: - return nil - } - } - - var project: String? { - switch self { - case .spm: - return "generated/Stagehand.xcodeproj" - case .xcode: - return nil - } - } - - var scheme: String { - switch self { - case .xcode: - return "Stagehand Demo App" - case .spm: - return "Stagehand-Package" - } - } - - var shouldGenerateXcodeProject: Bool { - switch self { - case .spm: - return true - case .xcode: - return false - } - } - - var shouldRunTests: Bool { - switch self { - case .spm: - return false - case .xcode: - return true - } - } - - var description: String { - return rawValue - } -} - -guard CommandLine.arguments.count > 2 else { - print("Usage: build.swift [spm|xcode] ") - throw TaskError.code(1) -} - -let rawTask = CommandLine.arguments[1] -let rawPlatform = CommandLine.arguments[2] - -guard let task = Task(rawValue: rawTask) else { - print("Received unknown task \"\(rawTask)\"") - throw TaskError.code(1) -} - -if task.shouldGenerateXcodeProject { - try execute(commandPath: "/usr/bin/swift", arguments: ["package", "generate-xcodeproj", "--output=generated/"]) -} - -guard let platform = Platform(rawValue: rawPlatform) else { - print("Received unknown platform \"\(rawPlatform)\"") - throw TaskError.code(1) -} - -var xcodeBuildArguments: [String] = [] - -if let workspace = task.workspace { - xcodeBuildArguments.append("-workspace") - xcodeBuildArguments.append(workspace) -} else if let project = task.project { - xcodeBuildArguments.append("-project") - xcodeBuildArguments.append(project) -} - -xcodeBuildArguments.append( - contentsOf: [ - "-scheme", task.scheme, - "-sdk", "iphonesimulator", - "-PBXBuildsContinueAfterErrors=0", - "-destination", platform.destination, - "-derivedDataPath", platform.derivedDataPath, - "ONLY_ACTIVE_ARCH=NO", - ] -) - -xcodeBuildArguments.append("build") - -if task.shouldRunTests { - xcodeBuildArguments.append("test") -} - -let xcpretty: Process? -if CommandLine.arguments.count > 3 { - xcpretty = .init() - xcpretty?.launchPath = CommandLine.arguments[3] -} else { - xcpretty = nil -} - -try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments, pipedTo: xcpretty)