Skip to content

Commit 60b64e6

Browse files
committed
ci: Simplify ci-os-only handling
Handle 'ci-os-only' occurrences in the .cirrus.star file instead of .cirrus.tasks.yml file. Now, 'ci-os-only' occurrences are controlled from one central place instead of dealing with them in each task. Author: Andres Freund <andres@anarazel.de> Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://postgr.es/m/20240413021221.hg53rvqlvldqh57i%40awork3.anarazel.de Backpatch: 15-, where CI support was added
1 parent 49cba82 commit 60b64e6

File tree

2 files changed

+49
-12
lines changed

2 files changed

+49
-12
lines changed

.cirrus.star

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ https://github.com/bazelbuild/starlark/blob/master/spec.md
77
See also .cirrus.yml and src/tools/ci/README
88
"""
99

10-
load("cirrus", "env", "fs", "yaml")
10+
load("cirrus", "env", "fs", "re", "yaml")
1111

1212

1313
def main():
@@ -66,6 +66,7 @@ def main():
6666
def compute_environment_vars():
6767
cenv = {}
6868

69+
###
6970
# Some tasks are manually triggered by default because they might use too
7071
# many resources for users of free Cirrus credits, but they can be
7172
# triggered automatically by naming them in an environment variable e.g.
@@ -82,6 +83,43 @@ def compute_environment_vars():
8283
else:
8384
value = 'manual'
8485
cenv[name] = value
86+
###
87+
88+
###
89+
# Parse "ci-os-only:" tag in commit message and set
90+
# CI_{$OS}_ENABLED variable for each OS
91+
92+
# We want to disable SanityCheck if testing just a specific OS. This
93+
# shortens push-wait-for-ci cycle time a bit when debugging operating
94+
# system specific failures. Just treating it as an OS in that case
95+
# suffices.
96+
97+
operating_systems = [
98+
'compilerwarnings',
99+
'freebsd',
100+
'linux',
101+
'macos',
102+
'mingw',
103+
'netbsd',
104+
'openbsd',
105+
'sanitycheck',
106+
'windows',
107+
]
108+
commit_message = env.get('CIRRUS_CHANGE_MESSAGE')
109+
match_re = r"(^|.*\n)ci-os-only: ([^\n]+)($|\n.*)"
110+
111+
# re.match() returns an array with a tuple of (matched-string, match_1, ...)
112+
m = re.match(match_re, commit_message)
113+
if m and len(m) > 0:
114+
os_only = m[0][2]
115+
os_only_list = re.split(r'[, ]+', os_only)
116+
else:
117+
os_only_list = operating_systems
118+
119+
for os in operating_systems:
120+
os_enabled = os in os_only_list
121+
cenv['CI_{0}_ENABLED'.format(os.upper())] = os_enabled
122+
###
85123

86124
return cenv
87125

.cirrus.tasks.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ task:
7272
# push-wait-for-ci cycle time a bit when debugging operating system specific
7373
# failures. Uses skip instead of only_if, as cirrus otherwise warns about
7474
# only_if conditions not matching.
75-
skip: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:.*'
75+
skip: $CI_SANITYCHECK_ENABLED == false
7676

7777
env:
7878
CPUS: 4
@@ -167,7 +167,7 @@ task:
167167
<<: *freebsd_task_template
168168

169169
depends_on: SanityCheck
170-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*freebsd.*'
170+
only_if: $CI_FREEBSD_ENABLED
171171

172172
sysinfo_script: |
173173
id
@@ -258,7 +258,7 @@ task:
258258
- name: NetBSD - Meson
259259
# See REPO_CI_AUTOMATIC_TRIGGER_TASKS in .cirrus.star
260260
trigger_type: $CI_TRIGGER_TYPE_NETBSD
261-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*netbsd.*'
261+
only_if: $CI_NETBSD_ENABLED
262262
env:
263263
OS_NAME: netbsd
264264
IMAGE_FAMILY: pg-ci-netbsd-postgres
@@ -277,7 +277,7 @@ task:
277277
- name: OpenBSD - Meson
278278
# See REPO_CI_AUTOMATIC_TRIGGER_TASKS in .cirrus.star
279279
trigger_type: $CI_TRIGGER_TYPE_OPENBSD
280-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*openbsd.*'
280+
only_if: $CI_OPENBSD_ENABLED
281281
env:
282282
OS_NAME: openbsd
283283
IMAGE_FAMILY: pg-ci-openbsd-postgres
@@ -417,7 +417,7 @@ task:
417417
<<: *linux_task_template
418418

419419
depends_on: SanityCheck
420-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
420+
only_if: $CI_LINUX_ENABLED
421421

422422
ccache_cache:
423423
folder: ${CCACHE_DIR}
@@ -616,7 +616,7 @@ task:
616616
<<: *macos_task_template
617617

618618
depends_on: SanityCheck
619-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*(macos|darwin|osx).*'
619+
only_if: $CI_MACOS_ENABLED
620620

621621
sysinfo_script: |
622622
id
@@ -722,7 +722,7 @@ task:
722722
<<: *windows_task_template
723723

724724
depends_on: SanityCheck
725-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
725+
only_if: $CI_WINDOWS_ENABLED
726726

727727
setup_additional_packages_script: |
728728
REM choco install -y --no-progress ...
@@ -761,7 +761,7 @@ task:
761761
trigger_type: $CI_TRIGGER_TYPE_MINGW
762762

763763
depends_on: SanityCheck
764-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*mingw.*'
764+
only_if: $CI_MINGW_ENABLED
765765

766766
env:
767767
TEST_JOBS: 4 # higher concurrency causes occasional failures
@@ -815,10 +815,9 @@ task:
815815

816816
# To limit unnecessary work only run this once the SanityCheck
817817
# succeeds. This is particularly important for this task as we intentionally
818-
# use always: to continue after failures. Task that did not run count as a
819-
# success, so we need to recheck SanityChecks's condition here ...
818+
# use always: to continue after failures.
820819
depends_on: SanityCheck
821-
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*'
820+
only_if: $CI_COMPILERWARNINGS_ENABLED
822821

823822
env:
824823
CPUS: 4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy