Skip to content

Commit aff3b0d

Browse files
committed
Ensure argument --release_id for gl-gh-release is handled as int
Signed-off-by: Tobias Wolf <wolf@b1-systems.de> On-behalf-of: SAP <tobias.wolf@sap.com>
1 parent 86e685a commit aff3b0d

File tree

5 files changed

+21
-33
lines changed

5 files changed

+21
-33
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Installs the given GardenLinux Python library
44
inputs:
55
version:
66
description: GardenLinux Python library version
7-
default: "0.10.19"
7+
default: "0.10.20"
88
python_version:
99
description: Python version to setup
1010
default: "3.13"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "gardenlinux"
3-
version = "0.10.19"
3+
version = "0.10.20"
44
description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames"
55
authors = ["Garden Linux Maintainers <contact@gardenlinux.io>"]
66
license = "Apache-2.0"

src/gardenlinux/github/release/__main__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def get_parser() -> argparse.ArgumentParser:
131131

132132
upload_parser.add_argument(
133133
"--release_id",
134+
type=int,
134135
required=True,
135136
help="GitHub release ID to upload the file to (required).",
136137
)
@@ -149,7 +150,10 @@ def get_parser() -> argparse.ArgumentParser:
149150
)
150151

151152
upload_parser.add_argument(
152-
"--overwrite-same-name", action="store_true", default=False
153+
"--overwrite-same-name",
154+
action="store_true",
155+
default=False,
156+
help="Overwrite assets with the same name.",
153157
)
154158

155159
return parser

tests/github/constants.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from ..constants import TEST_COMMIT, TEST_GARDENLINUX_RELEASE
22

3+
TEST_GARDENLINUX_RELEASE_ID = 1
4+
35
RELEASE_JSON = {
4-
"url": "https://api.github.com/repos/gardenlinux/gardenlinux/releases/1",
6+
"url": f"https://api.github.com/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}",
57
"html_url": f"https://github.com/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE}",
6-
"assets_url": "https://api.github.com/repos/gardenlinux/gardenlinux/releases/1/assets",
7-
"upload_url": "https://uploads.github.com/repos/gardenlinux/gardenlinux/releases/1/assets{?name,label}",
8+
"assets_url": f"https://api.github.com/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}/assets",
9+
"upload_url": f"https://uploads.github.com/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}/assets{{?name,label}}",
810
"tarball_url": "https://api.github.com/repos/gardenlinux/gardenlinux/tarball/{TEST_GARDENLINUX_RELEASE}",
911
"zipball_url": "https://api.github.com/repos/gardenlinux/gardenlinux/zipball/{TEST_GARDENLINUX_RELEASE}",
1012
"discussion_url": "https://github.com/gardenlinux/gardenlinux/discussions/1",

tests/github/test_github_script.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from gardenlinux.constants import GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
99

1010
from ..constants import TEST_GARDENLINUX_COMMIT, TEST_GARDENLINUX_RELEASE
11-
from .constants import RELEASE_JSON, REPO_JSON
11+
from .constants import RELEASE_JSON, REPO_JSON, TEST_GARDENLINUX_RELEASE_ID
1212

1313

1414
def test_script_parse_args_wrong_command(
@@ -145,7 +145,7 @@ def test_script_upload_needs_github_token(
145145
"--repo",
146146
"gardenlinux",
147147
"--release_id",
148-
TEST_GARDENLINUX_RELEASE,
148+
str(TEST_GARDENLINUX_RELEASE_ID),
149149
"--file_path",
150150
str(artifact_for_upload),
151151
"--dry-run",
@@ -190,7 +190,7 @@ def test_script_upload_dry_run(
190190
)
191191

192192
m.get(
193-
f"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/tags/{TEST_GARDENLINUX_RELEASE}",
193+
f"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}",
194194
json=RELEASE_JSON,
195195
status_code=200,
196196
)
@@ -206,7 +206,7 @@ def test_script_upload_dry_run(
206206
"--repo",
207207
"gardenlinux",
208208
"--release_id",
209-
TEST_GARDENLINUX_RELEASE,
209+
str(TEST_GARDENLINUX_RELEASE_ID),
210210
"--file_path",
211211
str(artifact_for_upload),
212212
"--dry-run",
@@ -237,23 +237,11 @@ def test_script_upload_inaccessible_file(
237237
)
238238

239239
m.get(
240-
"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/1",
240+
f"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}",
241241
json=RELEASE_JSON,
242242
status_code=200,
243243
)
244244

245-
m.get(
246-
f"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/tags/{TEST_GARDENLINUX_RELEASE}",
247-
json=RELEASE_JSON,
248-
status_code=200,
249-
)
250-
251-
m.post(
252-
f"//uploads.github.com:443/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE}/assets?name=artifact.log",
253-
text="{}",
254-
status_code=201,
255-
)
256-
257245
monkeypatch.setattr(
258246
sys,
259247
"argv",
@@ -265,7 +253,7 @@ def test_script_upload_inaccessible_file(
265253
"--repo",
266254
"gardenlinux",
267255
"--release_id",
268-
TEST_GARDENLINUX_RELEASE,
256+
str(TEST_GARDENLINUX_RELEASE_ID),
269257
"--file_path",
270258
str(artifact_for_upload),
271259
],
@@ -289,19 +277,13 @@ def test_script_upload(
289277
)
290278

291279
m.get(
292-
"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/1",
293-
json=RELEASE_JSON,
294-
status_code=200,
295-
)
296-
297-
m.get(
298-
f"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/tags/{TEST_GARDENLINUX_RELEASE}",
280+
f"//api.github.com:443/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}",
299281
json=RELEASE_JSON,
300282
status_code=200,
301283
)
302284

303285
m.post(
304-
"//uploads.github.com:443/repos/gardenlinux/gardenlinux/releases/1/assets?label=&name=artifact.log",
286+
f"//uploads.github.com:443/repos/gardenlinux/gardenlinux/releases/{TEST_GARDENLINUX_RELEASE_ID}/assets?label=&name=artifact.log",
305287
json={},
306288
status_code=201,
307289
)
@@ -317,7 +299,7 @@ def test_script_upload(
317299
"--repo",
318300
"gardenlinux",
319301
"--release_id",
320-
TEST_GARDENLINUX_RELEASE,
302+
str(TEST_GARDENLINUX_RELEASE_ID),
321303
"--file_path",
322304
str(artifact_for_upload),
323305
],

0 commit comments

Comments
 (0)