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

Activate step executable #334

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

ofalvai
Copy link
Contributor

@ofalvai ofalvai commented Aug 27, 2024

bitrise-io/bitrise#998

Initial support for storing pre-built binary URLs in published step.ymls and activating the prebuilt binary for execution.

Example step.yml snippet:

published_at: 2024-09-10T11:56:55.461001254Z

executables:
  darwin-amd64:
    url: https://github.com/bitrise-io/bitrise-steplib-playground/releases/download/0.1.0/null-amd64-darwin
    hash: sha256-b8713cdadcf595d09e1ff4e508bd1fb32f270aae3c62a97094e65d7634b5cbd8
  linux-amd64:
    url: https://github.com/bitrise-io/bitrise-steplib-playground/releases/download/0.1.0/null-amd64-linux
    hash: sha256-9f788b1f2e85f005fb8d318f605729d08e3430cc184317db715ec0da8ad3b046
  darwin-arm64:
    url: https://github.com/bitrise-io/bitrise-steplib-playground/releases/download/0.1.0/null-arm64-darwin
    hash: sha256-e0066ea529c1f11b669f3b4de6cce4f1765cc1ab73dbb06a45293ba18fd589cf
  linux-arm64:
    url: https://github.com/bitrise-io/bitrise-steplib-playground/releases/download/0.1.0/null-arm64-linux
    hash: sha256-9af07cfb8ca63a57bebf5c178c930edfa2cf0596f321fe047829bc4472c99d5b

Out of scope for this PR:

  • local caching and reusing cached binaries instead of downloading again


"github.com/bitrise-io/go-utils/command"
"github.com/bitrise-io/go-utils/pathutil"
"github.com/bitrise-io/stepman/models"
"github.com/bitrise-io/stepman/stepman"
)

var errStepNotAvailableOfflineMode error = fmt.Errorf("step not available in offline mode")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined this error handling into activateStepSource() because offline mode needs to be reworked for step executables anyway (we only cache the step source now, we'll need to cache the executables themselves)

}

if destinationStepYML != "" {
if err := copyStepYML(stepLibURI, id, version, destinationStepYML); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this into both activateStepSource() and activateStepExecutable()

@@ -75,46 +69,6 @@ func queryStep(stepLib models.StepCollectionModel, stepLibURI string, id, versio
return step, version, nil
}

func activateStep(stepLib models.StepCollectionModel, stepLibURI, id, version string, step models.StepModel, log stepman.Logger, isOfflineMode bool) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ activate_source.go

@@ -138,8 +92,14 @@ func copyStepYML(libraryURL, id, version, dest string) error {
func ListCachedStepVersions(log stepman.Logger, stepLib models.StepCollectionModel, stepLibURI, stepID string) []string {
versions := []models.Semver{}

for version, step := range stepLib.Steps[stepID].Versions {
_, err := activateStep(stepLib, stepLibURI, stepID, version, step, log, true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was doing a full step activation just to check the error. I replaced this with a proper stepman call

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it is not a full update, as there is an offline flag set in the last parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, true. The reason I had to replace this is the circular dependency between the activateStep() function that now calls this function.

@ofalvai ofalvai force-pushed the ofalvai/activate-step-executable branch from 210db1e to 3b3418a Compare August 27, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants