Skip to content

Commit 99e15e5

Browse files
author
Nikolas De Giorgis
authored
Move black formatting to GitHub action (#322)
1 parent f9f6ae7 commit 99e15e5

File tree

7 files changed

+35
-71
lines changed

7 files changed

+35
-71
lines changed

.evergreen.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@ functions:
8989
env:
9090
KUBECONFIG: ${workdir}/kube_config
9191

92-
black_formatting_test:
93-
- command: subprocess.exec
94-
type: test
95-
params:
96-
working_dir: mongodb-kubernetes-operator
97-
binary: scripts/ci/run_black_formatting_check.sh
98-
99-
10092
run_e2e_test:
10193
- command: subprocess.exec
10294
type: test
@@ -110,13 +102,6 @@ functions:
110102
- clusterwide
111103
binary: scripts/ci/run_test.sh
112104

113-
mypy_linting_test:
114-
- command: subprocess.exec
115-
type: test
116-
params:
117-
working_dir: mongodb-kubernetes-operator
118-
binary: scripts/ci/run_mypy_check.sh
119-
120105

121106
build_and_push_image:
122107
- command: subprocess.exec
@@ -212,19 +197,6 @@ tasks:
212197
image_type: versionhook
213198
expire_after: 48h
214199

215-
- name: black_formatting
216-
commands:
217-
- func: clone
218-
- func: setup_virtualenv
219-
- func: black_formatting_test
220-
221-
- name: mypy_linting
222-
commands:
223-
- func: clone
224-
- func: setup_virtualenv
225-
- func: mypy_linting_test
226-
227-
228200
- name: e2e_test_feature_compatibility_version
229201
commands:
230202
- func: run_e2e_test
@@ -364,14 +336,6 @@ buildvariants:
364336
tasks:
365337
- name: e2e_test_group
366338

367-
- name: code_health
368-
display_name: code_health
369-
run_on:
370-
- ubuntu1604-build
371-
tasks:
372-
- name: mypy_linting
373-
- name: black_formatting
374-
375339
- name: init_test_run
376340
display_name: init_test_run
377341
run_on:

.github/workflows/code_health.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Code Health
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
jobs:
7+
Black:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Black Check
13+
uses: jpetrucciani/black-check@20.8b1
14+
15+
Mypy:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Mypy linting
21+
uses: jpetrucciani/mypy-check@master
22+
with:
23+
path: scripts/*/*.py

mypy.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Global options:
2+
3+
[mypy]
4+
python_version = 3.7
5+
ignore_missing_imports = true
6+
disallow_untyped_calls = true
7+
disallow_untyped_defs = true
8+
disallow_incomplete_defs = true

scripts/ci/run_black_formatting_check.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/ci/run_mypy_check.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/dev/dockerfile_generator.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,10 @@ def e2e_params(files_to_add: List[str]) -> DockerParameters:
2525
}
2626

2727

28-
def python_formatting_params(files_to_add: List[str], script: str) -> DockerParameters:
29-
return {
30-
"base_image": "python:slim",
31-
"files_to_add": files_to_add,
32-
"script_location": script,
33-
}
34-
35-
36-
def render(image_name: str, files_to_add: List[str], script_location: str) -> str:
28+
def render(image_name: str, files_to_add: List[str]) -> str:
3729
param_dict = {
3830
"e2e": e2e_params(files_to_add),
3931
"operator": operator_params(files_to_add),
40-
"python_formatting": python_formatting_params(files_to_add, script_location),
4132
}
4233

4334
render_values = param_dict.get(image_name, dict())
@@ -56,24 +47,13 @@ def parse_args() -> argparse.Namespace:
5647
type=str,
5748
default=".",
5849
)
59-
parser.add_argument(
60-
"--script_location",
61-
help="Location of the python script to run. (Used only for python_formatting)",
62-
type=str,
63-
)
64-
args = parser.parse_args()
65-
66-
if args.script_location is not None and args.image != "python_formatting":
67-
parser.error(
68-
'The --script_location argument can be used only when the image used is "python_formatting"'
69-
)
7050

71-
return args
51+
return parser.parse_args()
7252

7353

7454
def main() -> int:
7555
args = parse_args()
76-
print(render(args.image, args.files_to_add.split(os.linesep), args.script_location))
56+
print(render(args.image, args.files_to_add.split(os.linesep)))
7757
return 0
7858

7959

scripts/dev/dockerutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def build_and_push_image(repo_url: str, tag: str, path: str, image_type: str) ->
9797
build_and_push_operator creates the Dockerfile for the operator
9898
and pushes it to the target repo
9999
"""
100-
dockerfile_text = render(image_type, ["."], "")
100+
dockerfile_text = render(image_type, ["."])
101101
with open(f"{path}/Dockerfile", "w") as f:
102102
f.write(dockerfile_text)
103103

0 commit comments

Comments
 (0)