Skip to content

Commit dc01058

Browse files
Merge pull request #5009 from Prucek/run-if-changed
feat(prowgen): propagate run_if_changed/skip_if_only_changed for images jobs
2 parents 258547f + 361fb15 commit dc01058

137 files changed

Lines changed: 2144 additions & 884 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/ci-operator-config-mirror/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func ciOperatorConfigsCallback(o options, configsByRepo configsByRepo) func(rbc
261261
repoInfo.Org = o.toOrg
262262
rbc.Metadata.Org = o.toOrg
263263

264-
if len(rbc.Tests) > 0 || len(rbc.Images) > 0 {
264+
if len(rbc.Tests) > 0 || len(rbc.Images.Items) > 0 {
265265
configsByRepo[repoInfo.Repo] = append(configsByRepo[repoInfo.Repo], config.DataWithInfo{
266266
Configuration: *rbc,
267267
Info: *repoInfo,

cmd/ci-operator-prowgen/main_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ build_root:
3838
namespace: openshift
3939
tag: golang-1.10
4040
images:
41-
- from: base
42-
to: service-serving-cert-signer
41+
items:
42+
- from: base
43+
to: service-serving-cert-signer
4344
resources:
4445
'*':
4546
limits:
@@ -77,8 +78,9 @@ build_root:
7778
namespace: openshift
7879
tag: golang-1.10
7980
images:
80-
- from: base
81-
to: service-serving-cert-signer
81+
items:
82+
- from: base
83+
to: service-serving-cert-signer
8284
resources:
8385
'*':
8486
limits:
@@ -133,8 +135,9 @@ tests:
133135
namespace: openshift
134136
tag: base
135137
images:
136-
- from: base
137-
to: service-serving-cert-signer
138+
items:
139+
- from: base
140+
to: service-serving-cert-signer
138141
resources:
139142
'*':
140143
limits:
@@ -193,8 +196,9 @@ tests:
193196
namespace: openshift
194197
tag: base
195198
images:
196-
- from: base
197-
to: service-serving-cert-signer
199+
items:
200+
- from: base
201+
to: service-serving-cert-signer
198202
resources:
199203
'*':
200204
limits:

cmd/ci-operator/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ func (o *options) Run() (errs []error) {
11791179
// determineSkippedImages determines which images can be skipped when
11801180
// build_images_if_affected is enabled and the [images] target is requested.
11811181
func determineSkippedImages(config *api.ReleaseBuildConfiguration, jobSpec *api.JobSpec, targets []string) sets.Set[string] {
1182-
if config == nil || jobSpec == nil || !config.BuildImagesIfAffected {
1182+
if config == nil || jobSpec == nil || !config.Images.BuildIfAffected {
11831183
return nil
11841184
}
11851185

@@ -1195,7 +1195,7 @@ func determineSkippedImages(config *api.ReleaseBuildConfiguration, jobSpec *api.
11951195
}
11961196

11971197
skipped := sets.New[string]()
1198-
for _, img := range config.Images {
1198+
for _, img := range config.Images.Items {
11991199
if !affectedTools.Has(string(img.To)) {
12001200
skipped.Insert(string(img.To))
12011201
}

cmd/ci-operator/main_test.go

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -448,66 +448,67 @@ base_images:
448448
binary_build_commands: make build WHAT='cmd/hypershift vendor/k8s.io/kubernetes/cmd/hyperkube'
449449
canonical_go_repository: github.com/openshift/origin
450450
images:
451-
- dockerfile_path: images/template-service-broker/Dockerfile.rhel
452-
from: base
453-
to: template-service-broker
454-
inputs:
455-
bin:
456-
as:
457-
- builder
458-
- dockerfile_path: images/cli/Dockerfile.rhel
459-
from: base
460-
to: cli
461-
inputs:
462-
bin:
463-
as:
464-
- builder
465-
- dockerfile_path: images/hypershift/Dockerfile.rhel
466-
from: base
467-
to: hypershift
468-
inputs:
469-
bin:
470-
as:
471-
- builder
472-
- dockerfile_path: images/hyperkube/Dockerfile.rhel
473-
from: base
474-
to: hyperkube
475-
inputs:
476-
bin:
477-
as:
478-
- builder
479-
- dockerfile_path: images/tests/Dockerfile.rhel
480-
from: cli
481-
to: tests
482-
inputs:
483-
bin:
484-
as:
485-
- builder
486-
- context_dir: images/deployer/
487-
dockerfile_path: Dockerfile.rhel
488-
from: cli
489-
to: deployer
490-
- context_dir: images/recycler/
491-
dockerfile_path: Dockerfile.rhel
492-
from: cli
493-
to: recycler
494-
- dockerfile_path: images/sdn/Dockerfile.rhel
495-
from: base
496-
to: node # TODO: SDN
497-
inputs:
498-
bin:
499-
as:
500-
- builder
501-
- context_dir: images/os/
502-
from: base
503-
inputs:
504-
base-machine-with-rpms:
505-
as:
506-
- builder
507-
machine-os-content-base:
508-
as:
509-
- registry.svc.ci.openshift.org/openshift/origin-v4.0:machine-os-content
510-
to: machine-os-content
451+
items:
452+
- dockerfile_path: images/template-service-broker/Dockerfile.rhel
453+
from: base
454+
to: template-service-broker
455+
inputs:
456+
bin:
457+
as:
458+
- builder
459+
- dockerfile_path: images/cli/Dockerfile.rhel
460+
from: base
461+
to: cli
462+
inputs:
463+
bin:
464+
as:
465+
- builder
466+
- dockerfile_path: images/hypershift/Dockerfile.rhel
467+
from: base
468+
to: hypershift
469+
inputs:
470+
bin:
471+
as:
472+
- builder
473+
- dockerfile_path: images/hyperkube/Dockerfile.rhel
474+
from: base
475+
to: hyperkube
476+
inputs:
477+
bin:
478+
as:
479+
- builder
480+
- dockerfile_path: images/tests/Dockerfile.rhel
481+
from: cli
482+
to: tests
483+
inputs:
484+
bin:
485+
as:
486+
- builder
487+
- context_dir: images/deployer/
488+
dockerfile_path: Dockerfile.rhel
489+
from: cli
490+
to: deployer
491+
- context_dir: images/recycler/
492+
dockerfile_path: Dockerfile.rhel
493+
from: cli
494+
to: recycler
495+
- dockerfile_path: images/sdn/Dockerfile.rhel
496+
from: base
497+
to: node # TODO: SDN
498+
inputs:
499+
bin:
500+
as:
501+
- builder
502+
- context_dir: images/os/
503+
from: base
504+
inputs:
505+
base-machine-with-rpms:
506+
as:
507+
- builder
508+
machine-os-content-base:
509+
as:
510+
- registry.svc.ci.openshift.org/openshift/origin-v4.0:machine-os-content
511+
to: machine-os-content
511512
raw_steps:
512513
- pipeline_image_cache_step:
513514
commands: mkdir -p _output/local/releases; touch _output/local/releases/CHECKSUM;
@@ -661,7 +662,7 @@ var parsedConfig = &api.ReleaseBuildConfiguration{
661662
RpmBuildCommands: "make build-rpms",
662663
RpmBuildLocation: "",
663664
CanonicalGoRepository: pointer.StringPtr("github.com/openshift/origin"),
664-
Images: []api.ProjectDirectoryImageBuildStepConfiguration{{
665+
Images: api.ImageConfiguration{Items: []api.ProjectDirectoryImageBuildStepConfiguration{{
665666
From: "base",
666667
To: "template-service-broker",
667668
ProjectDirectoryImageBuildInputs: api.ProjectDirectoryImageBuildInputs{
@@ -727,7 +728,7 @@ var parsedConfig = &api.ReleaseBuildConfiguration{
727728
"machine-os-content-base": {As: []string{"registry.svc.ci.openshift.org/openshift/origin-v4.0:machine-os-content"}},
728729
},
729730
},
730-
}},
731+
}}},
731732
RawSteps: []api.StepConfiguration{{
732733
PipelineImageCacheStepConfiguration: &api.PipelineImageCacheStepConfiguration{
733734
From: "bin",

cmd/private-org-peribolos-sync/testdata/ci-operator/config/org1/repo1/org1-repo1-main.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ build_root:
44
namespace: openshift
55
tag: golang-1.21
66
images:
7-
- dockerfile_path: Dockerfile
8-
from: base
9-
to: test-image
7+
items:
8+
- dockerfile_path: Dockerfile
9+
from: base
10+
to: test-image
1011
promotion:
1112
to:
1213
- name: "4.17"

cmd/private-org-peribolos-sync/testdata/ci-operator/config/org1/repo2/org1-repo2-main.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ build_root:
44
namespace: openshift
55
tag: golang-1.21
66
images:
7-
- dockerfile_path: Dockerfile
8-
from: base
9-
to: non-official-image
7+
items:
8+
- dockerfile_path: Dockerfile
9+
from: base
10+
to: non-official-image
1011
promotion:
1112
to:
1213
- name: "latest"

cmd/private-org-peribolos-sync/testdata/ci-operator/config/org2/repo3/org2-repo3-main.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ build_root:
44
namespace: openshift
55
tag: golang-1.21
66
images:
7-
- dockerfile_path: Dockerfile
8-
from: base
9-
to: whitelisted-image
7+
items:
8+
- dockerfile_path: Dockerfile
9+
from: base
10+
to: whitelisted-image
1011
promotion:
1112
to:
1213
- name: "latest"

cmd/registry-replacer/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func replacer(
258258
return nil
259259
}
260260

261-
if len(config.Images) == 0 {
261+
if len(config.Images.Items) == 0 {
262262
return nil
263263
}
264264

@@ -286,7 +286,7 @@ func replacer(
286286
// that we do not have the appropriate permissions.
287287
var hasNonEmptyDockerfile bool
288288

289-
for idx, image := range config.Images {
289+
for idx, image := range config.Images.Items {
290290
var dockerfile []byte
291291
if image.DockerfileLiteral != nil {
292292
dockerfile = []byte(*image.DockerfileLiteral)
@@ -310,7 +310,7 @@ func replacer(
310310
return fmt.Errorf("failed to apply replacements to Dockerfile in %s/%s@%s: %w", info.Org, info.Repo, info.Branch, err)
311311
}
312312

313-
foundTags, err := ensureReplacement(&config.Images[idx], dockerfile)
313+
foundTags, err := ensureReplacement(&config.Images.Items[idx], dockerfile)
314314
if err != nil {
315315
return fmt.Errorf("failed to ensure replacements in %s/%s@%s: %w", info.Org, info.Repo, info.Branch, err)
316316
}
@@ -598,7 +598,7 @@ func pruneReplacements(config *api.ReleaseBuildConfiguration, filter asDirective
598598
var prunedImages []api.ProjectDirectoryImageBuildStepConfiguration
599599
var errs []error
600600

601-
for _, image := range config.Images {
601+
for _, image := range config.Images.Items {
602602
for k, sourceImage := range image.Inputs {
603603
var newAs []string
604604
for _, sourceImage := range sourceImage.As {
@@ -624,7 +624,7 @@ func pruneReplacements(config *api.ReleaseBuildConfiguration, filter asDirective
624624
}
625625
}
626626

627-
config.Images = prunedImages
627+
config.Images.Items = prunedImages
628628

629629
return utilerrors.NewAggregate(errs)
630630
}
@@ -667,7 +667,7 @@ func pruneUnusedBaseImages(config *api.ReleaseBuildConfiguration, resolvedConfig
667667
getTestStepImages(resolvedConfig, &usedBaseImages, &test)
668668
}
669669

670-
for _, image := range resolvedConfig.Images {
670+
for _, image := range resolvedConfig.Images.Items {
671671
usedBaseImages.Insert(string(image.From))
672672
for input := range image.Inputs {
673673
usedBaseImages.Insert(input)
@@ -818,7 +818,7 @@ func updateDockerfilesToMatchOCPBuildData(
818818
return
819819
}
820820

821-
for idx, image := range config.Images {
821+
for idx, image := range config.Images.Items {
822822
promotionTarget, ok := promotedTags[string(image.To)]
823823
if !ok {
824824
continue
@@ -830,10 +830,10 @@ func updateDockerfilesToMatchOCPBuildData(
830830
continue
831831
}
832832
if image.ContextDir != dockerfilePath.contextDir {
833-
config.Images[idx].ContextDir = dockerfilePath.contextDir
833+
config.Images.Items[idx].ContextDir = dockerfilePath.contextDir
834834
}
835835
if image.DockerfilePath != dockerfilePath.dockerfile {
836-
config.Images[idx].DockerfilePath = dockerfilePath.dockerfile
836+
config.Images.Items[idx].DockerfilePath = dockerfilePath.dockerfile
837837
}
838838
}
839839
}

0 commit comments

Comments
 (0)