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

[ECO-5003] Check that the library builds in release configuration #190

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- id: generation-step
run: swift run BuildTool generate-matrices >> $GITHUB_OUTPUT

check-spm:
build-and-test-spm:
name: SPM (Xcode ${{ matrix.tooling.xcodeVersion }})
runs-on: macos-15
needs: generate-matrices
Expand All @@ -94,7 +94,26 @@ jobs:
- run: swift build -Xswiftc -warnings-as-errors
- run: swift test -Xswiftc -warnings-as-errors

check-xcode:
build-release-configuration-spm:
name: SPM, `release` configuration (Xcode ${{ matrix.tooling.xcodeVersion }})
runs-on: macos-15
needs: generate-matrices
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrices.outputs.matrix).withoutPlatform }}

steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.tooling.xcodeVersion }}

# https://forums.swift.org/t/warnings-as-errors-for-libraries-frameworks/58393/2
- run: swift build -Xswiftc -warnings-as-errors --configuration release

build-and-test-xcode:
name: Xcode, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }})
runs-on: macos-15
needs: generate-matrices
Expand All @@ -119,6 +138,26 @@ jobs:
- name: Run tests
run: swift run BuildTool test-library --platform ${{ matrix.platform }}

build-release-configuration-xcode:
name: Xcode, `release` configuration, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }})
runs-on: macos-15
needs: generate-matrices

strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrices.outputs.matrix).withPlatform }}

steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.tooling.xcodeVersion }}

- name: Build library
run: swift run BuildTool build-library --platform ${{ matrix.platform }} --configuration release

check-example-app:
name: Example app, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }})
runs-on: macos-15
Expand Down Expand Up @@ -149,8 +188,10 @@ jobs:
needs:
- lint
- spec-coverage
- check-spm
- check-xcode
- build-and-test-spm
- build-release-configuration-spm
- build-and-test-xcode
- build-release-configuration-xcode
- check-example-app

steps:
Expand Down
18 changes: 18 additions & 0 deletions Sources/BuildTool/BuildTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Table
struct BuildTool: AsyncParsableCommand {
static let configuration = CommandConfiguration(
subcommands: [
BuildLibrary.self,
BuildLibraryForTesting.self,
TestLibrary.self,
BuildExampleApp.self,
Expand All @@ -18,6 +19,23 @@ struct BuildTool: AsyncParsableCommand {
)
}

@available(macOS 14, *)
struct BuildLibrary: AsyncParsableCommand {
static let configuration = CommandConfiguration(
abstract: "Build the AblyChat library"
)

@Option var configuration: Configuration?
@Option var platform: Platform

mutating func run() async throws {
let destinationSpecifier = try await platform.resolve()
let scheme = "AblyChat"

try await XcodeRunner.runXcodebuild(action: "build", configuration: configuration, scheme: scheme, destination: destinationSpecifier)
}
lawrence-forooghian marked this conversation as resolved.
Show resolved Hide resolved
}

@available(macOS 14, *)
struct BuildLibraryForTesting: AsyncParsableCommand {
static let configuration = CommandConfiguration(
Expand Down
12 changes: 12 additions & 0 deletions Sources/BuildTool/Configuration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ArgumentParser

enum Configuration: String, CaseIterable {
case debug
case release
}

extension Configuration: ExpressibleByArgument {
init?(argument: String) {
self.init(rawValue: argument)
}
}
6 changes: 5 additions & 1 deletion Sources/BuildTool/XcodeRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import Foundation

@available(macOS 14, *)
enum XcodeRunner {
static func runXcodebuild(action: String?, scheme: String, destination: DestinationSpecifier) async throws {
static func runXcodebuild(action: String?, configuration: Configuration? = nil, scheme: String, destination: DestinationSpecifier) async throws {
var arguments: [String] = []

if let action {
arguments.append(action)
}

if let configuration {
arguments.append(contentsOf: ["-configuration", configuration.rawValue])
}

arguments.append(contentsOf: ["-scheme", scheme])
arguments.append(contentsOf: ["-destination", destination.xcodebuildArgument])

Expand Down
Loading