Merge pull request #23030 from Luap99/CI-cond

cirrus.yml: implement skips based on source changes
This commit is contained in:
openshift-merge-bot[bot] 2024-06-20 18:16:46 +00:00 committed by GitHub
commit 48e1efbe82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 66 additions and 0 deletions

View File

@ -639,6 +639,17 @@ local_integration_test_task: &local_integration_test_task
alias: local_integration_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_branch_build_docs_machine
# skip when: - it is a PR (we never want to skip on nightly tests); and
# - CI:ALL title is not set; and
# - no danger files are changed; and
# - when no int test code is changed; and
# - NOT (source code is changed AND NOT only test files)
skip: &skip_int_test >-
$CIRRUS_PR != '' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:ALL.*' &&
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
!changesInclude('test/e2e/**', 'test/utils/**') &&
!(changesInclude('**/*.go', '**/*.c') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**'))
depends_on: *build
matrix: *platform_axis
# integration tests scale well with cpu as they are parallelized
@ -680,6 +691,7 @@ container_integration_test_task:
alias: container_integration_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_branch_build_docs_machine
skip: *skip_int_test
depends_on: *build
matrix: &fedora_vm_axis
- env:
@ -708,6 +720,7 @@ rootless_integration_test_task:
alias: rootless_integration_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_branch_build_docs_machine
skip: *skip_int_test
depends_on: *build
matrix: *platform_axis
gce_instance: *fastvm
@ -731,6 +744,15 @@ podman_machine_task:
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*'
) || $CIRRUS_CRON == "main"
# skip when: - it is a PR (we never want to skip on nightly tests); and
# - CI:ALL title is not set; and
# - no danger files are changed; and
# - no machine code files are changed
skip: &skip_machine_test >-
$CIRRUS_PR != '' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:ALL.*' &&
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
!changesInclude('cmd/podman/machine/**', 'pkg/machine/**', '**/*machine*.go')
depends_on: *build
ec2_instance:
image: "${VM_IMAGE_NAME}"
@ -752,6 +774,7 @@ podman_machine_aarch64_task:
name: *std_name_fmt
alias: podman_machine_aarch64
only_if: *machine_cron_not_tag_build_docs
skip: *skip_machine_test
depends_on: *build
ec2_instance:
<<: *standard_build_ec2_aarch64
@ -773,6 +796,7 @@ podman_machine_windows_task:
# Only run for non-docs/copr PRs and non-release branch builds
# and never for tags. Docs: ./contrib/cirrus/CIModes.md
only_if: *machine_cron_not_tag_build_docs
skip: *skip_machine_test
depends_on: *build
ec2_instance:
<<: *windows
@ -797,6 +821,7 @@ podman_machine_mac_task:
name: *std_name_fmt
alias: podman_machine_mac
only_if: *machine_cron_not_tag_build_docs
skip: *skip_machine_test
depends_on: *build
persistent_worker: *mac_pw
env:
@ -849,6 +874,17 @@ local_system_test_task: &local_system_test_task
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:MACHINE.*'
# skip when: - it is a PR (we never want to skip on nightly tests); and
# - CI:ALL title is not set; and
# - no danger files are changed; and
# - no system test code is changed; and
# - NOT (source code is changed AND not only test files)
skip: &skip_system_test >-
$CIRRUS_PR != '' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:ALL.*' &&
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
!changesInclude('test/system/**') &&
!(changesInclude('**/*.go', '**/*.c') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**'))
depends_on: *build
matrix: *platform_axis
gce_instance: *standardvm
@ -866,6 +902,7 @@ local_system_test_aarch64_task: &local_system_test_task_aarch64
# Don't create task for tags, or if using [CI:DOCS], [CI:BUILD]
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_magic
skip: *skip_system_test
depends_on: *build
persistent_worker: *mac_pw
ec2_instance: *standard_build_ec2_aarch64
@ -917,6 +954,7 @@ rootless_system_test_task:
alias: rootless_system_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_magic
skip: *skip_system_test
depends_on: *build
matrix: *platform_axis
gce_instance: *standardvm
@ -968,6 +1006,15 @@ buildah_bud_test_task:
alias: buildah_bud_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_magic
# skip when: - it is a PR (we never want to skip on nightly tests); and
# - CI:ALL title is not set; and
# - no danger files are changed; and
# - no build source files are changed and no bud tests
skip: >-
$CIRRUS_PR != '' &&
$CIRRUS_CHANGE_TITLE !=~ '.*CI:ALL.*' &&
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
!changesInclude('**/*build*.go', 'test/buildah-bud/**')
depends_on: *build
env:
<<: *stdenvars

View File

@ -126,6 +126,10 @@ is removed.
commit-change before Cirrus-CI will notice the draft-status update (i.e.
pressing the re-run button **is not** good enough).
### Intended `[CI:ALL]` behavior:
Run even the tasks that are skipped based on changed sources conditions otherwise.
### Intended Branch tasks (and Cirrus-cron jobs):
+ *build*
+ swagger

View File

@ -60,6 +60,21 @@ class TestDependsOn(TestCaseBase):
msg=('No success aggregation task depends_on "{0}"'.format(task_name))
self.assertIn(task_name, success_deps, msg=msg)
def test_skips(self):
"""2024-06 PR#23030: ugly but necessary duplication in skip conditions. Prevent typos or unwanted changes."""
beginning = "$CIRRUS_PR != '' && $CIRRUS_CHANGE_TITLE !=~ '.*CI:ALL.*' && !changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') && "
real_source_changes = " && !(changesInclude('**/*.go', '**/*.c') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**'))"
for task_name in self.ALL_TASK_NAMES:
task = self.CIRRUS_YAML[task_name + '_task']
if 'skip' in task:
skip = task['skip']
if 'changesInclude' in skip:
msg = ('{0}: invalid skip'.format(task_name))
self.assertEqual(skip[:len(beginning)], beginning, msg=msg+": beginning part is wrong")
if 'changesIncludeOnly' in skip:
self.assertEqual(skip[len(skip)-len(real_source_changes):], real_source_changes, msg=msg+": changesIncludeOnly() part is wrong")
def not_task(self):
"""Ensure no task is named 'task'"""
self.assertNotIn('task', self.ALL_TASK_NAMES)