mirror of https://github.com/containers/podman.git
cirrus.yml: implement skips based on source changes
We do not have to test everything for each PR, we can know based on the source if we changed (i.e. machine code) and only run the tests then. This implements it as skip conditions, due to the nature of yaml files we unfortunately cannot deduplicate everything, i.e. the is PR check and danger files apply to everything but as skip is only a single yaml string we cannot deduplicate parts of that string. If anyone knows a way to achieve this I like to hear it. For now I implemented this for int, system, bud and machine tests. Once we are more comfortable with this I plan on adding it to other tests as well. This will replace the current _bail_if_test_can_be_skipped logic as it covers more, marks tasks actually skipped in the github UI and works even for the windows/macos machine tests. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
a2bf49abb8
commit
d9183f0587
39
.cirrus.yml
39
.cirrus.yml
|
@ -639,6 +639,15 @@ local_integration_test_task: &local_integration_test_task
|
||||||
alias: local_integration_test
|
alias: local_integration_test
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
# Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *not_tag_branch_build_docs_machine
|
only_if: *not_tag_branch_build_docs_machine
|
||||||
|
# skip when: - it is a PR (we never want to skip on nightly tests); 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 != '' &&
|
||||||
|
!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
|
depends_on: *build
|
||||||
matrix: *platform_axis
|
matrix: *platform_axis
|
||||||
# integration tests scale well with cpu as they are parallelized
|
# integration tests scale well with cpu as they are parallelized
|
||||||
|
@ -680,6 +689,7 @@ container_integration_test_task:
|
||||||
alias: container_integration_test
|
alias: container_integration_test
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
# Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *not_tag_branch_build_docs_machine
|
only_if: *not_tag_branch_build_docs_machine
|
||||||
|
skip: *skip_int_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
matrix: &fedora_vm_axis
|
matrix: &fedora_vm_axis
|
||||||
- env:
|
- env:
|
||||||
|
@ -708,6 +718,7 @@ rootless_integration_test_task:
|
||||||
alias: rootless_integration_test
|
alias: rootless_integration_test
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
# Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *not_tag_branch_build_docs_machine
|
only_if: *not_tag_branch_build_docs_machine
|
||||||
|
skip: *skip_int_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
matrix: *platform_axis
|
matrix: *platform_axis
|
||||||
gce_instance: *fastvm
|
gce_instance: *fastvm
|
||||||
|
@ -731,6 +742,13 @@ podman_machine_task:
|
||||||
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
|
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
|
||||||
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*'
|
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*'
|
||||||
) || $CIRRUS_CRON == "main"
|
) || $CIRRUS_CRON == "main"
|
||||||
|
# skip when: - it is a PR (we never want to skip on nightly tests); and
|
||||||
|
# - no danger files are changed; and
|
||||||
|
# - no machine code files are changed
|
||||||
|
skip: &skip_machine_test >-
|
||||||
|
$CIRRUS_PR != '' &&
|
||||||
|
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
|
||||||
|
!changesInclude('cmd/podman/machine/**', 'pkg/machine/**', '**/*machine*.go')
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
ec2_instance:
|
ec2_instance:
|
||||||
image: "${VM_IMAGE_NAME}"
|
image: "${VM_IMAGE_NAME}"
|
||||||
|
@ -752,6 +770,7 @@ podman_machine_aarch64_task:
|
||||||
name: *std_name_fmt
|
name: *std_name_fmt
|
||||||
alias: podman_machine_aarch64
|
alias: podman_machine_aarch64
|
||||||
only_if: *machine_cron_not_tag_build_docs
|
only_if: *machine_cron_not_tag_build_docs
|
||||||
|
skip: *skip_machine_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
ec2_instance:
|
ec2_instance:
|
||||||
<<: *standard_build_ec2_aarch64
|
<<: *standard_build_ec2_aarch64
|
||||||
|
@ -773,6 +792,7 @@ podman_machine_windows_task:
|
||||||
# Only run for non-docs/copr PRs and non-release branch builds
|
# Only run for non-docs/copr PRs and non-release branch builds
|
||||||
# and never for tags. Docs: ./contrib/cirrus/CIModes.md
|
# and never for tags. Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *machine_cron_not_tag_build_docs
|
only_if: *machine_cron_not_tag_build_docs
|
||||||
|
skip: *skip_machine_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
ec2_instance:
|
ec2_instance:
|
||||||
<<: *windows
|
<<: *windows
|
||||||
|
@ -797,6 +817,7 @@ podman_machine_mac_task:
|
||||||
name: *std_name_fmt
|
name: *std_name_fmt
|
||||||
alias: podman_machine_mac
|
alias: podman_machine_mac
|
||||||
only_if: *machine_cron_not_tag_build_docs
|
only_if: *machine_cron_not_tag_build_docs
|
||||||
|
skip: *skip_machine_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
persistent_worker: *mac_pw
|
persistent_worker: *mac_pw
|
||||||
env:
|
env:
|
||||||
|
@ -849,6 +870,15 @@ local_system_test_task: &local_system_test_task
|
||||||
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
|
$CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*' &&
|
||||||
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*' &&
|
$CIRRUS_CHANGE_TITLE !=~ '.*CI:BUILD.*' &&
|
||||||
$CIRRUS_CHANGE_TITLE !=~ '.*CI:MACHINE.*'
|
$CIRRUS_CHANGE_TITLE !=~ '.*CI:MACHINE.*'
|
||||||
|
# skip when: - it is a PR (we never want to skip on nightly tests); 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 != '' &&
|
||||||
|
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
|
||||||
|
!changesInclude('test/system/**') &&
|
||||||
|
!(changesInclude('**/*.go', '**/*.c') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**'))
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
matrix: *platform_axis
|
matrix: *platform_axis
|
||||||
gce_instance: *standardvm
|
gce_instance: *standardvm
|
||||||
|
@ -866,6 +896,7 @@ local_system_test_aarch64_task: &local_system_test_task_aarch64
|
||||||
# Don't create task for tags, or if using [CI:DOCS], [CI:BUILD]
|
# Don't create task for tags, or if using [CI:DOCS], [CI:BUILD]
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
# Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *not_tag_magic
|
only_if: *not_tag_magic
|
||||||
|
skip: *skip_system_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
persistent_worker: *mac_pw
|
persistent_worker: *mac_pw
|
||||||
ec2_instance: *standard_build_ec2_aarch64
|
ec2_instance: *standard_build_ec2_aarch64
|
||||||
|
@ -917,6 +948,7 @@ rootless_system_test_task:
|
||||||
alias: rootless_system_test
|
alias: rootless_system_test
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
# Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *not_tag_magic
|
only_if: *not_tag_magic
|
||||||
|
skip: *skip_system_test
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
matrix: *platform_axis
|
matrix: *platform_axis
|
||||||
gce_instance: *standardvm
|
gce_instance: *standardvm
|
||||||
|
@ -968,6 +1000,13 @@ buildah_bud_test_task:
|
||||||
alias: buildah_bud_test
|
alias: buildah_bud_test
|
||||||
# Docs: ./contrib/cirrus/CIModes.md
|
# Docs: ./contrib/cirrus/CIModes.md
|
||||||
only_if: *not_tag_magic
|
only_if: *not_tag_magic
|
||||||
|
# skip when: - it is a PR (we never want to skip on nightly tests); and
|
||||||
|
# - no danger files are changed; and
|
||||||
|
# - no build source files are changed and no bud tests
|
||||||
|
skip: >-
|
||||||
|
$CIRRUS_PR != '' &&
|
||||||
|
!changesInclude('.cirrus.yml', 'Makefile', 'contrib/cirrus/**', 'vendor/**', 'hack/**', 'version/rawversion/*') &&
|
||||||
|
!changesInclude('**/*build*.go', 'test/buildah-bud/**')
|
||||||
depends_on: *build
|
depends_on: *build
|
||||||
env:
|
env:
|
||||||
<<: *stdenvars
|
<<: *stdenvars
|
||||||
|
|
|
@ -60,6 +60,21 @@ class TestDependsOn(TestCaseBase):
|
||||||
msg=('No success aggregation task depends_on "{0}"'.format(task_name))
|
msg=('No success aggregation task depends_on "{0}"'.format(task_name))
|
||||||
self.assertIn(task_name, success_deps, msg=msg)
|
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 != '' && !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):
|
def not_task(self):
|
||||||
"""Ensure no task is named 'task'"""
|
"""Ensure no task is named 'task'"""
|
||||||
self.assertNotIn('task', self.ALL_TASK_NAMES)
|
self.assertNotIn('task', self.ALL_TASK_NAMES)
|
||||||
|
|
Loading…
Reference in New Issue