Skip to content

Commit ed34701

Browse files
authored
Implemented download + upload of openapi.json (#62)
* Implemented download + upload of openapi.json
1 parent 1d64153 commit ed34701

File tree

4 files changed

+3414
-16
lines changed

4 files changed

+3414
-16
lines changed

.github/workflows/check-api-outdated.yml

+7-14
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ jobs:
2525
- name: SCM Checkout
2626
uses: actions/checkout@v4
2727

28-
- name: Display Branch and Download openapi.json
29-
id: download
30-
run: |
31-
git branch
32-
F="ci-$(date "+%y%m%d-%H%M").json"
33-
curl -s https://cloud.exasol.com/openapi.json -o "$F"
34-
echo json=$F >> "$GITHUB_OUTPUT"
35-
36-
- name: Upload openapi.json
37-
uses: actions/upload-artifact@v4
38-
with:
39-
name: ${{ steps.download.outputs.json}}
40-
path: ${{ steps.download.outputs.json}}
41-
4228
- name: Setup Python & Poetry Environment
4329
uses: exasol/python-toolbox/.github/actions/[email protected]
4430
with:
@@ -58,3 +44,10 @@ jobs:
5844
notify_when: "failure,cancelled,warnings,skipped"
5945
env:
6046
SLACK_WEBHOOK_URL: ${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }}
47+
48+
- name: Upload openapi.json
49+
if: ${{ failure() }}
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: openapi.json
53+
path: openapi.json

doc/changes/unreleased.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
* #53: Separated long-running tests
66
* Updated GitHub workflow to upload `openapi.json` as artifact
7+
* #61: Restricted upload of `openapi.json` to failures
78

89
## Features
910

1011
* #55 Added publicly callable function finding the database id from its name.
12+
* #60: Added download of `openapi.json` when generating python client
1113

1214
## Documentation
1315

noxfile.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import json
12
import os
23
import nox
4+
import requests
35

6+
from datetime import datetime, timezone
47
from pathlib import Path
58
from nox import Session
69
from noxconfig import PROJECT_CONFIG
@@ -13,6 +16,21 @@
1316
nox.options.sessions = ["fix"]
1417

1518

19+
def _download_openapi_json() -> Path:
20+
url = f"{SAAS_HOST}/openapi.json"
21+
response = requests.get(url)
22+
response.raise_for_status()
23+
content = response.json()
24+
content["info"]["download"] = {
25+
"source": url,
26+
"timestamp": datetime.now(timezone.utc).isoformat(),
27+
}
28+
file = Path("openapi.json")
29+
with open(file, "w") as f:
30+
json.dump(content, f, indent=4)
31+
return file
32+
33+
1634
@nox.session(name="generate-api", python=False)
1735
def generate_api(session: Session):
1836
"""
@@ -26,10 +44,11 @@ def generate_api(session: Session):
2644
#default-environment-variables.
2745
"""
2846
silent = "CI" not in os.environ
47+
filename = _download_openapi_json()
2948
session.run(
3049
"openapi-python-client",
3150
"update",
32-
"--url", f"{SAAS_HOST}/openapi.json",
51+
"--path", str(filename),
3352
"--config", "openapi_config.yml",
3453
silent=silent,
3554
)
@@ -42,7 +61,7 @@ def check_api_outdated(session: Session):
4261
Generate API and run git diff to verify if API is out-dated.
4362
"""
4463
generate_api(session)
45-
session.run("git", "diff", "--exit-code")
64+
session.run("git", "diff", "--exit-code", "exasol/saas/client/openapi")
4665

4766

4867
@nox.session(name="get-project-short-tag", python=False)

0 commit comments

Comments
 (0)