|
| 1 | +from config_generator.etc.distros import find_large_distro, make_distro_str |
| 2 | +from config_generator.etc.function import Function |
| 3 | +from config_generator.etc.utils import bash_exec |
| 4 | + |
| 5 | +from config_generator.components.funcs.fetch_source import FetchSource |
| 6 | +from config_generator.components.funcs.find_cmake_latest import FindCMakeLatest |
| 7 | + |
| 8 | +from shrub.v3.evg_build_variant import BuildVariant |
| 9 | +from shrub.v3.evg_command import EvgCommandType, FunctionCall |
| 10 | +from shrub.v3.evg_task import EvgTask, EvgTaskRef |
| 11 | + |
| 12 | +from itertools import product |
| 13 | + |
| 14 | +TAG = 'openssl-compat' |
| 15 | + |
| 16 | +# pylint: disable=line-too-long |
| 17 | +# fmt: off |
| 18 | +OPENSSL_MATRIX = [ |
| 19 | + ('ubuntu2404', 'gcc', ['shared', 'static'], ['1.0.2', '1.1.1', '3.0.9', '3.1.2', '3.2.5', '3.3.4', '3.4.2', '3.5.1']), |
| 20 | +] |
| 21 | +# fmt: on |
| 22 | + |
| 23 | +# pylint: disable=line-too-long |
| 24 | +# fmt: off |
| 25 | +OPENSSL_FIPS_MATRIX = [ |
| 26 | + # https://openssl-library.org/source/ |
| 27 | + # > The following OpenSSL version(s) are FIPS validated: |
| 28 | + # > - 3.1.2: FIPS 140-3 |
| 29 | + # > - 3.0.9: FIPS 140-2 |
| 30 | + # > - ... |
| 31 | + ('ubuntu2404', 'gcc', ['shared', 'static'], ['3.0.9', '3.1.2']), |
| 32 | +] |
| 33 | +# fmt: on |
| 34 | + |
| 35 | + |
| 36 | +class OpenSSLSetup(Function): |
| 37 | + name = 'openssl-compat' |
| 38 | + commands = [ |
| 39 | + bash_exec( |
| 40 | + command_type=EvgCommandType.SETUP, |
| 41 | + working_dir='mongoc', |
| 42 | + include_expansions_in_env=['OPENSSL_VERSION', 'OPENSSL_ENABLE_FIPS', 'OPENSSL_USE_STATIC_LIBS'], |
| 43 | + script='.evergreen/scripts/openssl-compat-setup.sh', |
| 44 | + ), |
| 45 | + bash_exec( |
| 46 | + command_type=EvgCommandType.SETUP, |
| 47 | + working_dir='mongoc', |
| 48 | + include_expansions_in_env=['OPENSSL_VERSION', 'OPENSSL_USE_STATIC_LIBS'], |
| 49 | + script='.evergreen/scripts/openssl-compat-check.sh', |
| 50 | + ), |
| 51 | + ] |
| 52 | + |
| 53 | + |
| 54 | +def functions(): |
| 55 | + return OpenSSLSetup.defn() |
| 56 | + |
| 57 | + |
| 58 | +def tasks(): |
| 59 | + for distro_name, compiler, link_types, versions in OPENSSL_MATRIX: |
| 60 | + distro_str = make_distro_str(distro_name, compiler, None) |
| 61 | + |
| 62 | + for link_type, version in product(link_types, versions): |
| 63 | + vars = {'OPENSSL_VERSION': version} |
| 64 | + |
| 65 | + if link_type == 'static': |
| 66 | + vars |= {'OPENSSL_USE_STATIC_LIBS': 'ON'} |
| 67 | + |
| 68 | + yield EvgTask( |
| 69 | + name=f'{TAG}-{version}-{link_type}-{distro_str}', |
| 70 | + run_on=find_large_distro(distro_name).name, |
| 71 | + tags=[TAG, f'openssl-{version}', f'openssl-{link_type}', distro_name, compiler], |
| 72 | + commands=[ |
| 73 | + FetchSource.call(), |
| 74 | + FindCMakeLatest.call(), |
| 75 | + OpenSSLSetup.call(vars=vars), |
| 76 | + FunctionCall(func="run auth tests"), |
| 77 | + ], |
| 78 | + ) |
| 79 | + |
| 80 | + for distro_name, compiler, link_types, versions in OPENSSL_FIPS_MATRIX: |
| 81 | + distro_str = make_distro_str(distro_name, compiler, None) |
| 82 | + |
| 83 | + for link_type, version in product(link_types, versions): |
| 84 | + vars = {'OPENSSL_VERSION': version, 'OPENSSL_ENABLE_FIPS': 'ON'} |
| 85 | + |
| 86 | + if link_type == 'static': |
| 87 | + vars |= {'OPENSSL_USE_STATIC_LIBS': 'ON'} |
| 88 | + |
| 89 | + yield EvgTask( |
| 90 | + name=f'{TAG}-fips-{version}-{link_type}-{distro_str}', |
| 91 | + run_on=find_large_distro(distro_name).name, |
| 92 | + tags=[TAG, f'openssl-fips-{version}', f'openssl-{link_type}', distro_name, compiler], |
| 93 | + commands=[ |
| 94 | + FetchSource.call(), |
| 95 | + FindCMakeLatest.call(), |
| 96 | + OpenSSLSetup.call(vars=vars), |
| 97 | + FunctionCall(func="run auth tests"), |
| 98 | + ], |
| 99 | + ) |
| 100 | + |
| 101 | + |
| 102 | +def variants(): |
| 103 | + return [ |
| 104 | + BuildVariant( |
| 105 | + name=f'{TAG}-matrix', |
| 106 | + display_name='OpenSSL Compatibility Matrix', |
| 107 | + tasks=[EvgTaskRef(name=f'.{TAG}')], |
| 108 | + ), |
| 109 | + ] |
0 commit comments