Skip to content

Commit

Permalink
Pass DerivedData location as a parameter (#6)
Browse files Browse the repository at this point in the history
* Pass DerivedData location as a parameter

* Fix step.yml lint issue

* Use filepath.Join to construct SourcePackages path

* refresh REDAME file and reorder step inputs

---------

Co-authored-by: Krisztián Gödrei <krisztian.godrei@bitrise.io>
  • Loading branch information
esteluk and godrei committed Apr 9, 2024
1 parent 3adaab1 commit ade1350
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ steps:
| Key | Description | Flags | Default |
| --- | --- | --- | --- |
| `verbose` | Enable logging additional information for troubleshooting | required | `false` |
| `derived_data_path` | Path of the project's Derived Data folder. Supports glob patterns. | required | `~/Library/Developer/Xcode/DerivedData/**` |
</details>

<details>
Expand Down
6 changes: 6 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ deps:
- name: zstd

inputs:
- derived_data_path: ~/Library/Developer/Xcode/DerivedData/**
opts:
title: Derived Data Path
summary: Path of the project's Derived Data folder.
description: Path of the project's Derived Data folder. Supports glob patterns.
is_required: true
- verbose: "false"
opts:
title: Verbose logging
Expand Down
12 changes: 6 additions & 6 deletions step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package step

import (
"fmt"
"path/filepath"

"github.com/bitrise-io/go-steputils/v2/cache"
"github.com/bitrise-io/go-steputils/v2/stepconf"
Expand All @@ -18,15 +19,11 @@ const (
// checksum: Package.resolved is the dependency lockfile, either in the project root (pure Swift project)
// or at project.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
key = `{{ .OS }}-{{ .Arch }}-spm-cache-{{ checksum "**/Package.resolved" }}`

// Cached path
// This folder contains the cloned git repos of packages
// The wildcard is for the unique project folder, such as `sample-swiftpm2-czkemcvuprosyehacrtonyiofjkk`
path = "~/Library/Developer/Xcode/DerivedData/**/SourcePackages"
)

type Input struct {
Verbose bool `env:"verbose,required"`
Verbose bool `env:"verbose,required"`
DerivedDataPath string `env:"derived_data_path,required"`
}

type SaveCacheStep struct {
Expand Down Expand Up @@ -62,6 +59,9 @@ func (step SaveCacheStep) Run() error {
return fmt.Errorf("failed to parse inputs: %w", err)
}
stepconf.Print(input)

path := filepath.Join(input.DerivedDataPath, "SourcePackages")

step.logger.Println()
step.logger.Printf("Cache key: %s", key)
step.logger.Printf("Cache paths:")
Expand Down

0 comments on commit ade1350

Please sign in to comment.