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

Add stepman bin cache #950

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

Add stepman bin cache #950

wants to merge 40 commits into from

Conversation

lpusok
Copy link
Contributor

@lpusok lpusok commented Apr 24, 2024

Checklist

Version

Requires a MAJOR/MINOR/PATCH version update

Context

Changes

Investigation details

Decisions

@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from 6ce76c1 to 1eec4f1 Compare April 29, 2024 15:56
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from 3d824fe to 949510f Compare April 29, 2024 16:35
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch 4 times, most recently from 774e28d to 57a8bfe Compare April 29, 2024 19:57
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from 57a8bfe to 1d28f2a Compare April 29, 2024 20:02
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from 961e22f to bec0030 Compare April 30, 2024 01:30
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from bec0030 to 3e2cbcc Compare April 30, 2024 01:44
@@ -334,6 +334,23 @@ func (toolkit GoToolkit) PrepareForStepRun(step stepmanModels.StepModel, sIDData
return goBuildStep(&defaultRunner{}, goConfig, step.Toolkit.Go.PackageName, stepAbsDirPath, fullStepBinPath)
}

func GoBuildStep(stepAbsDirPath string, packageName string, fullStepBinPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I know we probably won't introduce new toolkits, but I still think this method should be part of the toolkit interface. Offline mode is now a CLI-wide concept, so every toolkit should support it

return nil
}

compressCmd := command.New("zstd", "--patch-from="+targetExecutablePathLatest, targetExecutablePath, "-o", patchFilePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not urgent for the prototyping, but we should not forget that this brings a new implicit dependency. I think bitrise setup should at least check that zstd is available in $PATH when the offline mode is enabled.

return checkChecksum(targetExecutablePath, checkSumPath)
}

func writeChecksum(patchFilePath, checksumPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Idea: SHA256 checksums are not that long when converted to ASCII, so we could also append them to the filenames. This could simplify the code in this file (and also make operations atomic)

Copy link
Contributor

Choose a reason for hiding this comment

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

Inspired by the Nix store path format: https://nixos.org/manual/nix/stable/store/store-path

workers = 10
)

type GoBuilder func(stepSourceAbsPath, packageName, targetExecutablePath string) error
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole file is heavily coupled with the Go step toolkit while stepman should be neutral. I would rather expend the step toolkit interface with the required methods and hooks to make this code uncoupled from any single toolkit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like the idea of expanding the toolkit interface.
However we can not use the toolkit interface here directly, as it would result in circular dependency.
Can look into removing the Go specificness.

@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from 8ecef0c to b5dfaf9 Compare April 30, 2024 10:02
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from eecc865 to 0245219 Compare April 30, 2024 10:40
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from 324cab6 to 95f7da7 Compare May 2, 2024 17:19
@lpusok lpusok force-pushed the ACI-2038-add-stepman-bin-cache branch from eeb95a4 to dfde6d2 Compare May 2, 2024 18:14
}

func (toolkit GoToolkit) PrepareForStepRun(step stepmanModels.StepModel, sIDData models.StepIDData, activatedStep stepmanModels.ActivatedStep) (stepmanModels.ActivatedStep, error) {
if activatedStep.Type == stepmanModels.ActivatedStepTypeExecutable {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A seperate case if the step is already precompiled.

ActivatedStepTypeExecutable ActivatedStepType = "executable"
)

type ActivatedStep struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Todo: still not ideal as can be both source and executable at the same time.

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.

None yet

2 participants