Skip to content

Commit 6432741

Browse files
committed
Reduced code duplications when checking job-matrix and artifact names by using local Actions.
1 parent 7e6bb82 commit 6432741

4 files changed

Lines changed: 252 additions & 489 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Check artifact names
2+
branding:
3+
icon: check-square
4+
color: green
5+
description: Check generated artifact names.
6+
author: Patrick Lehmann (@Paebbels)
7+
8+
inputs:
9+
prefix:
10+
description:
11+
type: string
12+
required: true
13+
generated-names:
14+
description:
15+
type: string
16+
required: true
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Install dependencies
22+
shell: bash
23+
run: pip install --disable-pip-version-check --break-system-packages pyTooling
24+
25+
- name: Check artifact names
26+
id: check
27+
shell: python
28+
working-directory: ${{ inputs.path }}
29+
run: |
30+
from pyTooling.Common import zipdicts
31+
32+
expectedName = "Example"
33+
expectedArtifacts = {
34+
"unittesting_xml": f"{expectedName}-UnitTestReportSummary-XML",
35+
"unittesting_html": f"{expectedName}-UnitTestReportSummary-HTML",
36+
"perftesting_xml": f"{expectedName}-PerformanceTestReportSummary-XML",
37+
"benchtesting_xml": f"{expectedName}-BenchmarkTestReportSummary-XML",
38+
"apptesting_xml": f"{expectedName}-ApplicationTestReportSummary-XML",
39+
"codecoverage_sqlite": f"{expectedName}-CodeCoverage-SQLite",
40+
"codecoverage_xml": f"{expectedName}-CodeCoverage-XML",
41+
"codecoverage_json": f"{expectedName}-CodeCoverage-JSON",
42+
"codecoverage_html": f"{expectedName}-CodeCoverage-HTML",
43+
"statictyping_cobertura": f"{expectedName}-StaticTyping-Cobertura-XML",
44+
"statictyping_junit": f"{expectedName}-StaticTyping-JUnit-XML",
45+
"statictyping_html": f"{expectedName}-StaticTyping-HTML",
46+
"package_all": f"{expectedName}-Packages",
47+
"documentation_html": f"{expectedName}-Documentation-HTML",
48+
"documentation_latex": f"{expectedName}-Documentation-LaTeX",
49+
"documentation_pdf": f"{expectedName}-Documentation-PDF",
50+
}
51+
52+
actualArtifactNames = json_loads("""${{ inputs }}""".replace("'", '"'))
53+
errors = 0
54+
55+
if len(actualArtifactNames) != len(expectedArtifacts):
56+
print(f"Number of 'artifact_names' does not match: {len(actualArtifactNames)} != {len(expectedArtifacts)}.")
57+
errors += 1
58+
else:
59+
for key, actual, expected in zipdicts(actualArtifactNames, expectedArtifacts):
60+
if actual != expected:
61+
print(f"Artifact name '{key}' does not match: {actual} != {expected}.")
62+
errors += 1
63+
64+
if errors == 0:
65+
print(f"All checks PASSED.")
66+
67+
exit(errors)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Check job matrix
2+
branding:
3+
icon: check-square
4+
color: green
5+
description: Check generated job matrix.
6+
author: Patrick Lehmann (@Paebbels)
7+
8+
inputs:
9+
expected-default-version:
10+
description:
11+
type: string
12+
required: true
13+
expected-python-versions:
14+
description:
15+
type: string
16+
required: true
17+
expected-systems:
18+
description:
19+
type: string
20+
required: true
21+
expected-exclude-jobs:
22+
description:
23+
type: string
24+
required: true
25+
expected-include-jobs:
26+
description:
27+
type: string
28+
required: true
29+
generated-default-version:
30+
description:
31+
type: string
32+
required: true
33+
generated-jobmatrix:
34+
description:
35+
type: string
36+
required: true
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- name: Check parameters
42+
id: check
43+
shell: python
44+
run: |
45+
from json import loads as json_loads
46+
from sys import exit
47+
48+
expectedPythonVersion = """${{ inputs.expected-default-version }}"""
49+
expectedPythons = json_loads("""${{ inputs.expected-python-versions }}""".replace("'", '"'))
50+
expectedSystems = json_loads("""${{ inputs.expected-systems }}""".replace("'", '"'))
51+
excludedJobs = json_loads("""${{ inputs.expected-exclude-jobs }}""".replace("'", '"'))
52+
includeJobs = json_loads("""${{ inputs.expected-include-jobs }}""".replace("'", '"'))
53+
expectedJobs = [f"{system}:{python}" for system in expectedSystems for python in expectedPythons if f"{system}:{python}" not in excludedJobs] + includeJobs
54+
55+
actualPythonVersion = """${{ inputs.generated-default-version }}"""
56+
actualPythonJobs = json_loads("""${{ inputs.generated-jobmatrix }}""".replace("'", '"'))
57+
errors = 0
58+
59+
if actualPythonVersion != expectedPythonVersion:
60+
print(f"'python_version' does not match: '{actualPythonVersion}' != '{expectedPythonVersion}'.")
61+
errors += 1
62+
63+
if len(actualPythonJobs) != len(expectedJobs):
64+
print(f"Number of 'python_jobs' does not match: {len(actualPythonJobs)} != {len(expectedJobs)}.")
65+
print("Actual jobs:")
66+
for job in actualPythonJobs:
67+
if job['system'] == "msys2":
68+
print(f" {job['runtime'].lower()}:{job['python']}")
69+
else:
70+
print(f" {job['system']}:{job['python']}")
71+
72+
print("Expected jobs:")
73+
for job in expectedJobs:
74+
print(f" {job}")
75+
errors += 1
76+
else:
77+
print("❌ Checking job matrix is not implemented")
78+
79+
if errors == 0:
80+
print(f"All checks PASSED.")
81+
82+
exit(errors)

.github/workflows/_Checking_ArtifactCleanup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
uses: pyTooling/Actions/.github/workflows/Parameters.yml@dev
1010
with:
1111
name: Example
12-
python_version_list: "3.12 3.13"
12+
python_version_list: "3.13 3.14" # py-1, py-0
1313
system_list: "ubuntu windows"
1414

1515
Testing:

0 commit comments

Comments
 (0)