Skip to content
Snippets Groups Projects

Native Step Runner Integration for Docker Executor

Merged Axel von Bertoldi requested to merge avonbertoldi/47414/steps-integration-docker into main
1 file
+ 45
1
Compare changes
  • Side-by-side
  • Inline
+ 45
1
@@ -17,6 +17,8 @@ import (
"strings"
"sync/atomic"
"time"
yamlconv "sigs.k8s.io/yaml"
)
const (
@@ -36,6 +38,10 @@ const (
repoSubmoduleLFSBeforeSHA = "1ea27a9695f80d7816d9e8ce025d9b2df83d0dd7"
repoSubmoduleLFSRefName = "add-lfs-submodule"
repoStepsSHA = "1142c6530a1eb81f0a5476db25fbfbf9a4e08f30"
repoStepsBeforeSHA = "1ea27a9695f80d7816d9e8ce025d9b2df83d0dd7"
repoStepsRefName = "add-steps"
FilesLFSFile1LFSsize = int64(2097152)
)
@@ -77,6 +83,17 @@ func GetSubmoduleLFSGitInfo(url string) GitInfo {
}
}
func GetStepsGitInfo(url string) GitInfo {
return GitInfo{
RepoURL: url,
Sha: repoStepsSHA,
BeforeSha: repoStepsBeforeSHA,
Ref: repoStepsRefName,
RefType: repoRefType,
Refspecs: []string{"+refs/heads/*:refs/origin/heads/*", "+refs/tags/*:refs/tags/*"},
}
}
func GetSuccessfulBuild() (JobResponse, error) {
return GetLocalBuildResponse("echo Hello World")
}
@@ -210,7 +227,6 @@ func GetRemoteSuccessfulBuildWithDumpedVariables() (JobResponse, error) {
fmt.Sprintf("[[ \"${%s}\" != \"\" ]]", variableName),
fmt.Sprintf("[[ $(cat $%s) == \"%s\" ]]", variableName, variableValue),
)
if err != nil {
return JobResponse{}, err
}
@@ -343,6 +359,34 @@ func getBuildResponse(repoURL string, commands []string) JobResponse {
}
}
func getStepsBuildResponse(repoURL string, stepsYAML string) JobResponse {
// steps come from GitLab in json, but it's a whole lot more convenient to write them in yaml in tests. Let's
// support the latter and convert the yaml to json here so everything else downstream works as if the steps were
// specified in json.
stepsJSON, err := yamlconv.YAMLToJSON([]byte(stepsYAML))
if err != nil {
panic(err)
}
return JobResponse{
GitInfo: GetStepsGitInfo(repoURL),
Run: string(stepsJSON),
Steps: Steps{
Step{
Name: StepNameRun,
When: StepWhenAlways,
AllowFailure: false,
},
},
RunnerInfo: RunnerInfo{
Timeout: DefaultTimeout,
},
}
}
func GetRemoteStepsBuildResponse(stepsYAML string) (JobResponse, error) {
return getStepsBuildResponse(repoRemoteURL, stepsYAML), nil
}
func GetRemoteBuildResponse(commands ...string) (JobResponse, error) {
return getBuildResponse(repoRemoteURL, commands), nil
}
Loading