Skip to content

Commit

Permalink
[ACI-2287] New step input: custom_tar_args (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
imrekel authored Jul 4, 2024
1 parent 6637802 commit 4acf15c
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 31 deletions.
30 changes: 30 additions & 0 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,36 @@ workflows:
- verbose: "true"
- is_key_unique: "true"

test_custom_tar_args:
envs:
- TEST_APP_URL: https://github.com/bitrise-io/Bitrise-React-Native-Sample
- BRANCH: master
before_run:
- _generate_api_token
- _setup
steps:
- change-workdir:
title: Switch working dir to _tmp
inputs:
- path: ./_tmp
- script:
title: Install dependencies
inputs:
- content: |-
set -ex
npm ci
- path::./:
title: Execute step
run_if: "true"
is_skippable: false
inputs:
- key: |
{{ .OS }}-{{ .Arch }}-node-modules-{{ checksum "package-lock.json" }}
- paths: |-
node_modules
- verbose: "true"
- custom_tar_args: --format posix

_setup:
steps:
- script:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bitrise-steplib/bitrise-step-save-cache
go 1.20

require (
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.31
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.33
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.22
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.31 h1:dO+9LYBwizOhS8ruTWk3PkWHfZoyhK0Ci40kv5LSZIw=
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.31/go.mod h1:Wu1/fiQqxr7A7a9aphh/Jxpof6WV+LEO6vGfBQ9T99A=
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.33 h1:BxTsbaY9hwC/3a2y4V8vHlKAu80DAEuv/rvEEAvaq8o=
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.33/go.mod h1:Wu1/fiQqxr7A7a9aphh/Jxpof6WV+LEO6vGfBQ9T99A=
github.com/bitrise-io/go-utils v1.0.13 h1:1QENhTS/JlKH9F7+/nB+TtbTcor6jGrE6cQ4CJWfp5U=
github.com/bitrise-io/go-utils v1.0.13/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.22 h1:/SD9xE4LlX/Ju9YZ+n/yW/uDs7hXMdFlXg4Nxlb7678=
Expand Down
13 changes: 13 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ inputs:
summary: Zstd compression level to control speed / archive size. Set to 1 for fastest option. Valid values are between 1 and 19. Defaults to 3.
is_required: false

- custom_tar_args:
opts:
title: Custom tar arguments
summary: Additional arguments to pass to the tar command when creating the cache archive.
description: |-
Additional arguments to pass to the tar command when creating the cache archive.
The arguments are passed directly to the `tar` command. Use this input to customize the behavior of the tar command when creating the cache archive
(these are appended to the default arguments used by the step).
Example: `--format posix`
is_required: false

- is_key_unique: "false"
opts:
title: Unique cache key
Expand Down
4 changes: 3 additions & 1 deletion step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Input struct {
Paths string `env:"paths,required"`
IsKeyUnique bool `env:"is_key_unique"`
CompressionLevel int `env:"compression_level,range[1..19]"`
CustomTarArgs string `env:"custom_tar_args"`
}

type SaveCacheStep struct {
Expand Down Expand Up @@ -52,13 +53,14 @@ func (step SaveCacheStep) Run() error {

step.logger.EnableDebugLog(input.Verbose)

saver := cache.NewSaver(step.envRepo, step.logger, step.pathProvider, step.pathModifier, step.pathChecker)
saver := cache.NewSaver(step.envRepo, step.logger, step.pathProvider, step.pathModifier, step.pathChecker, nil)
return saver.Save(cache.SaveCacheInput{
StepId: "save-cache",
Verbose: input.Verbose,
Key: input.Key,
Paths: strings.Split(input.Paths, "\n"),
IsKeyUnique: input.IsKeyUnique,
CompressionLevel: input.CompressionLevel,
CustomTarArgs: strings.Fields(input.CustomTarArgs),
})
}

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.

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.

34 changes: 30 additions & 4 deletions vendor/github.com/bitrise-io/go-steputils/v2/cache/restore.go

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

Loading

0 comments on commit 4acf15c

Please sign in to comment.