Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/cli/internal/action/workflow_run_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func humanizedRunnerType(in v1.CraftingSchema_Runner_RunnerType) string {
*v1.CraftingSchema_Runner_GITLAB_PIPELINE.Enum(): "GitLab",
*v1.CraftingSchema_Runner_AZURE_PIPELINE.Enum(): "Azure Pipeline",
*v1.CraftingSchema_Runner_JENKINS_JOB.Enum(): "Jenkins Job",
*v1.CraftingSchema_Runner_CIRCLECI_BUILD.Enum(): "CircleCI Build",
}

hrt, ok := mapping[in]
Expand Down
4 changes: 4 additions & 0 deletions app/cli/internal/action/workflow_run_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (s *workflowRunListSuite) TestHumanizedRunnerType() {
name: "jenkins runner",
testInput: v1.CraftingSchema_Runner_JENKINS_JOB,
expectedOutput: "Jenkins Job",
}, {
name: "circleci runner",
testInput: v1.CraftingSchema_Runner_CIRCLECI_BUILD,
expectedOutput: "CircleCI Build",
}, {
name: "unknown runner",
testInput: -34,
Expand Down

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

102 changes: 53 additions & 49 deletions app/controlplane/api/workflowcontract/v1/crafting_schema.pb.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ message CraftingSchema {
GITLAB_PIPELINE = 2;
AZURE_PIPELINE = 3;
JENKINS_JOB = 4;
CIRCLECI_BUILD = 5;
}
}

Expand Down
12 changes: 7 additions & 5 deletions internal/attestation/crafter/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ type supportedRunner interface {
func NewRunner(t schemaapi.CraftingSchema_Runner_RunnerType) supportedRunner {
switch t {
case schemaapi.CraftingSchema_Runner_GITHUB_ACTION:
return &runners.GitHubAction{}
return runners.NewGithubAction()
Copy link
Member

Choose a reason for hiding this comment

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

great, thank you for making this change!

case schemaapi.CraftingSchema_Runner_GITLAB_PIPELINE:
return &runners.GitlabPipeline{}
return runners.NewGitlabPipeline()
case schemaapi.CraftingSchema_Runner_AZURE_PIPELINE:
return &runners.AzurePipeline{}
return runners.NewAzurePipeline()
case schemaapi.CraftingSchema_Runner_JENKINS_JOB:
return &runners.JenkinsJob{}
return runners.NewJenkinsJob()
case schemaapi.CraftingSchema_Runner_CIRCLECI_BUILD:
return runners.NewCircleCIBuild()
default:
return &runners.Generic{}
return runners.NewGeneric()
}
}
64 changes: 64 additions & 0 deletions internal/attestation/crafter/runners/circleci_build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Copyright 2023 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package runners

import "os"

type CircleCIBuild struct{}

const CircleCIBuildID = "circleci-build"

func NewCircleCIBuild() *CircleCIBuild {
return &CircleCIBuild{}
}

func (r *CircleCIBuild) CheckEnv() bool {
for _, envVarName := range []string{"CI", "CIRCLECI"} {
if os.Getenv(envVarName) != "true" {
return false
}
}

return true
}

func (r *CircleCIBuild) ListEnvVars() []string {
return []string{
// Some info about the job
"CIRCLE_BUILD_URL",
"CIRCLE_JOB",

// Some info about the commit
"CIRCLE_BRANCH",
"CIRCLE_PR_NUMBER",

// Some info about the agent
"CIRCLE_NODE_TOTAL",
"CIRCLE_NODE_INDEX",
}
}

func (r *CircleCIBuild) ResolveEnvVars() map[string]string {
return resolveEnvVars(r.ListEnvVars())
}

func (r *CircleCIBuild) String() string {
return JenkinsJobID
}

func (r *CircleCIBuild) RunURI() string {
return os.Getenv("CIRCLE_BUILD_URL")
}
Loading