diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e951649f41a7f17c0433e0f30803de8b7805925b..a95066391320a6e9591228784671faa5c5056cc8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,11 +5,11 @@ - docker - linux -flake8: +black: <<: *test_job image: registry.gitlab.isc.org/isc-projects/images/bind9:debian-bullseye-amd64 script: - - find . -name "*.py" -execdir flake8 {} + + - black $(git ls-files '*.py') pylint: <<: *test_job diff --git a/windows-docker/executor.py b/windows-docker/executor.py index ff6a5d1bff8493a3ca7abee3cec63470f571b928..67093230a0b70b4132d59afeec87afe3223a103e 100644 --- a/windows-docker/executor.py +++ b/windows-docker/executor.py @@ -17,7 +17,7 @@ import subprocess import sys -DOCKER_PATH = 'C:\\Program Files\\Docker\\docker.exe' +DOCKER_PATH = "C:\\Program Files\\Docker\\docker.exe" def fatal_error(message): @@ -43,9 +43,9 @@ def do_config(*_): Perform the Config stage of a GitLab CI job. """ config = { - 'builds_dir': 'C:\\builds', - 'cache_dir': 'C:\\cache', - 'builds_dir_is_shared': False, + "builds_dir": "C:\\builds", + "cache_dir": "C:\\cache", + "builds_dir_is_shared": False, } print(json.dumps(config)) @@ -54,12 +54,17 @@ def do_prepare(container_name, _): """ Perform the Prepare stage of a GitLab CI job. """ - docker_command(['run', - '--name', container_name, - '--interactive', - '--detach', - '--rm', - os.environ['CUSTOM_ENV_CI_JOB_IMAGE']]) + docker_command( + [ + "run", + "--name", + container_name, + "--interactive", + "--detach", + "--rm", + os.environ["CUSTOM_ENV_CI_JOB_IMAGE"], + ] + ) def do_run(container_name, args): @@ -67,17 +72,17 @@ def do_run(container_name, args): Perform the Run stage of a GitLab CI job. """ valid_stages = [ - 'prepare_script', - 'get_sources', - 'restore_cache', - 'download_artifacts', - 'build_script', - 'step_script', - 'after_script', - 'archive_cache', - 'upload_artifacts_on_success', - 'upload_artifacts_on_failure', - 'cleanup_file_variables', + "prepare_script", + "get_sources", + "restore_cache", + "download_artifacts", + "build_script", + "step_script", + "after_script", + "archive_cache", + "upload_artifacts_on_success", + "upload_artifacts_on_failure", + "cleanup_file_variables", ] script_src = args[0] @@ -86,17 +91,17 @@ def do_run(container_name, args): if stage not in valid_stages: fatal_error(f'Unsupported run stage "{stage}"') - script_dst_path = f'C:\\{stage}.ps1' - script_dst = f'{container_name}:{script_dst_path}' - docker_command(['cp', script_src, script_dst]) - docker_command(['exec', container_name, 'powershell.exe', script_dst_path]) + script_dst_path = f"C:\\{stage}.ps1" + script_dst = f"{container_name}:{script_dst_path}" + docker_command(["cp", script_src, script_dst]) + docker_command(["exec", container_name, "powershell.exe", script_dst_path]) def do_cleanup(container_name, _): """ Perform the Cleanup stage of a GitLab CI job. """ - docker_command(['stop', container_name]) + docker_command(["stop", container_name]) def main(): @@ -104,21 +109,21 @@ def main(): Parse arguments and perform the requested stage of a GitLab CI job. """ actions = { - 'config': do_config, - 'prepare': do_prepare, - 'run': do_run, - 'cleanup': do_cleanup, + "config": do_config, + "prepare": do_prepare, + "run": do_run, + "cleanup": do_cleanup, } - valid_actions = '|'.join(actions.keys()) + valid_actions = "|".join(actions.keys()) try: action = actions[sys.argv[1]] except (IndexError, KeyError): - fatal_error(f'Usage: {sys.argv[0]} {valid_actions} [args...]') + fatal_error(f"Usage: {sys.argv[0]} {valid_actions} [args...]") - container_name = 'gitlab-runner-' + os.environ['CUSTOM_ENV_CI_JOB_ID'] + container_name = "gitlab-runner-" + os.environ["CUSTOM_ENV_CI_JOB_ID"] action(container_name, sys.argv[2:]) -if __name__ == '__main__': +if __name__ == "__main__": main()