Skip to content

CDRIVER-3620 Add new config_generator #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2c50790
Add structural .evergreen/config_generator scripts
eramongodb Jan 26, 2023
4c66114
Move top-level Evergreen configuration into config.yml
eramongodb Jan 26, 2023
4dea910
Add early termination handler to top-level config
eramongodb Jan 26, 2023
e571d69
Relocate pre commands into config_generator and tasks
eramongodb Jan 26, 2023
ef6650f
Relocate abi-compliance-check task into config_generator
eramongodb Jan 26, 2023
b9515c5
Relocate upload build function to config_generator
eramongodb Jan 26, 2023
6371b59
Relocate make-release-archive into config_generator
eramongodb Jan 26, 2023
81c649e
Relocate backtrace into config_generator
eramongodb Jan 26, 2023
a44e001
Relocate timeout hook into config.yml
eramongodb Jan 26, 2023
3ec5ef7
Relocate prepare kerberos into config_generator
eramongodb Jan 26, 2023
1b10bf8
Relocate bootstrap mongo-orchestration into config_generator
eramongodb Jan 26, 2023
2a20269
Relocate check-headers into config_generator
eramongodb Jan 26, 2023
2394f06
Relocate fetch build into config_generator
eramongodb Jan 26, 2023
109b1e8
Relocate clone drivers-evergreen-tools into config_generator
eramongodb Jan 26, 2023
fc19833
Relocate run kms servers into config_generator
eramongodb Jan 27, 2023
d9bbdc5
Relocate run tests to config_generator
eramongodb Jan 27, 2023
52f9f0d
Relocate stop load balancer into config_generator
eramongodb Jan 27, 2023
c18a985
Move cleanup into config_generator
eramongodb Jan 27, 2023
4f73af2
Relocate upload test results into config_generator
eramongodb Jan 27, 2023
409f6d8
Relocate upload mo artifacts into config_generator
eramongodb Jan 27, 2023
495dda6
Remove upload working directory post command
eramongodb Jan 27, 2023
0d26244
Update requirements.txt with pip freeze
eramongodb Jan 27, 2023
c584518
Move check_mongoc_public_headers.py out of funcs
eramongodb Jan 27, 2023
4369c59
Define pre and post commands manually in top-level config
eramongodb Jan 27, 2023
dfca040
Merge remote-tracking branch 'upstream/master' into cdriver-3620
eramongodb Jan 30, 2023
9c86cb0
Disable wrapping long lines in generated YAML
eramongodb Jan 31, 2023
c46bcb2
Remove os_ver from Windows distros without OS year
eramongodb Jan 31, 2023
da77eb1
Fix vs_ver for windwos-vsCurrent-* distros
eramongodb Jan 31, 2023
a22346b
Remove redundant check for .py extension
eramongodb Jan 31, 2023
497bbc3
Rename component_path -> generator_path in generate-config.py
eramongodb Jan 31, 2023
9513462
Change command types in abi compliance check to match assertions
eramongodb Jan 31, 2023
4364dac
Use pathlib.Path instead of strings and glob
eramongodb Feb 1, 2023
e98401c
Use built-in type specifications instead of typing
eramongodb Feb 1, 2023
e42013a
Add Python version check to generate-config.py
eramongodb Feb 1, 2023
3574d8a
Use inline for loop to create ordered and suffix
eramongodb Feb 1, 2023
3c96199
Ensure same Python binary is used to invoke legacy config generator
eramongodb Feb 1, 2023
668351b
Simplify generator import routine
eramongodb Feb 1, 2023
6d05219
Refactor class definitions to use common etc.function.Function
eramongodb Feb 1, 2023
9d6c674
Remove *args from Function.default_call
eramongodb Feb 1, 2023
aa0fd77
Automatically append .evergreen to PYTHONPATH
eramongodb Feb 1, 2023
8021291
Add default value of None to classes deriving BaseModel
eramongodb Feb 1, 2023
6036f0b
Remove default None for non-optional types
eramongodb Feb 1, 2023
186a4fd
Address Pylance warning for decorator order
eramongodb Feb 1, 2023
7082393
Fix requirements.txt
eramongodb Feb 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# Default timeout for all tasks is 1 hour.
# May be overridden by individual tasks.
exec_timeout_secs: 3600

# Default command type is 'system' to indicate failures unrelated to tests or
# their setup. Most commands should define their type as 'setup' or 'test'.
# - setup: before test (lavendar).
# - test: during test (red).
# - system: after test (purple).
command_type: system

