From cf2c3f19cfb91dfb7cf5f4d1ae7804abf2f7e880 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 3 Nov 2022 21:24:55 +0100 Subject: [PATCH] Writing sanity checks in Python. --- .github/workflows/ExamplePipeline.yml | 83 +++++++++++++++++++-------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ExamplePipeline.yml b/.github/workflows/ExamplePipeline.yml index e52d52e..51c2b6e 100644 --- a/.github/workflows/ExamplePipeline.yml +++ b/.github/workflows/ExamplePipeline.yml @@ -56,28 +56,65 @@ jobs: - Params_Exclude - Params_All runs-on: ubuntu-latest + defaults: + run: + shell: python steps: - run: | - echo "python_version: ${{ needs.Params_Default.outputs.python_version }}" - echo "python_jobs: ${{ needs.Params_Default.outputs.python_jobs }}" - echo "artifact_names: ${{ needs.Params_Default.outputs.artifact_names }}" - - run: | - echo "python_version: ${{ needs.Params_PythonVersions.outputs.python_version }}" - echo "python_jobs: ${{ needs.Params_PythonVersions.outputs.python_jobs }}" - echo "artifact_names: ${{ needs.Params_PythonVersions.outputs.artifact_names }}" - - run: | - echo "python_version: ${{ needs.Params_Systems.outputs.python_version }}" - echo "python_jobs: ${{ needs.Params_Systems.outputs.python_jobs }}" - echo "artifact_names: ${{ needs.Params_Systems.outputs.artifact_names }}" - - run: | - echo "python_version: ${{ needs.Params_Include.outputs.python_version }}" - echo "python_jobs: ${{ needs.Params_Include.outputs.python_jobs }}" - echo "artifact_names: ${{ needs.Params_Include.outputs.artifact_names }}" - - run: | - echo "python_version: ${{ needs.Params_Exclude.outputs.python_version }}" - echo "python_jobs: ${{ needs.Params_Exclude.outputs.python_jobs }}" - echo "artifact_names: ${{ needs.Params_Exclude.outputs.artifact_names }}" - - run: | - echo "python_version: ${{ needs.Params_All.outputs.python_version }}" - echo "python_jobs: ${{ needs.Params_All.outputs.python_jobs }}" - echo "artifact_names: ${{ needs.Params_All.outputs.artifact_names }}" + from json import loads as json_loads + from sys import exit + + expectedPythonVersion = "3.11" + expectedPythons = ["3.7", "3.8", "3.9", "3.10", "3.11"] + expectedSystems = ["ubuntu", "windows", "macos"] + expectedJobs = [f"{system}:{python}" for system in expectedSystems for python in expectedPythons] + ["mingw64:3.10"] + expectedName = "Example" + expectedArtifacts = { + "unittesting": f"{expectedName}-TestReport", + "codecoverage": f"{expectedName}-Coverage", + "statictyping": f"{expectedName}-Typing", + "package": f"{expectedName}-Package", + "documentation": f"{expectedName}-Documentation" + } + + actualPythonVersion = "${{ needs.Params_Default.outputs.python_version }}" + actualPythonJobs = json_loads("${{ needs.Params_Default.outputs.python_jobs }}".replace("'", '"')) + actualArtifactNames = json_loads("${{ needs.Params_Default.outputs.artifact_names }}".replace("'", '"')) + errors = 0 + + if actualPythonVersion != expectedPythonVersion: + print(f"'python_version' does not match: '{actualPythonVersion}' != '{expectedPythonVersion}'.") + errors += 1 + if len(actualPythonJobs) != len(expectedJobs): + print(f"Number of 'python_jobs' does not match: {len(actualPythonJobs)} != {len(expectedJobs)}.") + for job in actualPythonJobs: + print(f" {job['system']}:{job['python']}") + errors += 1 + if len(actualArtifactNames) != len(expectedArtifacts): + print(f"Number of 'artifact_names' does not match: {len(actualArtifactNames)} != {len(expectedArtifacts)}.") + for name in actualArtifactNames: + print(f" {name}") + errors += 1 + + exit(errors) + +# - run: | +# echo "python_version: ${{ needs.Params_PythonVersions.outputs.python_version }}" +# echo "python_jobs: ${{ needs.Params_PythonVersions.outputs.python_jobs }}" +# echo "artifact_names: ${{ needs.Params_PythonVersions.outputs.artifact_names }}" +# - run: | +# echo "python_version: ${{ needs.Params_Systems.outputs.python_version }}" +# echo "python_jobs: ${{ needs.Params_Systems.outputs.python_jobs }}" +# echo "artifact_names: ${{ needs.Params_Systems.outputs.artifact_names }}" +# - run: | +# echo "python_version: ${{ needs.Params_Include.outputs.python_version }}" +# echo "python_jobs: ${{ needs.Params_Include.outputs.python_jobs }}" +# echo "artifact_names: ${{ needs.Params_Include.outputs.artifact_names }}" +# - run: | +# echo "python_version: ${{ needs.Params_Exclude.outputs.python_version }}" +# echo "python_jobs: ${{ needs.Params_Exclude.outputs.python_jobs }}" +# echo "artifact_names: ${{ needs.Params_Exclude.outputs.artifact_names }}" +# - run: | +# echo "python_version: ${{ needs.Params_All.outputs.python_version }}" +# echo "python_jobs: ${{ needs.Params_All.outputs.python_jobs }}" +# echo "artifact_names: ${{ needs.Params_All.outputs.artifact_names }}"