Skip to content

Commit

Permalink
feat: add branches option to platform release create
Browse files Browse the repository at this point in the history
MrBlenny committed Dec 12, 2024
1 parent 112d6f3 commit 0ec2282
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion platform_cli/groups/packaging.py
Original file line number Diff line number Diff line change
@@ -256,7 +256,9 @@ def build(version: str, output: str, no_tests: bool): # type: ignore reportUnus
jobs = cpu_count() if cpu_count() else 1
if os.environ.get("BUILDJET_THROTTLE", None):
# the number of RAM to cores on the ARM runners are insufficient, so we can't have a 1:1 job:core ratio
echo("Throttling number of jobs due to Buildjet ARM64 Runner limitations", "yellow")
echo(
"Throttling number of jobs due to Buildjet ARM64 Runner limitations", "yellow"
)
jobs = math.floor(jobs * 0.75)

call(f"DEB_BUILD_OPTIONS=parallel={jobs} fakeroot debian/rules binary")
19 changes: 13 additions & 6 deletions platform_cli/groups/release.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

from glob import glob
import os
from typing import List, Optional, Dict, Iterable, Any
from typing import List, Optional, Dict, Iterable, Any, Union
from enum import Enum
from pathlib import Path
import xml.etree.ElementTree as ET
@@ -111,6 +111,7 @@ def get_releaserc(
package_dir: Optional[str] = None,
ros_distro: Optional[str] = None,
skip_build: bool = False,
branches: Optional[List[str]] = None,
):
"""
Returns the releaserc with the plugins configured according to the arguments
@@ -126,7 +127,7 @@ def get_releaserc(
prepare_cmd_args += f" --ros-distro={ros_distro}"

releaserc = {
"branches": ["main", "master", {"name": "alpha", "prerelease": True}],
"branches": branches or ["main", "master", {"name": "alpha", "prerelease": True}],
"plugins": [],
}

@@ -354,9 +355,9 @@ def _build_deb_in_docker(
os.chmod(host_debs_path, 0o777)

envs = {}
if os.environ.get('RUNNER_ARCH', None) == 'ARM64':
if os.environ.get("RUNNER_ARCH", None) == "ARM64":
# TODO(russkel): There is no way to get the runner name aka buildjet_ubuntuXXXX_arm from env vars
envs['BUILDJET_THROTTLE'] = '1'
envs["BUILDJET_THROTTLE"] = "1"

docker.run(
docker_image_name_with_digest,
@@ -489,14 +490,19 @@ def setup(package: str, package_dir: str): # type: ignore
help="Should platform NOT build the packages",
default=False,
)
@click.option(
"--branches",
type=str,
help="The branches to release on. Defaults to: main,master,alpha",
)
@click.argument(
"args",
nargs=-1,
)
def create(changelog: bool, github_release: bool, public: bool, package: str, package_dir: str, arch: List[Architecture], ros_distro: str, skip_tag: bool, skip_build: bool, args: List[str]): # type: ignore
def create(changelog: bool, github_release: bool, public: bool, package: str, package_dir: str, arch: List[Architecture], ros_distro: str, skip_tag: bool, skip_build: bool, branches: str, args: List[str]): # type: ignore
"""Creates a release of the platform module package. See .releaserc for more info"""
args_str = " ".join(args)

branches_split = branches.split(",") if branches else None
if skip_tag:
args_str += " --skip-tag"

@@ -520,6 +526,7 @@ def create(changelog: bool, github_release: bool, public: bool, package: str, pa
package_dir,
ros_distro,
skip_build,
branches_split,
)
with open(package_info.package_path / ".releaserc", "w+") as f:
f.write(json.dumps(releaserc, indent=4))

0 comments on commit 0ec2282

Please sign in to comment.