From 698af8daa3d983d29cfaf432810f4d2033c3db2b Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:23:48 +0000 Subject: [PATCH] PTFE-1981 fix mistakes with API schema --- bert_e/git_host/github/__init__.py | 5 ----- bert_e/git_host/github/schema.py | 2 ++ bert_e/tests/images/github-mock/Dockerfile | 11 ++--------- bert_e/tests/unit/test_github_build_status.py | 19 +++++++++++++------ 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/bert_e/git_host/github/__init__.py b/bert_e/git_host/github/__init__.py index f942ff40..b791e1b6 100644 --- a/bert_e/git_host/github/__init__.py +++ b/bert_e/git_host/github/__init__.py @@ -654,11 +654,6 @@ def remove_unwanted_workflows(self): self._workflow_runs )) - self._workflow_runs = list(filter( - lambda elem: elem['app']['slug'] == 'github-actions', - self._workflow_runs - )) - # When two of the same workflow ran on the same branch, # we only keep the best one. conclusion_ranking = { diff --git a/bert_e/git_host/github/schema.py b/bert_e/git_host/github/schema.py index 81e287ca..9f4d18fb 100644 --- a/bert_e/git_host/github/schema.py +++ b/bert_e/git_host/github/schema.py @@ -137,9 +137,11 @@ class WorkflowRun(GitHubSchema): head_sha = fields.Str() head_branch = fields.Str() status = fields.Str() + conclusion = fields.Str(allow_none=True) check_suite_id = fields.Integer() html_url = fields.Str() event = fields.Str() + workflow_id = fields.Integer() class AggregateWorkflowRuns(GitHubSchema): diff --git a/bert_e/tests/images/github-mock/Dockerfile b/bert_e/tests/images/github-mock/Dockerfile index 5fc45921..4b8e61e4 100644 --- a/bert_e/tests/images/github-mock/Dockerfile +++ b/bert_e/tests/images/github-mock/Dockerfile @@ -15,15 +15,8 @@ RUN curl https://github.com/stoplightio/prism/releases/download/${PRISM_VERSION} WORKDIR /app -RUN curl -O -L https://raw.githubusercontent.com/github/rest-api-description/a2f6c1ddb1840778cf7a4119c4446d697f77500e/descriptions/ghec/ghec.2022-11-28.json - -# There's a misconfiguration in the openapi file, we are going to replace the following strings: -# - "server-statistics-actions.yaml" -> "#/components/schemas/server-statistics-actions" -# - "server-statistics-packages.yaml" -> "#/components/schemas/server-statistics-packages" - -RUN sed -i 's/server-statistics-actions.yaml/#\/components\/schemas\/server-statistics-actions/g' ghec.2022-11-28.json \ - && sed -i 's/server-statistics-packages.yaml/#\/components\/schemas\/server-statistics-packages/g' ghec.2022-11-28.json +RUN curl -O -L https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/api.github.com/api.github.com.json ENTRYPOINT [ "prism" ] -CMD ["mock", "ghec.2022-11-28.json", "-h", "0.0.0.0"] +CMD ["mock", "api.github.com.json", "-h", "0.0.0.0"] diff --git a/bert_e/tests/unit/test_github_build_status.py b/bert_e/tests/unit/test_github_build_status.py index 01f7435d..58937359 100644 --- a/bert_e/tests/unit/test_github_build_status.py +++ b/bert_e/tests/unit/test_github_build_status.py @@ -28,9 +28,6 @@ def workflow_run_json(): 'workflow_id': 1, 'check_suite_id': 1, 'conclusion': 'success', - 'app': { - 'slug': 'github-actions' - }, 'pull_requests': [ { 'number': 1 @@ -53,9 +50,6 @@ def workflow_run_json(): 'event': 'pull_request', 'status': 'completed', 'conclusion': 'cancelled', - 'app': { - 'slug': 'github-actions' - }, 'pull_requests': [ { 'number': 1 @@ -74,6 +68,19 @@ def workflow_run_json(): } +def test_aggregated_workflow_run_api_client(client): + """Run the workflow run client with the GitHub mock server.""" + workflow_runs = AggregatedWorkflowRuns.get( + client=client, + owner='octo-org', + repo='Hello-World', + params={ + 'head_sha': 'd6fde92930d4715a2b49857d24b940956b26d2d3' + } + ) + assert workflow_runs.state == 'INPROGRESS' + + def test_aggregated_workflow_run(client, workflow_run_json): workflow_runs = AggregatedWorkflowRuns(client, **workflow_run_json)