|
| 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 | + run: | |
| 29 | + from json import loads as json_loads |
| 30 | + from sys import exit |
| 31 | +
|
| 32 | + from pyTooling.Common import zipdicts |
| 33 | +
|
| 34 | + actualArtifactNames = json_loads("""${{ inputs.generated-names }}""".replace("'", '"')) |
| 35 | +
|
| 36 | + expectedName = "${{ inputs.prefix }}" |
| 37 | + expectedArtifacts = { |
| 38 | + "unittesting_xml": f"{expectedName}-UnitTestReportSummary-XML", |
| 39 | + "unittesting_html": f"{expectedName}-UnitTestReportSummary-HTML", |
| 40 | + "perftesting_xml": f"{expectedName}-PerformanceTestReportSummary-XML", |
| 41 | + "benchtesting_xml": f"{expectedName}-BenchmarkTestReportSummary-XML", |
| 42 | + "apptesting_xml": f"{expectedName}-ApplicationTestReportSummary-XML", |
| 43 | + "codecoverage_sqlite": f"{expectedName}-CodeCoverage-SQLite", |
| 44 | + "codecoverage_xml": f"{expectedName}-CodeCoverage-XML", |
| 45 | + "codecoverage_json": f"{expectedName}-CodeCoverage-JSON", |
| 46 | + "codecoverage_html": f"{expectedName}-CodeCoverage-HTML", |
| 47 | + "statictyping_cobertura": f"{expectedName}-StaticTyping-Cobertura-XML", |
| 48 | + "statictyping_junit": f"{expectedName}-StaticTyping-JUnit-XML", |
| 49 | + "statictyping_html": f"{expectedName}-StaticTyping-HTML", |
| 50 | + "package_all": f"{expectedName}-Packages", |
| 51 | + "documentation_html": f"{expectedName}-Documentation-HTML", |
| 52 | + "documentation_latex": f"{expectedName}-Documentation-LaTeX", |
| 53 | + "documentation_pdf": f"{expectedName}-Documentation-PDF", |
| 54 | + } |
| 55 | +
|
| 56 | + errors = 0 |
| 57 | + if len(actualArtifactNames) != len(expectedArtifacts): |
| 58 | + print(f"❌ Number of 'artifact_names' does not match: {len(actualArtifactNames)} != {len(expectedArtifacts)}.") |
| 59 | + errors += 1 |
| 60 | + else: |
| 61 | + print("✅ Number of 'artifact_names' as expected.") |
| 62 | + print("Checking artifact names ...") |
| 63 | +
|
| 64 | + for key, actual, expected in zipdicts(actualArtifactNames, expectedArtifacts): |
| 65 | + if actual != expected: |
| 66 | + print(f" ❌ Artifact name '{key}' does not match: {actual} != {expected}.") |
| 67 | + errors += 1 |
| 68 | + else: |
| 69 | + print(f" ☑ Artifact name as expected: {key} ⇢ {actual}.") |
| 70 | +
|
| 71 | + if errors == 0: |
| 72 | + print("✅ All checks PASSED.") |
| 73 | + else: |
| 74 | + print(f"❌ Counted {errors} errors.") |
| 75 | + exit(errors) |
0 commit comments