Skip to content

Commit

Permalink
Support arch in destination (#229)
Browse files Browse the repository at this point in the history
If arch key is present in the xcodebuild -destination flag, pass it through.
This allows selecting a Rosetta compatible Simulator runtime (13.7 or 14.5).
  • Loading branch information
lpusok authored Jul 24, 2023
1 parent 6165d7c commit 96bccac
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 26 deletions.
1 change: 1 addition & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ workflows:
inputs:
# Inputs with non-default value or using environment variables
- project_path: ./_tmp/$BITRISE_PROJECT_PATH
- destination: platform=iOS Simulator,name=iPhone 11,OS=latest
- scheme: $BITRISE_SCHEME
- xcodebuild_test_options: -verbose
- export_uitest_artifacts: "true"
Expand Down
61 changes: 58 additions & 3 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ workflows:
- _run
- _check_outputs

test_rosetta_simulator:
description: Rosetta Simulator requires Xcode 14.3+.
steps:
- bitrise-run:
run_if: |-
{{ or (enveq "IS_LATEST_STACK_XCODE" "true") (not .IsCI) }}
inputs:
- workflow_id: utility_test_rosetta_simulator
- bitrise_config_path: ./e2e/bitrise.yml

utility_test_rosetta_simulator:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/Bitrise-iOS-x86-Framework-Sample.git
- TEST_APP_BRANCH: main
- BITRISE_PROJECT_PATH: Bitrise-iOS-x86-Framework-Sample.xcworkspace
- BITRISE_SCHEME: Bitrise-iOS-x86-Framework-Sample
- TEST_PLAN: ""
- DESTINATION: platform=iOS Simulator,name=iPhone 11,OS=latest,arch=x86_64
- LOG_FORMATTER: xcbeautify
- RETRY_ON_FAILURE: "no"
- EXPECT_TEST_FAILURE: "false"
- CACHE_LEVEL: none
- COLLECT_SIM_DIAGNOSTICS: never
after_run:
- _run
- _check_outputs

test_rosetta_simulator_failure:
description: Rosetta Simulator requires Xcode 14.3+.
steps:
- bitrise-run:
run_if: |-
{{ or (enveq "IS_LATEST_STACK_XCODE" "true") (not .IsCI) }}
is_skippable: true
inputs:
- workflow_id: utility_test_rosetta_simulator_failure
- bitrise_config_path: ./e2e/bitrise.yml

utility_test_rosetta_simulator_failure:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/Bitrise-iOS-x86-Framework-Sample.git
- TEST_APP_BRANCH: main
- BITRISE_PROJECT_PATH: Bitrise-iOS-x86-Framework-Sample.xcworkspace
- BITRISE_SCHEME: Bitrise-iOS-x86-Framework-Sample
- TEST_PLAN: ""
- DESTINATION: platform=iOS Simulator,name=iPhone 11,OS=latest
- LOG_FORMATTER: xcbeautify
- RETRY_ON_FAILURE: "no"
- EXPECT_TEST_FAILURE: "true"
- CACHE_LEVEL: none
- COLLECT_SIM_DIAGNOSTICS: never
after_run:
- _run
- _check_outputs

test_objc_xcpretty:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/sample-apps-ios-simple-objc-with-uitest.git
Expand Down Expand Up @@ -107,11 +162,11 @@ workflows:
- content: |-
#!/bin/env bash
set -ex
COLLECT_SIM_DIAGNOSTICS="on_failure"
COLLECT_SIM_DIAGNOSTICS_DEFAULT="on_failure"
if [[ "$EXPECT_TEST_FAILURE" == "true" ]]; then
COLLECT_SIM_DIAGNOSTICS="never"
COLLECT_SIM_DIAGNOSTICS_DEFAULT="never"
fi
envman add --key COLLECT_SIM_DIAGNOSTICS --value $COLLECT_SIM_DIAGNOSTICS
envman add --key COLLECT_SIM_DIAGNOSTICS --value ${COLLECT_SIM_DIAGNOSTICS-$COLLECT_SIM_DIAGNOSTICS_DEFAULT}
- script:
title: Set TEST_REPETITION_MODE to 'none' if not set
inputs:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/bitrise-io/go-utils v1.0.8
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.19
github.com/bitrise-io/go-xcode v1.0.11
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.26
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.27
github.com/hashicorp/go-version v1.6.0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/stretchr/testify v1.8.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.19/go.mod h1:Laih4ji980SQkRgdnMCH
github.com/bitrise-io/go-xcode v1.0.9/go.mod h1:Y0Wu2dXm0MilJ/4D3+gPHaNMlUcP+1DjIPoLPykq7wY=
github.com/bitrise-io/go-xcode v1.0.11 h1:Ac3TDAzL+1+XhBSWCOLnpT+VTzrIuGXjNhUvM0Q9plA=
github.com/bitrise-io/go-xcode v1.0.11/go.mod h1:Y0Wu2dXm0MilJ/4D3+gPHaNMlUcP+1DjIPoLPykq7wY=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.26 h1:4Mh+sdY+XXncLOHDZLyBvKEcTniaWruRzzN/k1QPE5I=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.26/go.mod h1:8WBcRgrVXY8tzR7NcjE4fw6WguOIfB3YcC7ZTcQYUEY=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.27 h1:msDl1IUyxhNvGt1zaI38HEs4Ed74UhBVKkjaU6I2D3g=
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.27/go.mod h1:8WBcRgrVXY8tzR7NcjE4fw6WguOIfB3YcC7ZTcQYUEY=
github.com/bitrise-io/goinp v0.0.0-20210504152833-8559b0680ab1/go.mod h1:iRbd8zAXLeNy+0gic0eqNCxXvDGe8ZEY/uYX2CCeAoo=
github.com/bitrise-io/goinp v0.0.0-20211005113137-305e91b481f4/go.mod h1:iRbd8zAXLeNy+0gic0eqNCxXvDGe8ZEY/uYX2CCeAoo=
github.com/bitrise-io/gows v0.0.0-20211005113107-14f65e686b88/go.mod h1:3Cp9ceJ8wHl1Av6oEE2ff1iWaYLliQuD+oaNdyM0NWQ=
Expand Down
6 changes: 3 additions & 3 deletions step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type Config struct {
Scheme string
TestPlan string

SimulatorID string
Simulator destination.Device
IsSimulatorBooted bool

XcodeMajorVersion int
Expand Down Expand Up @@ -257,7 +257,7 @@ type Result struct {
func (s XcodeTestRunner) Run(cfg Config) (Result, error) {
enableSimulatorVerboseLog := cfg.CollectSimulatorDiagnostics != never
launchSimulator := !cfg.IsSimulatorBooted && !cfg.HeadlessMode
if err := s.prepareSimulator(enableSimulatorVerboseLog, cfg.SimulatorID, launchSimulator); err != nil {
if err := s.prepareSimulator(enableSimulatorVerboseLog, cfg.Simulator.ID, launchSimulator); err != nil {
return Result{}, err
}

Expand All @@ -273,7 +273,7 @@ func (s XcodeTestRunner) Run(cfg Config) (Result, error) {
testExitCode = code
}

result.SimulatorDiagnosticsPath = s.teardownSimulator(cfg.SimulatorID, cfg.CollectSimulatorDiagnostics, cfg.IsSimulatorBooted, testErr)
result.SimulatorDiagnosticsPath = s.teardownSimulator(cfg.Simulator.ID, cfg.CollectSimulatorDiagnostics, cfg.IsSimulatorBooted, testErr)

if testErr != nil {
s.logger.Println()
Expand Down
4 changes: 2 additions & 2 deletions step/step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_GivenStep_WhenRuns_ThenXcodebuildGetsCalled(t *testing.T) {
Scheme: "Project",

XcodeMajorVersion: 13,
SimulatorID: "1234",
Simulator: destination.Device{ID: "1234"},
IsSimulatorBooted: true,

TestRepetitionMode: "none",
Expand Down Expand Up @@ -169,7 +169,7 @@ func Test_GivenLogFormatterIsXcbeautify_WhenParsesConfig_ThenAdditionalOptionsWo
ProjectPath: "/_tmp/BullsEye.xcworkspace",
Scheme: "BullsEye",

SimulatorID: device.ID,
Simulator: device,
IsSimulatorBooted: false,

XcodeMajorVersion: 13,
Expand Down
4 changes: 2 additions & 2 deletions step/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (u utils) CreateConfig(input Input,
Scheme: input.Scheme,
TestPlan: input.TestPlan,

SimulatorID: sim.ID,
Simulator: sim,
IsSimulatorBooted: sim.Status != simulatorShutdownState,

XcodeMajorVersion: xcodeMajorVersion,
Expand Down Expand Up @@ -89,7 +89,7 @@ func (u utils) CreateTestParams(cfg Config, xcresultPath, swiftPackagesPath stri
testParams := xcodebuild.TestParams{
ProjectPath: cfg.ProjectPath,
Scheme: cfg.Scheme,
Destination: fmt.Sprintf("id=%s", cfg.SimulatorID),
Destination: cfg.Simulator.XcodebuildDestination(),
TestPlan: cfg.TestPlan,
TestOutputDir: xcresultPath,
TestRepetitionMode: cfg.TestRepetitionMode,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions vendor/github.com/bitrise-io/go-xcode/v2/destination/parse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ github.com/bitrise-io/go-utils/v2/pathutil
## explicit; go 1.15
github.com/bitrise-io/go-xcode/models
github.com/bitrise-io/go-xcode/utility
# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.26
# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.27
## explicit; go 1.16
github.com/bitrise-io/go-xcode/v2/destination
github.com/bitrise-io/go-xcode/v2/errorfinder
Expand Down
18 changes: 16 additions & 2 deletions xcodebuild/mocks/PathChecker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96bccac

Please sign in to comment.