Skip to content

Commit e2e8b39

Browse files
committed
Rework StaticTypeCheck.
1 parent ae6f532 commit e2e8b39

File tree

6 files changed

+230
-66
lines changed

6 files changed

+230
-66
lines changed

.github/workflows/CompletePipeline.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,15 @@ jobs:
195195
- ConfigParams
196196
- UnitTestingParams
197197
with:
198-
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
199-
html_report: ${{ needs.ConfigParams.outputs.typing_report_html_directory }}
200-
html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
198+
python_version: ${{ needs.UnitTestingParams.outputs.python_version }}
199+
junit_report_directory: ${{ needs.ConfigParams.outputs.typing_report_junit_directory }}
200+
junit_report_file: ${{ needs.ConfigParams.outputs.typing_report_junit_file }}
201+
junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_junit }}
202+
cobertura_report_directory: ${{ needs.ConfigParams.outputs.typing_report_cobertura_directory }}
203+
cobertura_report_file: ${{ needs.ConfigParams.outputs.typing_report_cobertura_file }}
204+
cobertura_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_cobertura }}
205+
html_report: ${{ needs.ConfigParams.outputs.typing_report_html_directory }}
206+
html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }}
201207

202208
DocCoverage:
203209
uses: pyTooling/Actions/.github/workflows/CheckDocumentation.yml@dev

.github/workflows/ExtractConfiguration.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ on:
5656
package_directory:
5757
description: ""
5858
value: ${{ jobs.Extract.outputs.package_directory }}
59-
mypy_prepare_command:
60-
description: ""
61-
value: ${{ jobs.Extract.outputs.mypy_prepare_command }}
6259
unittest_report_xml_directory:
6360
description: ""
6461
value: ${{ jobs.Extract.outputs.unittest_report_xml_directory }}
@@ -98,19 +95,29 @@ on:
9895
coverage_report_json:
9996
description: ""
10097
value: ${{ jobs.Extract.outputs.coverage_report_json }}
98+
typing_report_cobertura_directory:
99+
description: ""
100+
value: ${{ jobs.Extract.outputs.typing_report_cobertura_directory }}
101+
typing_report_cobertura_file:
102+
description: ""
103+
value: ${{ jobs.Extract.outputs.typing_report_cobertura_file }}
104+
typing_report_junit_directory:
105+
description: ""
106+
value: ${{ jobs.Extract.outputs.typing_report_junit_directory }}
107+
typing_report_junit_file:
108+
description: ""
109+
value: ${{ jobs.Extract.outputs.typing_report_junit_file }}
101110
typing_report_html_directory:
102111
description: ""
103112
value: ${{ jobs.Extract.outputs.typing_report_html_directory }}
104113

105-
106114
jobs:
107115
Extract:
108116
name: 📓 Extract configurations from pyproject.toml
109117
runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}"
110118
outputs:
111119
package_fullname: ${{ steps.getPackageName.outputs.package_fullname }}
112120
package_directory: ${{ steps.getPackageName.outputs.package_directory }}
113-
mypy_prepare_command: ${{ steps.getPackageName.outputs.mypy_prepare_command }}
114121
unittest_report_xml_directory: ${{ steps.getVariables.outputs.unittest_report_xml_directory }}
115122
unittest_report_xml_filename: ${{ steps.getVariables.outputs.unittest_report_xml_filename }}
116123
unittest_report_xml: ${{ steps.getVariables.outputs.unittest_report_xml }}
@@ -124,6 +131,10 @@ jobs:
124131
coverage_report_json_directory: ${{ steps.getVariables.outputs.coverage_report_json_directory }}
125132
coverage_report_json_filename: ${{ steps.getVariables.outputs.coverage_report_json_filename }}
126133
coverage_report_json: ${{ steps.getVariables.outputs.coverage_report_json }}
134+
typing_report_cobertura_directory: ${{ steps.getVariables.outputs.typing_report_cobertura_directory }}
135+
typing_report_cobertura_file: ${{ steps.getVariables.outputs.typing_report_cobertura_file }}
136+
typing_report_junit_directory: ${{ steps.getVariables.outputs.typing_report_junit_directory }}
137+
typing_report_junit_file: ${{ steps.getVariables.outputs.typing_report_junit_file }}
127138
typing_report_html_directory: ${{ steps.getVariables.outputs.typing_report_html_directory }}
128139

