Skip to content

Commit

Permalink
Tool 692 opt out cache (#54)
Browse files Browse the repository at this point in the history
* enable_cache input added to opt in/out caching

* vendor update
  • Loading branch information
godrei authored Sep 5, 2019
1 parent 410fc35 commit 34056f1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1 // indirect
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 // indirect
github.com/bitrise-io/stepman v0.0.0-20190813144014-10564a4888a6 // indirect
github.com/bitrise-io/xcode-project v0.0.0-20190829132102-743450f7d0f0
github.com/bitrise-io/xcode-project v0.0.0-20190829132102-743450f7d0f0 // indirect
github.com/bitrise-steplib/bitrise-step-android-unit-test v0.0.0-20190902203028-ff8e682d8645
github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver v0.0.0-20190815132021-09bfb54640c4
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
Expand Down
39 changes: 21 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Config struct {
Lane string `env:"lane,required"`
UpdateFastlane bool `env:"update_fastlane,opt[true,false]"`
VerboseLog bool `env:"verbose_log,opt[yes,no]"`
EnableCache bool `env:"enable_cache,opt[yes,no]"`

GemHome string `env:"GEM_HOME"`
}
Expand Down Expand Up @@ -318,27 +319,29 @@ func main() {
failf("Command failed, error: %s", err)
}

fmt.Println()
log.Infof("Collecting cache")
if config.EnableCache {
fmt.Println()
log.Infof("Collecting cache")

c := cache.New()
for _, depFunc := range depsFuncs {
includes, excludes, err := depFunc(workDir)
log.Debugf("%s found include path:\n%s\nexclude paths:\n%s", functionName(depFunc), strings.Join(includes, "\n"), strings.Join(excludes, "\n"))
if err != nil {
log.Warnf("failed to collect dependencies: %s", err.Error())
continue
}
c := cache.New()
for _, depFunc := range depsFuncs {
includes, excludes, err := depFunc(workDir)
log.Debugf("%s found include path:\n%s\nexclude paths:\n%s", functionName(depFunc), strings.Join(includes, "\n"), strings.Join(excludes, "\n"))
if err != nil {
log.Warnf("failed to collect dependencies: %s", err.Error())
continue
}

for _, item := range includes {
c.IncludePath(item)
}
for _, item := range includes {
c.IncludePath(item)
}

for _, item := range excludes {
c.ExcludePath(item)
for _, item := range excludes {
c.ExcludePath(item)
}
}
if err := c.Commit(); err != nil {
log.Warnf("failed to commit paths to cache: %s", err)
}
}
if err := c.Commit(); err != nil {
log.Warnf("failed to commit paths to cache: %s", err)
}
}
12 changes: 12 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ inputs:
value_options:
- "yes"
- "no"
- enable_cache: "yes"
opts:
title: "Enable collecting files to be included in the build cache"
description: |-
If enabled the step will add the following cache items (if they exist):
- Pods -> Podfile.lock
- Carthage -> Cartfile.resolved
- Android dependencies
value_options:
- "yes"
- "no"
is_required: true

0 comments on commit 34056f1

Please sign in to comment.