Skip to content

Commit

Permalink
PTFE-1981 fix mistakes with API schema (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet authored Oct 15, 2024
1 parent 3bd9b89 commit 45ccec7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
5 changes: 0 additions & 5 deletions bert_e/git_host/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions bert_e/git_host/github/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 2 additions & 9 deletions bert_e/tests/images/github-mock/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
19 changes: 13 additions & 6 deletions bert_e/tests/unit/test_github_build_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,9 +50,6 @@ def workflow_run_json():
'event': 'pull_request',
'status': 'completed',
'conclusion': 'cancelled',
'app': {
'slug': 'github-actions'
},
'pull_requests': [
{
'number': 1
Expand All @@ -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)

Expand Down

0 comments on commit 45ccec7

Please sign in to comment.