Skip to content

Commit a77ee9a

Browse files
committed
nitpicks
1 parent d7a075c commit a77ee9a

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

Tools/scripts/ReleaseAutomation/release_config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import datetime
1+
"""Netcode configuration for the release process automation."""
2+
3+
import datetime
24
import sys
35
import os
46
from github import Github
@@ -7,8 +9,8 @@
79
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
810
sys.path.insert(0, PARENT_DIR)
911

10-
from Utils.general_utils import get_package_version_from_manifest # nopep8
11-
from release import make_package_release_ready # nopep8
12+
from Utils.general_utils import get_package_version_from_manifest
13+
from release import make_package_release_ready
1214

1315
class GithubUtils:
1416
def __init__(self, access_token, repo):

Tools/scripts/ReleaseAutomation/run_release_preparation.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import sys
2-
import os
1+
"""Automation for package release process."""
32

43
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
54
sys.path.insert(0, PARENT_DIR)
65

7-
from ReleaseAutomation.release_config import ReleaseConfig # nopep8
8-
from Utils.git_utils import create_branch_execute_commands_and_push # nopep8
9-
from Utils.verifyReleaseConditions import verifyReleaseConditions # nopep8
10-
from Utils.commitChangelogAndPackageVersionUpdates import commitChangelogAndPackageVersionUpdates # nopep8
11-
from Utils.triggerYamatoJobsForReleasePreparation import trigger_release_preparation_jobs # nopep8
6+
import sys
7+
import os
8+
from ReleaseAutomation.release_config import ReleaseConfig
9+
from Utils.git_utils import create_branch_execute_commands_and_push
10+
from Utils.verifyReleaseConditions import verifyReleaseConditions
11+
from Utils.commitChangelogAndPackageVersionUpdates import commitChangelogAndPackageVersionUpdates
12+
from Utils.triggerYamatoJobsForReleasePreparation import trigger_release_preparation_jobs
1213

1314
def PrepareNetcodePackageForRelease():
1415
try:
@@ -27,7 +28,7 @@ def PrepareNetcodePackageForRelease():
2728
commitChangelogAndPackageVersionUpdates(config)
2829

2930
except Exception as e:
30-
print(f"\n--- ERROR: Netcode release process failed ---", file=sys.stderr)
31+
print("\n--- ERROR: Netcode release process failed ---", file=sys.stderr)
3132
print(f"Reason: {e}", file=sys.stderr)
3233
sys.exit(1)
3334

Tools/scripts/Utils/git_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Helper class for Git repo operations."""
2+
3+
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../ReleaseAutomation'))
4+
sys.path.insert(0, PARENT_DIR)
5+
26
import subprocess
37
import sys
48
import os
59
from git import Repo, Actor
610
from github import GithubException
7-
8-
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../ReleaseAutomation'))
9-
sys.path.insert(0, PARENT_DIR)
10-
1111
from release_config import ReleaseConfig
1212

1313
def get_local_repo():
@@ -35,10 +35,10 @@ def get_latest_git_revision(branch_name):
3535
)
3636
return result.stdout.strip()
3737

38-
except FileNotFoundError:
39-
raise Exception("Git command not found. Please ensure Git is installed and available in your PATH.")
38+
except FileNotFoundError as exc:
39+
raise Exception("Git command not found. Please ensure Git is installed and available in your PATH.") from exc
4040
except subprocess.CalledProcessError as e:
41-
raise Exception(f"Failed to get the latest revision for branch '{branch_name}'.")
41+
raise Exception(f"Failed to get the latest revision for branch '{branch_name}'.") from e
4242

4343
def create_branch_execute_commands_and_push(config: ReleaseConfig):
4444
"""
@@ -57,7 +57,7 @@ def create_branch_execute_commands_and_push(config: ReleaseConfig):
5757

5858
if config.command_to_run_on_release_branch:
5959
print(f"\nExecuting command on branch '{config.release_branch_name}': {' '.join(config.command_to_run_on_release_branch.__name__)}")
60-
config.command_to_run_on_release_branch(config.manifest_path, config.changelog_path, config.validation_exceptions_path, config.package_version)
60+
config.command_to_run_on_release_branch(config.manifest_path, config.changelog_path, config.validation_exceptions_path, config.package_version, config.package_name_regex)
6161

