Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
akiioto authored Jul 4, 2024
2 parents 8008798 + a3a20be commit 1b6e18f
Show file tree
Hide file tree
Showing 117 changed files with 639 additions and 425 deletions.
9 changes: 5 additions & 4 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
baseImageOverrides:
github.com/kyma-project/test-infra/cmd/tools/pjtester: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240703-14228c3e
github.com/kyma-project/test-infra/cmd/markdown-index: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240703-14228c3e
github.com/kyma-project/test-infra/cmd/image-detector: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240703-14228c3e
github.com/kyma-project/test-infra/cmd/image-autobumper: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240703-14228c3e
github.com/kyma-project/test-infra/cmd/tools/pjtester: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240704-8a4fa8a7
github.com/kyma-project/test-infra/cmd/markdown-index: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240704-8a4fa8a7
github.com/kyma-project/test-infra/cmd/image-detector: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240704-8a4fa8a7
github.com/kyma-project/test-infra/cmd/image-autobumper: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240704-8a4fa8a7
github.com/kyma-project/test-infra/cmd/external-plugins/automated-approver: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240703-14228c3e
github.com/kyma-project/test-infra/cmd/external-plugins/automated-approver: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240704-8a4fa8a7
defaultPlatforms:
- linux/arm64
- linux/amd64
17 changes: 16 additions & 1 deletion cmd/image-builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ type GitStateConfig struct {
JobType string
// Number of the pull request for presubmit job
PullRequestNumber int
// Commit SHA for base branch
// Commit SHA for base branch or tag
BaseCommitSHA string
// Base branch or tag
BaseCommitRef string
// Commit SHA for head of the pull request
PullHeadCommitSHA string
// isPullRequest contains information whether event which triggered the job was from pull request
Expand Down Expand Up @@ -255,6 +257,19 @@ func loadGithubActionsGitState() (GitStateConfig, error) {
JobType: "postsubmit",
BaseCommitSHA: *payload.HeadCommit.ID,
}, nil
case "workflow_dispatch":
var payload github.WorkflowDispatchEvent
err = json.Unmarshal(data, &payload)
if err != nil {
return GitStateConfig{}, fmt.Errorf("failed to parse event payload: %s", err)
}
return GitStateConfig{
RepositoryName: *payload.Repo.Name,
RepositoryOwner: *payload.Repo.Owner.Login,
JobType: "on-demand",
BaseCommitSHA: os.Getenv("GITHUB_SHA"),
BaseCommitRef: os.Getenv("GITHUB_REF"),
}, nil
default:
return GitStateConfig{}, fmt.Errorf("GITHUB_EVENT_NAME environment variable is set to unsupported value \"%s\", please set it to supported value", eventName)
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/image-builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,26 @@ func TestLoadGitStateConfig(t *testing.T) {
isPullRequest: false,
},
},
{
name: "Load data from event payload for github workflow_dispatch event",
options: options{
ciSystem: GithubActions,
},
env: map[string]string{
"GITHUB_EVENT_PATH": "./test_fixture/workflow_dispatch.json",
"GITHUB_EVENT_NAME": "workflow_dispatch",
"GITHUB_SHA": "d42f5051757b3e0699eb979d7581404e36fc0eee",
"GITHUB_REF": "refs/heads/main",
},
gitState: GitStateConfig{
RepositoryName: "test-infra",
RepositoryOwner: "KacperMalachowski",
JobType: "on-demand",
BaseCommitSHA: "d42f5051757b3e0699eb979d7581404e36fc0eee",
BaseCommitRef: "refs/heads/main",
isPullRequest: false,
},
},
{
name: "Unknown ci system, return err",
options: options{
Expand Down
6 changes: 6 additions & 0 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ func prepareADOTemplateParameters(options options) (adopipelines.OCIImageBuilder
templateParameters.SetPresubmitJobType()
} else if options.gitState.JobType == "postsubmit" {
templateParameters.SetPostsubmitJobType()
} else if options.gitState.JobType == "on-demand" {
templateParameters.SetOnDemandJobType()
}

if options.gitState.IsPullRequest() {
Expand All @@ -209,6 +211,10 @@ func prepareADOTemplateParameters(options options) (adopipelines.OCIImageBuilder

templateParameters.SetBaseSHA(options.gitState.BaseCommitSHA)

if len(options.gitState.BaseCommitRef) > 0 {
templateParameters.SetBaseRef(options.gitState.BaseCommitRef)
}

if options.gitState.IsPullRequest() {
templateParameters.SetPullSHA(options.gitState.PullHeadCommitSHA)
}
Expand Down
27 changes: 26 additions & 1 deletion cmd/image-builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,13 +650,38 @@ func Test_prepareADOTemplateParameters(t *testing.T) {
"UseKanikoConfigFromPR": "false",
},
},
{
name: "On demand job type with base commit SHA and base commit ref",
options: options{
gitState: GitStateConfig{
JobType: "on-demand",
BaseCommitSHA: "abc123",
BaseCommitRef: "main",
},
tags: sets.Tags{
{Name: "{{ .Env \"GOLANG_VERSION\" }}-ShortSHA", Value: "{{ .Env \"GOLANG_VERSION\" }}-{{ .ShortSHA }}"},
},
},
want: pipelines.OCIImageBuilderTemplateParams{
"Context": "",
"Dockerfile": "",
"ExportTags": "false",
"JobType": "on-demand",
"Name": "",
"PullBaseSHA": "abc123",
"BaseRef": "main",
"RepoName": "",
"RepoOwner": "",
"Tags": "e3sgLkVudiAiR09MQU5HX1ZFUlNJT04iIH19LVNob3J0U0hBPXt7IC5FbnYgIkdPTEFOR19WRVJTSU9OIiB9fS17eyAuU2hvcnRTSEEgfX0=",
"UseKanikoConfigFromPR": "false",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := prepareADOTemplateParameters(tt.options)
if (err != nil) != tt.wantErr {
t.Errorf("prepareADOTemplateParameters() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("prepareADOTemplateParameters() got = %v, want %v", got, tt.want)
Expand Down
131 changes: 131 additions & 0 deletions cmd/image-builder/test_fixture/workflow_dispatch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"inputs": null,
"ref": "refs/heads/main",
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/KacperMalachowski/test-infra/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/KacperMalachowski/test-infra/assignees{/user}",
"blobs_url": "https://api.github.com/repos/KacperMalachowski/test-infra/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/KacperMalachowski/test-infra/branches{/branch}",
"clone_url": "https://github.com/KacperMalachowski/test-infra.git",
"collaborators_url": "https://api.github.com/repos/KacperMalachowski/test-infra/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/KacperMalachowski/test-infra/comments{/number}",
"commits_url": "https://api.github.com/repos/KacperMalachowski/test-infra/commits{/sha}",
"compare_url": "https://api.github.com/repos/KacperMalachowski/test-infra/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/KacperMalachowski/test-infra/contents/{+path}",
"contributors_url": "https://api.github.com/repos/KacperMalachowski/test-infra/contributors",
"created_at": "2022-09-30T09:18:40Z",
"default_branch": "main",
"deployments_url": "https://api.github.com/repos/KacperMalachowski/test-infra/deployments",
"description": "Test infrastructure for the Kyma project.",
"disabled": false,
"downloads_url": "https://api.github.com/repos/KacperMalachowski/test-infra/downloads",
"events_url": "https://api.github.com/repos/KacperMalachowski/test-infra/events",
"fork": true,
"forks": 0,
"forks_count": 0,
"forks_url": "https://api.github.com/repos/KacperMalachowski/test-infra/forks",
"full_name": "KacperMalachowski/test-infra",
"git_commits_url": "https://api.github.com/repos/KacperMalachowski/test-infra/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/KacperMalachowski/test-infra/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/KacperMalachowski/test-infra/git/tags{/sha}",
"git_url": "git://github.com/KacperMalachowski/test-infra.git",
"has_discussions": false,
"has_downloads": true,
"has_issues": false,
"has_pages": false,
"has_projects": true,
"has_wiki": false,
"homepage": "https://status.build.kyma-project.io/",
"hooks_url": "https://api.github.com/repos/KacperMalachowski/test-infra/hooks",
"html_url": "https://github.com/KacperMalachowski/test-infra",
"id": 543520825,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/KacperMalachowski/test-infra/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/KacperMalachowski/test-infra/issues/events{/number}",
"issues_url": "https://api.github.com/repos/KacperMalachowski/test-infra/issues{/number}",
"keys_url": "https://api.github.com/repos/KacperMalachowski/test-infra/keys{/key_id}",
"labels_url": "https://api.github.com/repos/KacperMalachowski/test-infra/labels{/name}",
"language": "Go",
"languages_url": "https://api.github.com/repos/KacperMalachowski/test-infra/languages",
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"node_id": "MDc6TGljZW5zZTI=",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0"
},
"merges_url": "https://api.github.com/repos/KacperMalachowski/test-infra/merges",
"milestones_url": "https://api.github.com/repos/KacperMalachowski/test-infra/milestones{/number}",
"mirror_url": null,
"name": "test-infra",
"node_id": "R_kgDOIGV4OQ",
"notifications_url": "https://api.github.com/repos/KacperMalachowski/test-infra/notifications{?since,all,participating}",
"open_issues": 0,
"open_issues_count": 0,
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/38684517?v=4",
"events_url": "https://api.github.com/users/KacperMalachowski/events{/privacy}",
"followers_url": "https://api.github.com/users/KacperMalachowski/followers",
"following_url": "https://api.github.com/users/KacperMalachowski/following{/other_user}",
"gists_url": "https://api.github.com/users/KacperMalachowski/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/KacperMalachowski",
"id": 38684517,
"login": "KacperMalachowski",
"node_id": "MDQ6VXNlcjM4Njg0NTE3",
"organizations_url": "https://api.github.com/users/KacperMalachowski/orgs",
"received_events_url": "https://api.github.com/users/KacperMalachowski/received_events",
"repos_url": "https://api.github.com/users/KacperMalachowski/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/KacperMalachowski/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/KacperMalachowski/subscriptions",
"type": "User",
"url": "https://api.github.com/users/KacperMalachowski"
},
"private": false,
"pulls_url": "https://api.github.com/repos/KacperMalachowski/test-infra/pulls{/number}",
"pushed_at": "2024-07-01T11:57:56Z",
"releases_url": "https://api.github.com/repos/KacperMalachowski/test-infra/releases{/id}",
"size": 43126,
"ssh_url": "[email protected]:KacperMalachowski/test-infra.git",
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/KacperMalachowski/test-infra/stargazers",
"statuses_url": "https://api.github.com/repos/KacperMalachowski/test-infra/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/KacperMalachowski/test-infra/subscribers",
"subscription_url": "https://api.github.com/repos/KacperMalachowski/test-infra/subscription",
"svn_url": "https://github.com/KacperMalachowski/test-infra",
"tags_url": "https://api.github.com/repos/KacperMalachowski/test-infra/tags",
"teams_url": "https://api.github.com/repos/KacperMalachowski/test-infra/teams",
"topics": [],
"trees_url": "https://api.github.com/repos/KacperMalachowski/test-infra/git/trees{/sha}",
"updated_at": "2024-07-01T11:57:59Z",
"url": "https://api.github.com/repos/KacperMalachowski/test-infra",
"visibility": "public",
"watchers": 0,
"watchers_count": 0,
"web_commit_signoff_required": false
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/38684517?v=4",
"events_url": "https://api.github.com/users/KacperMalachowski/events{/privacy}",
"followers_url": "https://api.github.com/users/KacperMalachowski/followers",
"following_url": "https://api.github.com/users/KacperMalachowski/following{/other_user}",
"gists_url": "https://api.github.com/users/KacperMalachowski/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/KacperMalachowski",
"id": 38684517,
"login": "KacperMalachowski",
"node_id": "MDQ6VXNlcjM4Njg0NTE3",
"organizations_url": "https://api.github.com/users/KacperMalachowski/orgs",
"received_events_url": "https://api.github.com/users/KacperMalachowski/received_events",
"repos_url": "https://api.github.com/users/KacperMalachowski/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/KacperMalachowski/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/KacperMalachowski/subscriptions",
"type": "User",
"url": "https://api.github.com/users/KacperMalachowski"
},
"workflow": ".github/workflows/test.yaml"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
project_id = "sap-kyma-neighbors-dev"
region = "europe-west3"
service_account_keys_rotator_service_name = "service-account-keys-rotator"
service_account_keys_rotator_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/rotate-service-account:v20240703-177f328f" #gitleaks:allow
service_account_keys_rotator_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/rotate-service-account:v20240704-00c0b6cd" #gitleaks:allow
service_account_keys_cleaner_service_name = "service-account-keys-cleaner"
service_account_keys_cleaner_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/service-account-keys-cleaner:v20240703-adc8d13f" #gitleaks:allow
service_account_keys_cleaner_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/service-account-keys-cleaner:v20240704-00c0b6cd" #gitleaks:allow
service_account_key_latest_version_min_age = 24
service_account_keys_cleaner_scheduler_cron_schedule = "0 0 * * 1-5"
4 changes: 2 additions & 2 deletions configs/terraform/environments/prod/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ kyma_project_artifact_registry_collection = {
},
}
service_account_keys_rotator_service_name = "service-account-keys-rotator"
service_account_keys_rotator_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/rotate-service-account:v20240703-177f328f" #gitleaks:allow
service_account_keys_rotator_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/rotate-service-account:v20240704-00c0b6cd" #gitleaks:allow
service_account_keys_cleaner_service_name = "service-account-keys-cleaner"
service_account_keys_cleaner_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/service-account-keys-cleaner:v20240703-adc8d13f" #gitleaks:allow
service_account_keys_cleaner_image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/service-account-keys-cleaner:v20240704-00c0b6cd" #gitleaks:allow
service_account_key_latest_version_min_age = 24
service_account_keys_cleaner_scheduler_cron_schedule = "0 0 * * 1-5"
2 changes: 1 addition & 1 deletion configs/terraform/modules/cors-proxy/cors-proxy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "google_cloud_run_service" "cors_proxy" {
template {
spec {
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/cors-proxy:v20240703-583e75e0"
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/cors-proxy:v20240704-3f2fe2c5"
env {
name = "COMPONENT_NAME"
value = "cors-proxy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ resource "google_cloud_run_service" "github_webhook_gateway" {
spec {
service_account_name = google_service_account.github_webhook_gateway.email
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/github-webhook-gateway:v20240703-583e75e0"
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/github-webhook-gateway:v20240704-3f2fe2c5"
env {
name = "PROJECT_ID"
value = var.gcp_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "google_cloud_run_service" "gcs_bucket_mover" {
spec {
service_account_name = google_service_account.gcs_bucket_mover.email
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/move-gcs-bucket:v20240703-583e75e0"
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/move-gcs-bucket:v20240704-3f2fe2c5"
env {
name = "PROJECT_ID"
value = var.gcp_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "google_cloud_run_service" "github_issue_creator" {
spec {
service_account_name = google_service_account.github_issue_creator.email
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/create-github-issue:v20240703-583e75e0"
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/create-github-issue:v20240704-3f2fe2c5"
env {
name = "PROJECT_ID"
value = var.gcp_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "google_cloud_run_service" "github_issue_finder" {
spec {
service_account_name = google_service_account.github_issue_finder.email
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/search-github-issue:v20240703-583e75e0"
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/search-github-issue:v20240704-3f2fe2c5"
env {
name = "PROJECT_ID"
value = var.gcp_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "google_cloud_run_service" "secrets_leak_log_scanner" {
spec {
service_account_name = google_service_account.secrets_leak_log_scanner.email
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/scan-logs-for-secrets:v20240703-583e75e0" #gitleaks:allow
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/scan-logs-for-secrets:v20240704-3f2fe2c5" #gitleaks:allow
env {
name = "PROJECT_ID"
value = var.gcp_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "google_cloud_run_service" "security_dashboard_token" {
template {
spec {
containers {
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/dashboard-token-proxy:v20240703-583e75e0" #gitleaks:allow ignore gitleaks detection
image = "europe-docker.pkg.dev/kyma-project/prod/test-infra/ko/dashboard-token-proxy:v20240704-3f2fe2c5" #gitleaks:allow ignore gitleaks detection
env {
name = "CLIENT_SECRET"
value_from {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
cloud.google.com/go/firestore v1.15.0
cloud.google.com/go/logging v1.10.0
cloud.google.com/go/pubsub v1.40.0
cloud.google.com/go/storage v1.42.0
cloud.google.com/go/storage v1.43.0
github.com/Masterminds/semver v1.5.0
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/avast/retry-go/v4 v4.6.0
Expand Down
Loading

0 comments on commit 1b6e18f

Please sign in to comment.