129140
steps:
@@ -159,17 +170,14 @@ jobs:
159170
if namespace == "" or namespace == ".":
160171
fullname = f"{name}"
161172
directory = f"{name}"
162-
mypy_prepare_command = ""
163173
else:
164174
fullname = f"{namespace}.{name}"
165175
directory = f"{namespace}/{name}"
166-
mypy_prepare_command = f"touch {namespace}/__init__.py"
167176
168177
print(dedent(f"""\
169178
OUTPUTS:
170179
package_fullname: {fullname}
171180
package_directory: {directory}
172-
mypy_prepare_command: {mypy_prepare_command}
173181
"""))
174182
175183
github_output = Path(getenv("GITHUB_OUTPUT"))
@@ -178,7 +186,6 @@ jobs:
178186
f.write(dedent(f"""\
179187
package_fullname={fullname}
180188
package_directory={directory}
181-
mypy_prepare_command={mypy_prepare_command}
182189
"""))
183190
184191
- name: 🔁 Extract configurations from pyproject.toml
@@ -199,6 +206,8 @@ jobs:
199206
coverageXMLFile = Path("./coverage.xml")
200207
coverageJSONFile = Path("./coverage.json")
201208
coverageRC = "${{ inputs.coverage_config }}".strip()
209+
typingCoberturaFile = Path("report/typing/cobertura.xml")
210+
typingJUnitFile = Path("report/typing/StaticTypingSummary.xml")
202211
typingHTMLDirectory = Path("htmlmypy")
203212
204213
# Read output paths from 'pyproject.toml' file
@@ -213,6 +222,8 @@ jobs:
213222
coverageHTMLDirectory = Path(pyProjectSettings["tool"]["coverage"]["html"]["directory"])
214223
coverageXMLFile = Path(pyProjectSettings["tool"]["coverage"]["xml"]["output"])
215224
coverageJSONFile= Path(pyProjectSettings["tool"]["coverage"]["json"]["output"])
225+
typingCoberturaFile = Path(pyProjectSettings["tool"]["mypy"]["cobertura_xml_report"]) / "cobertura.xml"
226+
typingJUnitFile = Path(pyProjectSettings["tool"]["mypy"]["junit_xml"])
216227
typingHTMLDirectory = Path(pyProjectSettings["tool"]["mypy"]["html_report"])
217228
else:
218229
print(f"File '{pyProjectFile}' not found.")
@@ -221,6 +232,8 @@ jobs:
221232
222233
# Read output paths from '.coveragerc' file
223234
elif len(coverageRC) > 0:
235+
print(f"::warning title=Deprecated::Using '{coverageRCFile}' is deprecated. Please use 'pyproject.toml'.")
236+
224237
coverageRCFile = Path(coverageRC)
225238
if coverageRCFile.exists():
226239
with coverageRCFile.open("rb") as file:
@@ -252,6 +265,10 @@ jobs:
252265
coverage_report_json_directory={coverageJSONFile.parent.as_posix()}
253266
coverage_report_json_filename={coverageJSONFile.name}
254267
coverage_report_json={coverageJSONFile.as_posix()}
268+
typing_report_cobertura_directory={typingCoberturaFile.parent.as_posix()}
269+
typing_report_cobertura_file={typingCoberturaFile.name}
270+
typing_report_junit_directory={typingJUnitFile.parent.as_posix()}
271+
typing_report_junit_file={typingJUnitFile.name}
255272
typing_report_html_directory={typingHTMLDirectory.as_posix()}
256273
"""))
257274
@@ -262,5 +279,7 @@ jobs:
262279
coverage html: {coverageHTMLDirectory}
263280
coverage xml: {coverageXMLFile}
264281
coverage json: {coverageJSONFile}
282+
typing cobertura: {typingCoberturaFile}
283+
typing junit: {typingJUnitFile}
265284
typing html: {typingHTMLDirectory}
266285
"""))

.github/workflows/Parameters.yml

Lines changed: 113 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,33 @@ on:
115115
python_version:
116116
description: "Default Python version for other jobs."
117117
value: ${{ jobs.Parameters.outputs.python_version }}
118-
python_jobs:
119-
description: "List of Python versions (and system combinations) to be used in the matrix of other jobs."
120-
value: ${{ jobs.Parameters.outputs.python_jobs }}
118+
package_fullname:
119+
description: "The package's full name."
120+
value: ${{ jobs.Parameters.outputs.package_fullname }}
121+
package_directory:
122+
description: "The package's directory."
123+
value: ${{ jobs.Parameters.outputs.package_directory }}
124+
artifact_basename:
125+
description: "Artifact base name."
126+
value: ${{ jobs.Parameters.outputs.artifact_basename }}
121127
artifact_names:
122128
description: "Pre-defined artifact names for other jobs."
123129
value: ${{ jobs.Parameters.outputs.artifact_names }}
124-
params:
125-
description: "Parameters to be used in other jobs."
126-
value: ${{ jobs.Parameters.outputs.params }}
130+
python_jobs:
131+
description: "List of Python versions (and system combinations) to be used in the matrix of other jobs."
132+
value: ${{ jobs.Parameters.outputs.python_jobs }}
127133