6262
repo.git.add('.yamato/') # regenerated jobs
6363
repo.git.add('Packages/') # for example changelog and package.json updates
@@ -72,6 +72,6 @@ def create_branch_execute_commands_and_push(config: ReleaseConfig):
7272
print(f"Successfully created, updated and pushed new branch: {config.release_branch_name}")
7373

7474
except GithubException as e:
75-
raise GithubException(f"An error occurred with the GitHub API: {e.status}", data=e.data)
75+
raise GithubException(f"An error occurred with the GitHub API: {e.status}", data=e.data) from e
7676
except Exception as e:
77-
raise Exception(f"An unexpected error occurred: {e}")
77+
raise Exception(f"An unexpected error occurred: {e}") from e

Tools/scripts/Utils/triggerYamatoJobsForReleasePreparation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
Additionally the job also triggers build automation job that will prepare builds for the Playtest.
77
"""
88
#!/usr/bin/env python3
9-
import os
10-
import sys
11-
import requests
129

1310
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
1411
sys.path.insert(0, PARENT_DIR)
1512

13+
import os
14+
import sys
15+
import requests
1616
from ReleaseAutomation.release_config import ReleaseConfig
1717
from Utils.git_utils import get_latest_git_revision
1818

@@ -44,7 +44,7 @@ def trigger_wrench_promotion_job_on_yamato(yamato_api_token, project_id, branch_
4444
}
4545

4646
print(f"Triggering job on branch {branch_name}...\n")
47-
response = requests.post(YAMATO_API_URL, headers=headers, json=data)
47+
response = requests.post(YAMATO_API_URL, headers=headers, json=data, timeout=10)
4848

4949
if response.status_code in [200, 201]:
5050
data = response.json()
@@ -109,7 +109,7 @@ def trigger_automated_builds_job_on_yamato(yamato_api_token, project_id, branch_
109109
}
110110

111111
print(f"Triggering the build of {sample['name']} with a configuration '{config['job_name']}' on branch {branch_name}...\n")
112-
response = requests.post(YAMATO_API_URL, headers=headers, json=data)
112+
response = requests.post(YAMATO_API_URL, headers=headers, json=data, timeout=10)
113113

114114
if not response.status_code in [200, 201]:
115115
print(f"Failed to trigger job. Status: {response.status_code}", file=sys.stderr)
@@ -128,6 +128,6 @@ def trigger_release_preparation_jobs(config: ReleaseConfig):
128128
trigger_automated_builds_job_on_yamato(config.yamato_api_token, config.yamato_project_id, config.release_branch_name, revision_sha, config.yamato_samples_to_build, config.yamato_build_automation_configs)
129129

130130
except Exception as e:
131-
print(f"\n--- ERROR: Job failed ---", file=sys.stderr)
131+
print("\n--- ERROR: Job failed ---", file=sys.stderr)
132132
print(f"Reason: {e}", file=sys.stderr)
133133
sys.exit(1)

Tools/scripts/Utils/verifyReleaseConditions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
- If the release branch for the target release already exists, the script will not run.
1111
"""
1212
#!/usr/bin/env python3
13-
import datetime
14-
import re
15-
import sys
16-
import os
1713

1814
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../ReleaseAutomation'))
1915
sys.path.insert(0, PARENT_DIR)
2016

17+
import datetime
18+
import re
19+
import sys
20+
import os
2121
from release_config import ReleaseConfig
2222

2323
def is_release_date(weekday, release_week_cycle, anchor_date):
@@ -90,6 +90,6 @@ def verifyReleaseConditions(config: ReleaseConfig):
9090
sys.exit(1)
9191

9292
except Exception as e:
93-
print(f"\n--- ERROR: Release Verification failed ---", file=sys.stderr)
93+
print("\n--- ERROR: Release Verification failed ---", file=sys.stderr)
9494
print(f"Reason: {e}", file=sys.stderr)
9595
sys.exit(1)

0 commit comments

Comments
 (0)