def run_build(build, job_type, opts, project=Project.GROMACS): """Main entry point for Jenkins builds. Runs the build with the given build script and build parameters. Before calling this script, the job should have checked out the releng repository to a :file:`releng/` subdirectory of the workspace, and the repository that triggered the build, similarly in a subdirectory of the workspace. See :doc:`releng` for more details on the general build organization. Args: build (str): Build type identifying the build script to use. Names without directory separators are interpreted as :file:`gromacs/admin/builds/{build}.py`, i.e., loaded from the main repository. job_type (JobType): Type/scope of the job that can, e.g., influence the scope of testing. Not all build scripts use the value. opts (List[str]): This is mainly intended for multi-configuration builds. Build scripts not intended for such builds may simply ignore most of the parameters that can be influenced by these options. """ from context import BuildContext from factory import ContextFactory # Please ensure that __main__.py stays in sync. factory = ContextFactory(default_project=project) with factory.status_reporter: BuildContext._run_build(factory, build, job_type, opts)
def read_build_script_config(script_name, outputfile): """Reads build options specified in a build script. Args: script_name (str): Name of the build script (see run_build()). outputfile (str): File to write the configurations to, under build/. """ from context import BuildContext from factory import ContextFactory factory = ContextFactory() with factory.status_reporter: BuildContext._read_build_script_config(factory, script_name, outputfile)
def read_build_script_config(script_name): """Reads build options specified in a build script. Args: script_name (str): Name of the build script (see run_build()). """ from context import BuildContext from factory import ContextFactory factory = ContextFactory() with factory.status_reporter as status: config = BuildContext._read_build_script_config(factory, script_name) status.return_value = config
def read_source_version_info(): """Reads version info from the source repository. Returns a structure that provides version information from the source repository. """ from context import BuildContext from factory import ContextFactory factory = ContextFactory() with factory.status_reporter as status: context = BuildContext._run_build(factory, 'get-version-info', JobType.GERRIT, None) version, regtest_md5sum = context._get_version_info() status.return_value = { 'version': version, 'regressiontestsMd5sum': regtest_md5sum }
def read_source_version_info(outputfile): """Reads version info from the source repository. Information is written as a JSON file that can be read from a workflow script calling this (a temporary file is by far the simplest way to pass the information out). Args: outputfile (str): File to write the information to, under logs/. """ from context import BuildContext from factory import ContextFactory import json factory = ContextFactory() with factory.status_reporter: context = BuildContext._run_build(factory, 'get-version-info', JobType.GERRIT, None) version, regtest_md5sum = context._get_version_info() contents = json.dumps({ 'version': version, 'regressiontestsMd5sum': regtest_md5sum }) path = factory.workspace.get_path_for_logfile(outputfile) factory.executor.write_file(path, contents)
def run_build(args, factory): BuildContext._run_build(factory, args.script, args.job_type, args.opts)
def create_context(self, *args): """Creates a BuildContext with given arguments.""" return BuildContext(self, *args)
workspace_root = args.workspace if workspace_root is None: workspace_root = os.path.join(os.path.dirname(__file__), "..", "..") workspace_root = os.path.abspath(workspace_root) project = Project.GROMACS if args.project is not None: project = Project.parse(args.project) env = dict(os.environ) env.update({ 'CHECKOUT_PROJECT': Project.RELENG, 'CHECKOUT_REFSPEC': 'HEAD', 'GROMACS_REFSPEC': 'HEAD', 'RELENG_REFSPEC': 'HEAD', 'REGRESSIONTESTS_REFSPEC': 'HEAD', 'WORKSPACE': workspace_root }) # Please ensure that run_build() in __init__.py stays in sync. factory = ContextFactory(default_project=project, system=args.system, env=env) if not args.run: from executor import DryRunExecutor factory.init_executor(cls=DryRunExecutor) factory.init_gerrit_integration(user=args.user) with factory.status_reporter: if args.matrix: prepare_build_matrix(factory, args.matrix, os.path.basename(args.matrix)) else: BuildContext._run_build(factory, args.build, args.job_type, args.opts)