diff --git a/.evergreen.yml b/.evergreen.yml index e06143c0e..9f44aa66f 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 @@ -110,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 @@ -212,19 +197,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 - - func: setup_virtualenv - - func: mypy_linting_test - - - name: e2e_test_feature_compatibility_version commands: - func: run_e2e_test @@ -364,14 +336,6 @@ buildvariants: tasks: - name: e2e_test_group - - name: code_health - display_name: code_health - run_on: - - ubuntu1604-build - tasks: - - name: mypy_linting - - name: black_formatting - - 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 new file mode 100644 index 000000000..8be014241 --- /dev/null +++ b/.github/workflows/code_health.yml @@ -0,0 +1,23 @@ +name: Code Health + +on: + pull_request: + branches: [ master ] +jobs: + Black: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - 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_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/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 {} + diff --git a/scripts/dev/dockerfile_generator.py b/scripts/dev/dockerfile_generator.py index d55c2cde4..b1dc08995 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: +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), - "python_formatting": python_formatting_params(files_to_add, script_location), } render_values = param_dict.get(image_name, dict()) @@ -56,24 +47,13 @@ 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: 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 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)