128134
jobs:
129135
Parameters:
130136
name: ✎ Generate pipeline parameters
131137
runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}"
132138
outputs:
133-
python_version: ${{ steps.params.outputs.python_version }}
134-
python_jobs: ${{ steps.params.outputs.python_jobs }}
135-
artifact_names: ${{ steps.params.outputs.artifact_names }}
136-
params: ${{ steps.params.outputs.params }}
139+
python_version: ${{ steps.variables.outputs.python_version }}
140+
package_fullname: ${{ steps.variables.outputs.package_fullname }}
141+
package_directory: ${{ steps.variables.outputs.package_directory }}
142+
artifact_basename: ${{ steps.variables.outputs.artifact_basename }}
143+
artifact_names: ${{ steps.artifacts.outputs.artifact_names }}
144+
python_jobs: ${{ steps.jobs.outputs.python_jobs }}
137145

138146
steps:
139147
- name: Generate a startup delay of ${{ inputs.pipeline-delay }} seconds
@@ -142,32 +150,107 @@ jobs:
142150
run: |
143151
sleep ${{ inputs.pipeline-delay }}
144152
145-
- name: Generate 'params' and 'python_jobs'
146-
id: params
153+
- name: Generate 'python_version'
154+
id: variables
147155
shell: python
148156
run: |
149-
from json import dumps as json_dumps
150157
from os import getenv
151158
from pathlib import Path
152159
from textwrap import dedent
153-
from typing import Iterable
154160
161+
python_version = "${{ inputs.python_version }}".strip()
155162
package_namespace = "${{ inputs.package_namespace }}".strip()
156163
package_name = "${{ inputs.package_name }}".strip()
157164
name = "${{ inputs.name }}".strip()
158-
python_version = "${{ inputs.python_version }}".strip()
165+
166+
if package_namespace == "" or package_namespace == ".":
167+
package_fullname = f"{package_name}"
168+
package_directory = f"{package_name}"
169+
else:
170+
package_fullname = f"{package_namespace}.{package_name}"
171+
package_directory = f"{package_namespace}/{package_name}"
172+
173+
artifact_basename = package_fullname if name == "" else name
174+
175+
print("Variables:")
176+
print(f" python_version: {python_version}")
177+
print(f" package_fullname: {package_fullname}")
178+
print(f" package_directory: {package_directory}")
179+
print(f" artifact_basename: {artifact_basename}")
180+
181+
# Write jobs to special file
182+
github_output = Path(getenv("GITHUB_OUTPUT"))
183+
print(f"GITHUB_OUTPUT: {github_output}")
184+
with github_output.open("a+", encoding="utf-8") as f:
185+
f.write(dedent(f"""\
186+
python_version={python_version}
187+
package_fullname={package_fullname}
188+
package_directory={package_directory}
189+
artifact_basename={artifact_basename}
190+
"""))
191+
192+
- name: Generate 'artifact_names'
193+
id: artifacts
194+
shell: python
195+
run: |
196+
from json import dumps as json_dumps
197+
from os import getenv
198+
from pathlib import Path
199+
from textwrap import dedent
200+
201+
package_namespace = "${{ inputs.package_namespace }}".strip()
202+
package_name = "${{ inputs.package_name }}".strip()
203+
artifact_basename = "${{ steps.variables.outputs.artifact_basename }}"
204+
205+
artifact_names = {
206+
"unittesting_xml": f"{artifact_basename}-UnitTestReportSummary-XML",
207+
"unittesting_html": f"{artifact_basename}-UnitTestReportSummary-HTML",
208+
"perftesting_xml": f"{artifact_basename}-PerformanceTestReportSummary-XML",
209+
"benchtesting_xml": f"{artifact_basename}-BenchmarkTestReportSummary-XML",
210+
"apptesting_xml": f"{artifact_basename}-ApplicationTestReportSummary-XML",
211+
"codecoverage_sqlite": f"{artifact_basename}-CodeCoverage-SQLite",
212+
"codecoverage_xml": f"{artifact_basename}-CodeCoverage-XML",
213+
"codecoverage_json": f"{artifact_basename}-CodeCoverage-JSON",
214+
"codecoverage_html": f"{artifact_basename}-CodeCoverage-HTML",
215+
"statictyping_cobertura": f"{artifact_basename}-StaticTyping-Cobertura-XML",
216+
"statictyping_junit": f"{artifact_basename}-StaticTyping-JUnit-XML",
217+
"statictyping_html": f"{artifact_basename}-StaticTyping-HTML",
218+
"package_all": f"{artifact_basename}-Packages",
219+
"documentation_html": f"{artifact_basename}-Documentation-HTML",
220+
"documentation_latex": f"{artifact_basename}-Documentation-LaTeX",
221+
"documentation_pdf": f"{artifact_basename}-Documentation-PDF",
222+
}
223+
224+
print("Artifacts Names ({len(artifact_names)}):")
225+
for id, artifactName in artifact_names.items():
226+
print(f" {id:>24}: {artifactName}")
227+
228+
# Write jobs to special file
229+
github_output = Path(getenv("GITHUB_OUTPUT"))
230+
print(f"GITHUB_OUTPUT: {github_output}")
231+
with github_output.open("a+", encoding="utf-8") as f:
232+
f.write(dedent(f"""\
233+
artifact_names={json_dumps(artifact_names)}
234+
"""))
235+
236+
- name: Generate 'python_jobs'
237+
id: jobs
238+
shell: python
239+
run: |
240+
from json import dumps as json_dumps
241+
from os import getenv
242+
from pathlib import Path
243+
from textwrap import dedent
244+
from typing import Iterable
245+
246+
python_version = "${{ steps.variables.outputs.python_version }}"
247+
name = "${{ steps.artifacts.outputs.artifact_base }}"
159248
systems = "${{ inputs.system_list }}".strip()
160249
versions = "${{ inputs.python_version_list }}".strip()
161250
include_list = "${{ inputs.include_list }}".strip()
162251
exclude_list = "${{ inputs.exclude_list }}".strip()
163252
disable_list = "${{ inputs.disable_list }}".strip()
164253
165-
if name == "":
166-
if package_namespace == "" or package_namespace == ".":
167-
name = f"{package_name}"
168-
else:
169-
name = f"{package_namespace}.{package_name}"
170-
171254
currentMSYS2Version = "3.12"
172255
currentAlphaVersion = "3.14"
173256
currentAlphaRelease = "3.14.0-rc.2"
@@ -322,31 +405,11 @@ jobs:
322405
for runtime, version in combinations if runtime not in data["sys"]
323406
]
324407
325-
artifact_names = {
326-
"unittesting_xml": f"{name}-UnitTestReportSummary-XML",
327-
"unittesting_html": f"{name}-UnitTestReportSummary-HTML",
328-
"perftesting_xml": f"{name}-PerformanceTestReportSummary-XML",
329-
"benchtesting_xml": f"{name}-BenchmarkTestReportSummary-XML",
330-
"apptesting_xml": f"{name}-ApplicationTestReportSummary-XML",
331-
"codecoverage_sqlite": f"{name}-CodeCoverage-SQLite",
332-
"codecoverage_xml": f"{name}-CodeCoverage-XML",
333-
"codecoverage_json": f"{name}-CodeCoverage-JSON",
334-
"codecoverage_html": f"{name}-CodeCoverage-HTML",
335-
"statictyping_html": f"{name}-StaticTyping-HTML",
336-
"package_all": f"{name}-Packages",
337-
"documentation_html": f"{name}-Documentation-HTML",
338-
"documentation_latex": f"{name}-Documentation-LaTeX",
339-
"documentation_pdf": f"{name}-Documentation-PDF",
340-
}
341-
342408
print("Parameters:")
343409
print(f" python_version: {python_version}")
344410
print(f" python_jobs ({len(jobs)}):\n" +
345411
"".join([f" {{ " + ", ".join([f"\"{key}\": \"{value}\"" for key, value in job.items()]) + f" }},\n" for job in jobs])
346412
)
347-
print(f" artifact_names ({len(artifact_names)}):")
348-
for id, name in artifact_names.items():
349-
print(f" {id:>20}: {name}")
350413
351414
# Write jobs to special file
352415
github_output = Path(getenv("GITHUB_OUTPUT"))
@@ -355,13 +418,17 @@ jobs:
355418
f.write(dedent(f"""\
356419
python_version={python_version}
357420
python_jobs={json_dumps(jobs)}
358-
artifact_names={json_dumps(artifact_names)}
359421
"""))
360422
361423
- name: Verify out parameters
362424
id: verify
363425
run: |
364-
printf "python_version: %s\n" '${{ steps.params.outputs.python_version }}'
365-
printf "python_jobs: %s\n" '${{ steps.params.outputs.python_jobs }}'
366-
printf "artifact_names: %s\n" '${{ steps.params.outputs.artifact_names }}'
367-
printf "params: %s\n" '${{ steps.params.outputs.params }}'
426+
printf "python_version: %s\n" '${{ steps.variables.outputs.python_version }}'
427+
printf "package_fullname: %s\n" '${{ steps.variables.outputs.package_fullname }}'
428+
printf "package_directory: %s\n" '${{ steps.variables.outputs.package_directory }}'
429+
printf "artifact_basename: %s\n" '${{ steps.variables.outputs.artifact_basename }}'
430+
printf "====================\n"
431+
printf "artifact_names: %s\n" '${{ steps.artifacts.outputs.artifact_names }}'
432+
printf "====================\n"
433+
printf "python_jobs: %s\n" '${{ steps.jobs.outputs.python_jobs }}'
434+
printf "====================\n"

0 commit comments

Comments
 (0)