# Ensure Evergreen tests earlier commits when a task fails.
stepback: true

# Ensure failure in pre commands is also considered task failure.
pre_error_fails_task: true

# Too many post commands are not designed to handle errors.
# TODO: set to true once failing post commands have been moved into
# teardown_group commands of appropriate task groups.
post_error_fails_task: false

# Unlikely, but document loudly when task failure is due to early termination.
early_termination:
- func: early-termination

# TODO: move into timeout commands of appropriate task groups.
timeout:
- func: backtrace

# Commands run before all tasks (excluding those in task groups).
# Use sparingly and ensure they are error-proof.
pre:
- func: fetch-source

# Commands run after all tasks (excluding those in task groups).
# Use sparingly and ensure they are error-proof.
# TODO: move into teardown_group commands of appropriate task groups.
post:
- func: backtrace
- func: upload-mo-artifacts
- func: upload-test-results
- func: stop-mongo-orchestration
- func: stop-load-balancer

include:
- filename: .evergreen/generated_configs/legacy-config.yml
- filename: .evergreen/generated_configs/functions.yml
- filename: .evergreen/generated_configs/task_groups.yml
- filename: .evergreen/generated_configs/tasks.yml
- filename: .evergreen/generated_configs/variants.yml
56 changes: 56 additions & 0 deletions .evergreen/config_generator/components/abi_compliance_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from shrub.v3.evg_command import EvgCommandType
from shrub.v3.evg_command import s3_put
from shrub.v3.evg_task import EvgTask

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class CheckABICompliance(Function):
name = 'abi-compliance-check'
commands = [
bash_exec(
command_type=EvgCommandType.SETUP,
working_dir='mongoc',
script='.evergreen/scripts/abi-compliance-check.sh'
),
bash_exec(
command_type=EvgCommandType.TEST,
working_dir='mongoc',
env={
'AWS_ACCESS_KEY_ID': '${aws_key}',
'AWS_SECRET_ACCESS_KEY': '${aws_secret}',
},
script='''\
aws s3 cp abi-compliance/compat_reports s3://mciuploads/${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_reports --recursive --acl public-read --region us-east-1
[[ ! -f ./abi-compliance/abi-error.txt ]]
'''
),
s3_put(
aws_key='${aws_key}',
aws_secret='${aws_secret}',
bucket='mciuploads',
content_type='text/html',
display_name='ABI Report:',
local_files_include_filter='mongoc/abi-compliance/compat_reports/**/*.html',
permissions='public-read',
remote_file='${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_report.html',
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return CheckABICompliance.defn()


def tasks():
return [
EvgTask(
name=CheckABICompliance.name,
commands=[CheckABICompliance.call()],
)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from shrub.v3.evg_command import EvgCommandType
from shrub.v3.evg_task import EvgTask

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class CheckMongocPublicHeaders(Function):
name = 'check-headers'
commands = [
bash_exec(
command_type=EvgCommandType.TEST,
working_dir='mongoc',
script='.evergreen/scripts/check-public-decls.sh',
),
bash_exec(
command_type=EvgCommandType.TEST,
working_dir='mongoc',
script='.evergreen/scripts/check-preludes.py .',
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return CheckMongocPublicHeaders.defn()


def tasks():
return [
EvgTask(
name=CheckMongocPublicHeaders.name,
commands=[CheckMongocPublicHeaders.call()],
)
]
22 changes: 22 additions & 0 deletions .evergreen/config_generator/components/early_termination.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class EarlyTermination(Function):
name = 'early-termination'
commands = [
bash_exec(
script='''\
echo 'EVERGREEN HOST WAS UNEXPECTEDLY TERMINATED!!!' 1>&2
echo 'Restart this Evergreen task and try again!' 1>&2
'''
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return EarlyTermination.defn()
20 changes: 20 additions & 0 deletions .evergreen/config_generator/components/funcs/backtrace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class Backtrace(Function):
name = 'backtrace'
commands = [
bash_exec(
working_dir='mongoc',
script='.evergreen/scripts/debug-core-evergreen.sh',
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return Backtrace.defn()
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from shrub.v3.evg_command import EvgCommandType
from shrub.v3.evg_command import expansions_update

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class BootstrapMongoOrchestration(Function):
name = 'bootstrap-mongo-orchestration'
command_type = EvgCommandType.SETUP
commands = [
bash_exec(
command_type=command_type,
working_dir='mongoc',
script='.evergreen/scripts/integration-tests.sh',
add_expansions_to_env=True,
),
expansions_update(
command_type=command_type,
file='mongoc/mo-expansion.yml'
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return BootstrapMongoOrchestration.defn()
41 changes: 41 additions & 0 deletions .evergreen/config_generator/components/funcs/fetch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from shrub.v3.evg_command import archive_targz_extract
from shrub.v3.evg_command import EvgCommandType
from shrub.v3.evg_command import s3_get

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class FetchBuild(Function):
name = 'fetch-build'
command_type = EvgCommandType.SETUP
commands = [
bash_exec(command_type=command_type, script='rm -rf mongoc'),
s3_get(
command_type=command_type,
aws_key='${aws_key}',
aws_secret='${aws_secret}',
bucket='mciuploads',
local_file='build.tar.gz',
remote_file='${project}/${build_variant}/${revision}/${BUILD_NAME}/${build_id}.tar.gz',
),
archive_targz_extract(path='build.tar.gz', destination='mongoc'),
# Scripts may not be executable on Windows.
bash_exec(
command_type=command_type,
working_dir='mongoc',
script='''\
for file in $(find .evergreen/scripts -type f); do
chmod +rx "$file" || exit
done
'''
),
]

@classmethod
def call(cls, build_name, **kwargs):
return cls.default_call(vars={'BUILD_NAME': build_name}, **kwargs)


def functions():
return FetchBuild.defn()
26 changes: 26 additions & 0 deletions .evergreen/config_generator/components/funcs/fetch_det.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from shrub.v3.evg_command import EvgCommandType

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class FetchDET(Function):
name = 'fetch-det'
commands = [
bash_exec(
command_type=EvgCommandType.SETUP,
script='''\
if [[ ! -d drivers-evergreen-tools ]]; then
git clone --depth=1 [email protected]:mongodb-labs/drivers-evergreen-tools.git
fi
''',
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return FetchDET.defn()
61 changes: 61 additions & 0 deletions .evergreen/config_generator/components/funcs/fetch_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from shrub.v3.evg_command import EvgCommandType
from shrub.v3.evg_command import expansions_update
from shrub.v3.evg_command import git_get_project

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class FetchSource(Function):
name = 'fetch-source'
command_type = EvgCommandType.SETUP
commands = [
git_get_project(command_type=command_type, directory='mongoc'),
bash_exec(
command_type=command_type,
working_dir='mongoc',
script='''\
set -o errexit
if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then
# This is a GitHub PR or patch build, probably branched from master
if command -v python3 2>/dev/null; then
# Prefer python3 if it is available
echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
else
echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
fi
VERSION=$VERSION_CURRENT-${version_id}
else
VERSION=latest
fi
echo "CURRENT_VERSION: $VERSION" > expansion.yml
'''
),
expansions_update(command_type=command_type,
file='mongoc/expansion.yml'),
bash_exec(
command_type=command_type,
script='''\
rm -f *.tar.gz
curl --retry 5 --output mongoc.tar.gz -sS --max-time 120 https://s3.amazonaws.com/mciuploads/${project}/${branch_name}/mongo-c-driver-${CURRENT_VERSION}.tar.gz
'''
),
# Scripts may not be executable on Windows.
bash_exec(
command_type=EvgCommandType.SETUP,
working_dir='mongoc',
script='''\
for file in $(find .evergreen/scripts -type f); do
chmod +rx "$file" || exit
done
'''
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return FetchSource.defn()
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from shrub.v3.evg_command import EvgCommandType

from config_generator.etc.function import Function
from config_generator.etc.utils import bash_exec


class PrepareKerberos(Function):
name = 'prepare-kerberos'
commands = [
bash_exec(
command_type=EvgCommandType.SETUP,
working_dir='mongoc',
silent=True,
script='''\
if test "${keytab|}" && [[ -f /etc/krb5.conf ]]; then
echo "${keytab}" > /tmp/drivers.keytab.base64
base64 --decode /tmp/drivers.keytab.base64 > /tmp/drivers.keytab
if touch /etc/krb5.conf 2>/dev/null; then
cat .evergreen/etc/kerberos.realm | tee -a /etc/krb5.conf
elif command sudo true 2>/dev/null; then
cat .evergreen/etc/kerberos.realm | sudo tee -a /etc/krb5.conf
else
echo "Cannot append kerberos.realm to /etc/krb5.conf; skipping." 1>&2
fi
fi
'''
),
]

@classmethod
def call(cls, **kwargs):
return cls.default_call(**kwargs)


def functions():
return PrepareKerberos.defn()
Loading