From 8563bfc59275d4f05ce94440819b8c69d7fe176b Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 29 Jan 2021 13:01:53 +0100 Subject: [PATCH 1/9] Create code_health.yml --- .github/workflows/code_health.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/code_health.yml diff --git a/.github/workflows/code_health.yml b/.github/workflows/code_health.yml new file mode 100644 index 000000000..a2b577500 --- /dev/null +++ b/.github/workflows/code_health.yml @@ -0,0 +1,15 @@ +name: Code Health + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ master ] +jobs: + Black: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Black Check + uses: jpetrucciani/black-check@20.8b1 From 5a1f28d06cf9d275bc12122993744e2fed0e33e5 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 29 Jan 2021 13:04:21 +0100 Subject: [PATCH 2/9] Update dev_config.py --- scripts/dev/dev_config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/dev/dev_config.py b/scripts/dev/dev_config.py index 8529ec85a..8eaf9e413 100644 --- a/scripts/dev/dev_config.py +++ b/scripts/dev/dev_config.py @@ -51,7 +51,5 @@ def load_config(config_file_path: str = None) -> DevConfig: with open(config_file_path, "r") as f: return DevConfig(json.loads(f.read())) except FileNotFoundError: - print( - f"No DevConfig found. Please ensure that the configuration file exists at '{config_file_path}'" - ) + print(f"No DevConfig found. Please ensure that the configuration file exists at '{config_file_path}'") raise From 122f67b4965963457ff005005fa832c18eb72bcc Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 29 Jan 2021 13:12:15 +0100 Subject: [PATCH 3/9] black format --- .evergreen.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.evergreen.yml b/.evergreen.yml index e06143c0e..184c5eaa5 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -89,14 +89,6 @@ functions: env: KUBECONFIG: ${workdir}/kube_config - black_formatting_test: - - command: subprocess.exec - type: test - params: - working_dir: mongodb-kubernetes-operator - binary: scripts/ci/run_black_formatting_check.sh - - run_e2e_test: - command: subprocess.exec type: test @@ -212,12 +204,6 @@ tasks: image_type: versionhook expire_after: 48h - - name: black_formatting - commands: - - func: clone - - func: setup_virtualenv - - func: black_formatting_test - - name: mypy_linting commands: - func: clone @@ -370,7 +356,6 @@ buildvariants: - ubuntu1604-build tasks: - name: mypy_linting - - name: black_formatting - name: init_test_run display_name: init_test_run From bc6851c1ca9d11cc50b0d07853eb1322279acd15 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 4 Feb 2021 21:39:50 +0100 Subject: [PATCH 4/9] black format --- scripts/dev/dev_config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/dev/dev_config.py b/scripts/dev/dev_config.py index 8eaf9e413..8529ec85a 100644 --- a/scripts/dev/dev_config.py +++ b/scripts/dev/dev_config.py @@ -51,5 +51,7 @@ def load_config(config_file_path: str = None) -> DevConfig: with open(config_file_path, "r") as f: return DevConfig(json.loads(f.read())) except FileNotFoundError: - print(f"No DevConfig found. Please ensure that the configuration file exists at '{config_file_path}'") + print( + f"No DevConfig found. Please ensure that the configuration file exists at '{config_file_path}'" + ) raise From 3852192915877d3857c333bd2e68fbceb8ca84a1 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 4 Feb 2021 21:44:18 +0100 Subject: [PATCH 5/9] removed unused files --- scripts/ci/run_black_formatting_check.sh | 6 ------ scripts/dev/dockerfile_generator.py | 22 +--------------------- 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100755 scripts/ci/run_black_formatting_check.sh diff --git a/scripts/ci/run_black_formatting_check.sh b/scripts/ci/run_black_formatting_check.sh deleted file mode 100755 index cf76f1ced..000000000 --- a/scripts/ci/run_black_formatting_check.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# shellcheck disable=SC1091 -. venv/bin/activate -# shellcheck disable=SC2046 -black --check $(find . -type f -not -path '*venv*' -name '*.py') diff --git a/scripts/dev/dockerfile_generator.py b/scripts/dev/dockerfile_generator.py index d55c2cde4..3c6421a3e 100755 --- a/scripts/dev/dockerfile_generator.py +++ b/scripts/dev/dockerfile_generator.py @@ -25,19 +25,10 @@ def e2e_params(files_to_add: List[str]) -> DockerParameters: } -def python_formatting_params(files_to_add: List[str], script: str) -> DockerParameters: - return { - "base_image": "python:slim", - "files_to_add": files_to_add, - "script_location": script, - } - - def render(image_name: str, files_to_add: List[str], script_location: str) -> str: param_dict = { "e2e": e2e_params(files_to_add), "operator": operator_params(files_to_add), - "python_formatting": python_formatting_params(files_to_add, script_location), } render_values = param_dict.get(image_name, dict()) @@ -56,19 +47,8 @@ def parse_args() -> argparse.Namespace: type=str, default=".", ) - parser.add_argument( - "--script_location", - help="Location of the python script to run. (Used only for python_formatting)", - type=str, - ) - args = parser.parse_args() - - if args.script_location is not None and args.image != "python_formatting": - parser.error( - 'The --script_location argument can be used only when the image used is "python_formatting"' - ) - return args + return parser.parse_args() def main() -> int: From c9ebba1b3c9f066714e43a89075aad33d05837b9 Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 4 Feb 2021 21:46:51 +0100 Subject: [PATCH 6/9] changed workflow --- .github/workflows/code_health.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/code_health.yml b/.github/workflows/code_health.yml index a2b577500..12c146574 100644 --- a/.github/workflows/code_health.yml +++ b/.github/workflows/code_health.yml @@ -1,8 +1,6 @@ name: Code Health on: - push: - branches: [ '*' ] pull_request: branches: [ master ] jobs: From b3c0bc5d0e149f29932a811a625e49dd742ea77a Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Thu, 4 Feb 2021 23:04:15 +0100 Subject: [PATCH 7/9] wip --- scripts/dev/dockerfile_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/dev/dockerfile_generator.py b/scripts/dev/dockerfile_generator.py index 3c6421a3e..b1dc08995 100755 --- a/scripts/dev/dockerfile_generator.py +++ b/scripts/dev/dockerfile_generator.py @@ -25,7 +25,7 @@ def e2e_params(files_to_add: List[str]) -> DockerParameters: } -def render(image_name: str, files_to_add: List[str], script_location: str) -> str: +def render(image_name: str, files_to_add: List[str]) -> str: param_dict = { "e2e": e2e_params(files_to_add), "operator": operator_params(files_to_add), @@ -53,7 +53,7 @@ def parse_args() -> argparse.Namespace: def main() -> int: args = parse_args() - print(render(args.image, args.files_to_add.split(os.linesep), args.script_location)) + print(render(args.image, args.files_to_add.split(os.linesep))) return 0 From b103d73b07ccad0dfa7476a9b8f6b18d999a3ecd Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 5 Feb 2021 08:28:13 +0100 Subject: [PATCH 8/9] wip --- scripts/dev/dockerutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/dockerutil.py b/scripts/dev/dockerutil.py index a5fbc2468..1368b793b 100644 --- a/scripts/dev/dockerutil.py +++ b/scripts/dev/dockerutil.py @@ -97,7 +97,7 @@ def build_and_push_image(repo_url: str, tag: str, path: str, image_type: str) -> build_and_push_operator creates the Dockerfile for the operator and pushes it to the target repo """ - dockerfile_text = render(image_type, ["."], "") + dockerfile_text = render(image_type, ["."]) with open(f"{path}/Dockerfile", "w") as f: f.write(dockerfile_text) From 2f2e36848010fd57e0a03d3c9205e17aaef7748f Mon Sep 17 00:00:00 2001 From: Nikolas De Giorgis Date: Fri, 5 Feb 2021 11:03:37 +0100 Subject: [PATCH 9/9] move Mypy to GitHub action (#323) --- .evergreen.yml | 21 --------------------- .github/workflows/code_health.yml | 10 ++++++++++ mypy.ini | 8 ++++++++ scripts/ci/run_mypy_check.sh | 5 ----- 4 files changed, 18 insertions(+), 26 deletions(-) create mode 100644 mypy.ini delete mode 100755 scripts/ci/run_mypy_check.sh diff --git a/.evergreen.yml b/.evergreen.yml index 184c5eaa5..9f44aa66f 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -102,13 +102,6 @@ functions: - clusterwide binary: scripts/ci/run_test.sh - mypy_linting_test: - - command: subprocess.exec - type: test - params: - working_dir: mongodb-kubernetes-operator - binary: scripts/ci/run_mypy_check.sh - build_and_push_image: - command: subprocess.exec @@ -204,13 +197,6 @@ tasks: image_type: versionhook expire_after: 48h - - name: mypy_linting - commands: - - func: clone - - func: setup_virtualenv - - func: mypy_linting_test - - - name: e2e_test_feature_compatibility_version commands: - func: run_e2e_test @@ -350,13 +336,6 @@ buildvariants: tasks: - name: e2e_test_group - - name: code_health - display_name: code_health - run_on: - - ubuntu1604-build - tasks: - - name: mypy_linting - - name: init_test_run display_name: init_test_run run_on: diff --git a/.github/workflows/code_health.yml b/.github/workflows/code_health.yml index 12c146574..8be014241 100644 --- a/.github/workflows/code_health.yml +++ b/.github/workflows/code_health.yml @@ -11,3 +11,13 @@ jobs: - name: Black Check uses: jpetrucciani/black-check@20.8b1 + + Mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Mypy linting + uses: jpetrucciani/mypy-check@master + with: + path: scripts/*/*.py diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000..46f77830e --- /dev/null +++ b/mypy.ini @@ -0,0 +1,8 @@ +# Global options: + +[mypy] +python_version = 3.7 +ignore_missing_imports = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_incomplete_defs = true diff --git a/scripts/ci/run_mypy_check.sh b/scripts/ci/run_mypy_check.sh deleted file mode 100755 index e5a4ae003..000000000 --- a/scripts/ci/run_mypy_check.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -# shellcheck disable=SC1091 -. venv/bin/activate -find . -type f -not -path '*venv*' -name '*.py' -exec python3 -m mypy --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports {} +