mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 10:30:33 +03:00 
			
		
		
		
	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
This commit is contained in:
		
							
								
								
									
										38
									
								
								.cirrus.star
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								.cirrus.star
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ https://github.com/bazelbuild/starlark/blob/master/spec.md | |||||||
| See also .cirrus.yml and src/tools/ci/README | See also .cirrus.yml and src/tools/ci/README | ||||||
| """ | """ | ||||||
|  |  | ||||||
| load("cirrus", "env", "fs", "yaml") | load("cirrus", "env", "fs", "re", "yaml") | ||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
| @@ -66,6 +66,7 @@ def main(): | |||||||
| def compute_environment_vars(): | def compute_environment_vars(): | ||||||
|     cenv = {} |     cenv = {} | ||||||
|  |  | ||||||
|  |     ### | ||||||
|     # Some tasks are manually triggered by default because they might use too |     # Some tasks are manually triggered by default because they might use too | ||||||
|     # many resources for users of free Cirrus credits, but they can be |     # many resources for users of free Cirrus credits, but they can be | ||||||
|     # triggered automatically by naming them in an environment variable e.g. |     # triggered automatically by naming them in an environment variable e.g. | ||||||
| @@ -82,6 +83,41 @@ def compute_environment_vars(): | |||||||
|         else: |         else: | ||||||
|             value = 'manual' |             value = 'manual' | ||||||
|         cenv[name] = value |         cenv[name] = value | ||||||
|  |     ### | ||||||
|  |  | ||||||
|  |     ### | ||||||
|  |     # Parse "ci-os-only:" tag in commit message and set | ||||||
|  |     # CI_{$OS}_ENABLED variable for each OS | ||||||
|  |  | ||||||
|  |     # We want to disable SanityCheck if testing just a specific OS. This | ||||||
|  |     # shortens push-wait-for-ci cycle time a bit when debugging operating | ||||||
|  |     # system specific failures. Just treating it as an OS in that case | ||||||
|  |     # suffices. | ||||||
|  |  | ||||||
|  |     operating_systems = [ | ||||||
|  |       'compilerwarnings', | ||||||
|  |       'freebsd', | ||||||
|  |       'linux', | ||||||
|  |       'macos', | ||||||
|  |       'mingw', | ||||||
|  |       'sanitycheck', | ||||||
|  |       'windows', | ||||||
|  |     ] | ||||||
|  |     commit_message = env.get('CIRRUS_CHANGE_MESSAGE') | ||||||
|  |     match_re = r"(^|.*\n)ci-os-only: ([^\n]+)($|\n.*)" | ||||||
|  |  | ||||||
|  |     # re.match() returns an array with a tuple of (matched-string, match_1, ...) | ||||||
|  |     m = re.match(match_re, commit_message) | ||||||
|  |     if m and len(m) > 0: | ||||||
|  |         os_only = m[0][2] | ||||||
|  |         os_only_list = re.split(r'[, ]+', os_only) | ||||||
|  |     else: | ||||||
|  |         os_only_list = operating_systems | ||||||
|  |  | ||||||
|  |     for os in operating_systems: | ||||||
|  |         os_enabled = os in os_only_list | ||||||
|  |         cenv['CI_{0}_ENABLED'.format(os.upper())] = os_enabled | ||||||
|  |     ### | ||||||
|  |  | ||||||
|     return cenv |     return cenv | ||||||
|  |  | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ task: | |||||||
|   # push-wait-for-ci cycle time a bit when debugging operating system specific |   # push-wait-for-ci cycle time a bit when debugging operating system specific | ||||||
|   # failures. Uses skip instead of only_if, as cirrus otherwise warns about |   # failures. Uses skip instead of only_if, as cirrus otherwise warns about | ||||||
|   # only_if conditions not matching. |   # only_if conditions not matching. | ||||||
|   skip: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:.*' |   skip: $CI_SANITYCHECK_ENABLED == false | ||||||
|  |  | ||||||
|   env: |   env: | ||||||
|     CPUS: 4 |     CPUS: 4 | ||||||
| @@ -143,7 +143,7 @@ task: | |||||||
|   <<: *freebsd_task_template |   <<: *freebsd_task_template | ||||||
|  |  | ||||||
|   depends_on: SanityCheck |   depends_on: SanityCheck | ||||||
|   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*freebsd.*' |   only_if: $CI_FREEBSD_ENABLED | ||||||
|  |  | ||||||
|   sysinfo_script: | |   sysinfo_script: | | ||||||
|     id |     id | ||||||
| @@ -280,7 +280,7 @@ task: | |||||||
|   <<: *linux_task_template |   <<: *linux_task_template | ||||||
|  |  | ||||||
|   depends_on: SanityCheck |   depends_on: SanityCheck | ||||||
|   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*' |   only_if: $CI_LINUX_ENABLED | ||||||
|  |  | ||||||
|   ccache_cache: |   ccache_cache: | ||||||
|     folder: ${CCACHE_DIR} |     folder: ${CCACHE_DIR} | ||||||
| @@ -449,7 +449,7 @@ task: | |||||||
|   <<: *macos_task_template |   <<: *macos_task_template | ||||||
|  |  | ||||||
|   depends_on: SanityCheck |   depends_on: SanityCheck | ||||||
|   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*(macos|darwin|osx).*' |   only_if: $CI_MACOS_ENABLED | ||||||
|  |  | ||||||
|   sysinfo_script: | |   sysinfo_script: | | ||||||
|     id |     id | ||||||
| @@ -556,7 +556,7 @@ task: | |||||||
|   <<: *windows_task_template |   <<: *windows_task_template | ||||||
|  |  | ||||||
|   depends_on: SanityCheck |   depends_on: SanityCheck | ||||||
|   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*' |   only_if: $CI_WINDOWS_ENABLED | ||||||
|  |  | ||||||
|   setup_additional_packages_script: | |   setup_additional_packages_script: | | ||||||
|     REM choco install -y --no-progress ... |     REM choco install -y --no-progress ... | ||||||
| @@ -594,7 +594,7 @@ task: | |||||||
|   trigger_type: $CI_TRIGGER_TYPE_MINGW |   trigger_type: $CI_TRIGGER_TYPE_MINGW | ||||||
|  |  | ||||||
|   depends_on: SanityCheck |   depends_on: SanityCheck | ||||||
|   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*mingw.*' |   only_if: $CI_MINGW_ENABLED | ||||||
|  |  | ||||||
|   env: |   env: | ||||||
|     TEST_JOBS: 4 # higher concurrency causes occasional failures |     TEST_JOBS: 4 # higher concurrency causes occasional failures | ||||||
| @@ -648,10 +648,9 @@ task: | |||||||
|  |  | ||||||
|   # To limit unnecessary work only run this once the SanityCheck |   # To limit unnecessary work only run this once the SanityCheck | ||||||
|   # succeeds. This is particularly important for this task as we intentionally |   # succeeds. This is particularly important for this task as we intentionally | ||||||
|   # use always: to continue after failures. Task that did not run count as a |   # use always: to continue after failures. | ||||||
|   # success, so we need to recheck SanityChecks's condition here ... |  | ||||||
|   depends_on: SanityCheck |   depends_on: SanityCheck | ||||||
|   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' |   only_if: $CI_COMPILERWARNINGS_ENABLED | ||||||
|  |  | ||||||
|   env: |   env: | ||||||
|     CPUS: 4 |     CPUS: 4 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user