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

Remove deprecated SPM cache handling #254

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ Run tests with custom xcconfig file path:
| `log_formatter` | Defines how xcodebuild command's log is formatted. Available options: - `xcbeautify`: The xcodebuild command's output will be beautified by xcbeautify. - `xcodebuild`: Only the last 20 lines of raw xcodebuild output will be visible in the build log. - `xcpretty`: The xcodebuild command's output will be prettified by xcpretty. The raw xcodebuild log will be exported in all cases. | required | `xcbeautify` |
| `xcbeautify_options` | Additional options to be added to the executed xcbeautify command. | | |
| `xcpretty_options` | Additional options to be added to the executed xcpretty command. | | `--color --report html --output "${BITRISE_DEPLOY_DIR}/xcode-test-results-${BITRISE_SCHEME}.html"` |
| `cache_level` | Defines what cache content should be automatically collected. Use key-based caching instead for better performance. Available options: - `none`: Disable collecting cache content. - `swift_packages`: Collect Swift PM packages added to the Xcode project. With key-based caching, you only need the Restore SPM cache and the Save SPM cache Steps to cache your Swift packages. [See devcenter for more information.](https://devcenter.bitrise.io/en/dependencies-and-caching/managing-dependencies-for-ios-apps/managing-dependencies-with-spm.html#caching-swift-packages) | | `none` |
| `verbose_log` | If this input is set, the Step will print additional logs for debugging. | | `no` |
| `collect_simulator_diagnostics` | If this input is set, the simulator verbose logging will be enabled and the simulator diagnostics log will be exported. | | `never` |
| `headless_mode` | In headless mode the simulator is not launched in the foreground. If this input is set, the simulator will not be visible but tests (even the screenshots) will run just like if you run a simulator in foreground. | | `yes` |
Expand Down
22 changes: 0 additions & 22 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ workflows:
- DESTINATION: platform=iOS Simulator,name=Bitrise iOS default,OS=latest
- LOG_FORMATTER: xcbeautify
- EXPECT_TEST_FAILURE: "false"
- CACHE_LEVEL: swift_packages
after_run:
- _run
- _check_outputs
Expand All @@ -27,7 +26,6 @@ workflows:
- DESTINATION: platform=iOS Simulator,name=Bitrise iOS default,OS=latest
- LOG_FORMATTER: xcpretty
- EXPECT_TEST_FAILURE: "false"
- CACHE_LEVEL: none
after_run:
- _run
- _check_outputs
Expand All @@ -45,11 +43,9 @@ workflows:
- DESTINATION: platform=iOS Simulator,name=iPhone 12,OS=latest
- LOG_FORMATTER: xcbeautify
- EXPECT_TEST_FAILURE: "false"
- CACHE_LEVEL: swift_packages
after_run:
- _run
- _check_outputs
- _check_cache

test_xcconfig_rel_path:
envs:
Expand All @@ -61,7 +57,6 @@ workflows:
- DESTINATION: platform=iOS Simulator,name=Bitrise iOS default,OS=latest
- LOG_FORMATTER: xcodebuild
- EXPECT_TEST_FAILURE: "false"
- CACHE_LEVEL: none
- XCCONFIG_CONTENT: ./_tmp2/p.xcconfig
before_run:
- utility_create_xcconfig
Expand Down Expand Up @@ -143,7 +138,6 @@ workflows:
- perform_clean_action: "yes"
- xcodebuild_options: -verbose
- verbose_log: "yes"
- cache_level: $CACHE_LEVEL
- collect_simulator_diagnostics: $COLLECT_SIM_DIAGNOSTICS

_clear_outputs:
Expand Down Expand Up @@ -247,19 +241,3 @@ workflows:
fi

echo "Exported xcpretty html report found: $BITRISE_DEPLOY_DIR/xcode-test-results-ios-simple-objc.html"

_check_cache:
steps:
- script:
inputs:
- content: |-
#!/bin/env bash
set -ex
if [[ -z "$BITRISE_CACHE_EXCLUDE_PATHS" ]] ; then
echo "BITRISE_CACHE_EXCLUDE_PATHS is empty"
exit 1
fi
if [[ -z "$BITRISE_CACHE_INCLUDE_PATHS" ]] ; then
echo "BITRISE_CACHE_INCLUDE_PATHS is empty"
exit 1
fi
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/bitrise-io/go-xcode/v2/destination"
"github.com/bitrise-io/go-xcode/v2/simulator"
"github.com/bitrise-io/go-xcode/v2/xcconfig"
cache "github.com/bitrise-io/go-xcode/v2/xcodecache"
"github.com/bitrise-io/go-xcode/v2/xcodecommand"
"github.com/bitrise-io/go-xcode/v2/xcodeversion"
"github.com/bitrise-steplib/steps-xcode-test/output"
Expand Down Expand Up @@ -88,7 +87,6 @@ func createStep(logger log.Logger, logFormatter string) (step.XcodeTestRunner, e
fileManager := fileutil.NewFileManager()
xcconfigWriter := xcconfig.NewWriter(pathProvider, fileManager, pathChecker, pathModifier)
simulatorManager := simulator.NewManager(logger, commandFactory)
swiftCache := cache.NewSwiftPackageCache()
outputExporter := export.NewExporter(commandFactory)
testAddonExporter := testaddon.NewExporter(testaddon.NewTestAddon(logger))
stepenvRepository := stepenv.NewRepository(envRepository)
Expand Down Expand Up @@ -116,5 +114,5 @@ func createStep(logger log.Logger, logFormatter string) (step.XcodeTestRunner, e

xcodebuilder := xcodebuild.NewXcodebuild(logger, fileManager, xcconfigWriter, xcodeCommandRunner)

return step.NewXcodeTestRunner(logger, commandFactory, xcodebuilder, simulatorManager, swiftCache, exporter, pathModifier, pathProvider, utils), nil
return step.NewXcodeTestRunner(logger, commandFactory, xcodebuilder, simulatorManager, exporter, pathModifier, pathProvider, utils), nil
}
20 changes: 0 additions & 20 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,26 +222,6 @@ inputs:
title: Additional options for the xcpretty command
summary: Additional options to be added to the executed xcpretty command.

# Caching

- cache_level: none
opts:
category: Branch-based (legacy) caching
title: Enable collecting cache content
summary: Defines what cache content should be automatically collected. Use key-based caching instead for better performance.
description: |-
Defines what cache content should be automatically collected. Use key-based caching instead for better performance.

Available options:
- `none`: Disable collecting cache content.
- `swift_packages`: Collect Swift PM packages added to the Xcode project.

With key-based caching, you only need the Restore SPM cache and the Save SPM cache Steps to cache your Swift packages.
[See devcenter for more information.](https://devcenter.bitrise.io/en/dependencies-and-caching/managing-dependencies-for-ios-apps/managing-dependencies-with-spm.html#caching-swift-packages)
value_options:
- none
- swift_packages

# Debugging

- verbose_log: "no"
Expand Down
60 changes: 0 additions & 60 deletions step/mocks/SwiftPackageCache.go

This file was deleted.

22 changes: 2 additions & 20 deletions step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/bitrise-io/go-utils/v2/pathutil"
"github.com/bitrise-io/go-xcode/v2/destination"
"github.com/bitrise-io/go-xcode/v2/simulator"
cache "github.com/bitrise-io/go-xcode/v2/xcodecache"
"github.com/bitrise-io/go-xcode/v2/xcodecommand"
"github.com/bitrise-steplib/steps-xcode-test/output"
"github.com/bitrise-steplib/steps-xcode-test/xcodebuild"
Expand Down Expand Up @@ -47,9 +46,6 @@ type Input struct {
XcprettyOptions string `env:"xcpretty_options"`
XcbeautifyOptions string `env:"xcbeautify_options"`

// Caching
CacheLevel string `env:"cache_level,opt[none,swift_packages]"`

// Debugging
VerboseLog bool `env:"verbose_log,opt[yes,no]"`
CollectSimulatorDiagnostics string `env:"collect_simulator_diagnostics,opt[always,on_failure,never]"`
Expand Down Expand Up @@ -124,20 +120,18 @@ type XcodeTestRunner struct {
commandFactory command.Factory
xcodebuild xcodebuild.Xcodebuild
simulatorManager simulator.Manager
cache cache.SwiftPackageCache
outputExporter output.Exporter
pathModifier pathutil.PathModifier
pathProvider pathutil.PathProvider
utils Utils
}

func NewXcodeTestRunner(logger log.Logger, commandFactory command.Factory, xcodebuild xcodebuild.Xcodebuild, simulatorManager simulator.Manager, cache cache.SwiftPackageCache, outputExporter output.Exporter, pathModifier pathutil.PathModifier, pathProvider pathutil.PathProvider, utils Utils) XcodeTestRunner {
func NewXcodeTestRunner(logger log.Logger, commandFactory command.Factory, xcodebuild xcodebuild.Xcodebuild, simulatorManager simulator.Manager, outputExporter output.Exporter, pathModifier pathutil.PathModifier, pathProvider pathutil.PathProvider, utils Utils) XcodeTestRunner {
return XcodeTestRunner{
logger: logger,
commandFactory: commandFactory,
xcodebuild: xcodebuild,
simulatorManager: simulatorManager,
cache: cache,
outputExporter: outputExporter,
pathModifier: pathModifier,
pathProvider: pathProvider,
Expand Down Expand Up @@ -254,13 +248,6 @@ func (s XcodeTestRunner) Run(cfg Config) (Result, error) {
return result, testErr
}

// Cache swift PM
if cfg.CacheLevel == "swift_packages" {
if err := s.cache.CollectSwiftPackages(cfg.ProjectPath); err != nil {
s.logger.Warnf("Failed to mark swift packages for caching: %s", err)
}
}

s.logger.Println()
s.logger.Infof("Xcode Test command succeeded.")

Expand Down Expand Up @@ -404,12 +391,7 @@ func (s XcodeTestRunner) runTests(cfg Config) (Result, int, error) {
}
xcresultPath := path.Join(tempDir, fmt.Sprintf("Test-%s.xcresult", cfg.Scheme))

swiftPackagesPath, err := s.cache.SwiftPackagesPath(cfg.ProjectPath)
if err != nil {
return result, -1, fmt.Errorf("failed to get Swift Packages path: %w", err)
}

testParams := s.utils.CreateTestParams(cfg, xcresultPath, swiftPackagesPath)
testParams := s.utils.CreateTestParams(cfg, xcresultPath)

testLog, exitCode, testErr := s.xcodebuild.RunTest(testParams)
result.XcresultPath = xcresultPath
Expand Down
11 changes: 1 addition & 10 deletions step/step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type stepMocks struct {
commandFactory *commonMocks.CommandFactory
xcodebuilder *mocks.Xcodebuild
simulatorManager *mocks.SimulatorManager
cache *mocks.SwiftPackageCache
outputExporter *mocks.Exporter
pathModifier *mocks.PathModifier
pathProvider *mocks.PathProvider
Expand All @@ -38,7 +37,6 @@ func Test_GivenStep_WhenRuns_ThenXcodebuildGetsCalled(t *testing.T) {

mocks.xcodebuilder.On("RunTest", mock.Anything).Return("", 0, nil)
mocks.simulatorManager.On("ResetLaunchServices").Return(nil)
mocks.cache.On("SwiftPackagesPath", mock.Anything).Return("", nil)
mocks.pathProvider.On("CreateTempDir", mock.Anything).Return("tmp_dir", nil)

config := Config{
Expand All @@ -55,8 +53,6 @@ func Test_GivenStep_WhenRuns_ThenXcodebuildGetsCalled(t *testing.T) {
LogFormatter: "xcodebuild",
PerformCleanAction: false,

CacheLevel: "",

CollectSimulatorDiagnostics: never,
HeadlessMode: true,
}
Expand Down Expand Up @@ -124,8 +120,6 @@ func Test_GivenLogFormatterIsXcbeautify_WhenParsesConfig_ThenAdditionalOptionsWo
LogFormatterOptions: []string{"--is-ci", "-q"},
PerformCleanAction: false,

CacheLevel: "swift_packages",

CollectSimulatorDiagnostics: never,
HeadlessMode: true,
}
Expand Down Expand Up @@ -206,7 +200,6 @@ func defaultEnvValues() map[string]string {
"should_retry_test_on_fail": "no",
"perform_clean_action": "no",
"log_formatter": "xcpretty",
"cache_level": "swift_packages",
"verbose_log": "no",
"collect_simulator_diagnostics": "never",
"headless_mode": "yes",
Expand Down Expand Up @@ -264,18 +257,16 @@ func createStepAndMocks(t *testing.T) (XcodeTestRunner, stepMocks) {
commandFactory := new(commonMocks.CommandFactory)
xcodebuilder := mocks.NewXcodebuild(t)
simulatorManager := mocks.NewSimulatorManager(t)
cache := mocks.NewSwiftPackageCache(t)
outputExporter := mocks.NewExporter(t)
pathModifier := mocks.NewPathModifier(t)
pathProvider := mocks.NewPathProvider(t)
utils := NewUtils(logger)

step := NewXcodeTestRunner(logger, commandFactory, xcodebuilder, simulatorManager, cache, outputExporter, pathModifier, pathProvider, utils)
step := NewXcodeTestRunner(logger, commandFactory, xcodebuilder, simulatorManager, outputExporter, pathModifier, pathProvider, utils)
mocks := stepMocks{
commandFactory: commandFactory,
xcodebuilder: xcodebuilder,
simulatorManager: simulatorManager,
cache: cache,
outputExporter: outputExporter,
pathModifier: pathModifier,
pathProvider: pathProvider,
Expand Down
8 changes: 2 additions & 6 deletions step/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type Utils interface {
PrintLastLinesOfXcodebuildTestLog(rawXcodebuildOutput string, isRunSuccess bool)
CreateConfig(input Input, projectPath string, sim destination.Device, additionalOptions, additionalLogFormatterOptions []string) Config
CreateTestParams(cfg Config, xcresultPath, swiftPackagesPath string) xcodebuild.TestRunParams
CreateTestParams(cfg Config, xcresultPath string) xcodebuild.TestRunParams
}

type utils struct {
Expand Down Expand Up @@ -72,16 +72,14 @@ func (u utils) CreateConfig(input Input,
LogFormatter: input.LogFormatter,
LogFormatterOptions: additionalLogFormatterOptions,

CacheLevel: input.CacheLevel,

CollectSimulatorDiagnostics: exportCondition(input.CollectSimulatorDiagnostics),
HeadlessMode: input.HeadlessMode,

DeployDir: input.DeployDir,
}
}

func (u utils) CreateTestParams(cfg Config, xcresultPath, swiftPackagesPath string) xcodebuild.TestRunParams {
func (u utils) CreateTestParams(cfg Config, xcresultPath string) xcodebuild.TestRunParams {
testParams := xcodebuild.TestParams{
ProjectPath: cfg.ProjectPath,
Scheme: cfg.Scheme,
Expand All @@ -100,7 +98,5 @@ func (u utils) CreateTestParams(cfg Config, xcresultPath, swiftPackagesPath stri
TestParams: testParams,
LogFormatterOptions: cfg.LogFormatterOptions,
RetryOnTestRunnerError: true,
RetryOnSwiftPackageResolutionError: true,
SwiftPackagesPath: swiftPackagesPath,
}
}
Loading