Esempio n. 1
0
#!/usr/bin/env python3

# Purpose: Run cargo update and make a pull-request against master.
# Dependencies: None
# Usage: ./automation/cargo-update-pr.py

from shared import step_msg, fatal_err, run_cmd_checked, find_app_services_root, ensure_working_tree_clean

step_msg("Checking that the generated protobuf Rust files are up-to-date")
# ensure_working_tree_clean()
config_file_path = find_app_services_root() / "tools/protobuf_files.toml"
run_cmd_checked(["cargo", "run", "--bin", "protobuf-gen", config_file_path])

if run_cmd_checked(["git", "status", "--porcelain"], capture_output=True).stdout:
    run_cmd_checked(["git", "status"])
    fatal_err("""
The protobuf rust files are outdated.
You can fix this yourself by running cargo run --bin protobuf-gen <APP_SERVICES_ROOT>/tools/protobuf_files.toml
    """)
Esempio n. 2
0
args = parser.parse_args()
base_branch = args.base_branch
remote = args.remote
release_type = args.release_type

# Constants
BUILDCONFIG_FILE = ".buildconfig-android.yml"
BUILDCONFIG_VERSION_FIELD = "libraryVersion"
UNRELEASED_CHANGES_FILE = "CHANGES_UNRELEASED.md"
CHANGELOG_FILE = "CHANGELOG.md"

# 1. Create a new branch based on the branch we want to release from.

ensure_working_tree_clean()

step_msg(f"Updating remote {remote}")
run_cmd_checked(["git", "remote", "update", remote])

temp_branch = f"prepare-release-from-{base_branch}"
step_msg(f"Checking out candidate release branch from {base_branch}")
run_cmd_checked([
    "git", "checkout", "-b", temp_branch, "--no-track",
    f"{remote}/{base_branch}"
])

# 2. Calculate new version number based on what's in the base branch.

with open(BUILDCONFIG_FILE, "r") as stream:
    buildConfig = yaml.safe_load(stream)

cur_version = buildConfig[BUILDCONFIG_VERSION_FIELD]
                    help="Run the following action once a-c is set up.")

DEFAULT_REMOTE_REPO_URL="https://github.com/mozilla-mobile/android-components.git"

args = parser.parse_args()
local_repo_path = args.use_local_repo
remote_repo_url = args.remote_repo_url
branch = args.branch
action = args.action

repo_path = local_repo_path
if repo_path is None:
    repo_path = tempfile.mkdtemp(suffix="-a-c")
    if remote_repo_url is None:
        remote_repo_url = DEFAULT_REMOTE_REPO_URL
    step_msg(f"Cloning {remote_repo_url}")
    run_cmd_checked(["git", "clone", remote_repo_url, repo_path])
    if branch is not None:
        run_cmd_checked(["git", "checkout", branch], cwd=repo_path)
elif branch is not None:
    fatal_err("Cannot specify fenix branch when using a local repo; check it out locally and try again.")

step_msg(f"Configuring {repo_path} to autopublish appservices")
set_gradle_substitution_path(repo_path, "autoPublish.application-services.dir", find_app_services_root())

if action == "do-nothing":
    exit(0)
elif action == "run-tests" or action is None:
    # There are a lot of non-app-services-related components and we don't want to run all their tests.
    # Read the build config to find which projects actually depend on appservices.
    # It's a bit gross but it makes the tests run faster!
Esempio n. 4
0
parser.add_argument(
    "--remote",
    default="origin",
    help=
    "The remote name that corresponds to the Application Services main repository."
)

args = parser.parse_args()
remote = args.remote

ensure_working_tree_clean()

today_date = datetime.today().strftime("%Y-%m-%d")
branch_name = f"cargo-update-{today_date}"

step_msg(f"Check if branch {branch_name} already exists")

res = subprocess.run(
    ["git", "show-ref", "--verify", f"refs/heads/{branch_name}"],
    capture_output=True)

if res.returncode == 0:
    fatal_err(f"The branch {branch_name} already exists!")

step_msg(f"Updating remote {remote}")
run_cmd_checked(["git", "remote", "update", remote])

step_msg(f"Creating branch {branch_name}")
run_cmd_checked(
    ["git", "checkout", "-b", branch_name, "--no-track", f"{remote}/main"])
args = parser.parse_args()
local_repo_path = args.use_local_repo
remote_repo_url = args.remote_repo_url
local_ac_repo_path = args.use_local_ac_repo
remote_ac_repo_url = args.remote_ac_repo_url
fenix_branch = args.branch
ac_branch = args.branch
action = args.action

repo_path = local_repo_path
if repo_path is None:
    repo_path = tempfile.mkdtemp(suffix="-fenix")
    if remote_repo_url is None:
        remote_repo_url = DEFAULT_REMOTE_REPO_URL
    step_msg(f"Cloning {remote_repo_url}")
    run_cmd_checked(["git", "clone", remote_repo_url, repo_path])
    if fenix_branch is not None:
        run_cmd_checked(["git", "checkout", fenix_branch], cwd=repo_path)
elif fenix_branch is not None:
    fatal_err(
        "Cannot specify fenix branch when using a local repo; check it out locally and try again."
    )

ac_repo_path = local_ac_repo_path
if ac_repo_path is None:
    if remote_ac_repo_url is not None:
        ac_repo_path = tempfile.mkdtemp(suffix="-fenix")
        step_msg(f"Cloning {remote_ac_repo_url}")
        run_cmd_checked(["git", "clone", remote_ac_repo_url, ac_repo_path])
        if ac_branch is not None:
Esempio n. 6
0
DEFAULT_REMOTE_REPO_URL = "https://github.com/mozilla-mobile/firefox-ios.git"

args = parser.parse_args()
firefox_ios_branch = args.branch
local_repo_path = args.use_local_repo
remote_repo_url = args.remote_repo_url
action = args.action

repo_path = local_repo_path

if local_repo_path is None:
    repo_path = tempfile.mkdtemp(suffix="-fxios")
    if remote_repo_url is None:
        remote_repo_url = DEFAULT_REMOTE_REPO_URL
    step_msg(f"Cloning {remote_repo_url}")
    run_cmd_checked(["git", "clone", remote_repo_url, repo_path])
    if firefox_ios_branch is not None:
        run_cmd_checked(["git", "checkout", firefox_ios_branch], cwd=repo_path)
elif firefox_ios_branch is not None:
    fatal_err(
        "Cannot specify branch when using a local repo; check it out locally and try again."
    )

if not Path(repo_path, "Carthage").exists():
    step_msg(
        "Carthage folder not present. Running the firefox-ios bootstrap script"
    )
    run_cmd_checked(["./bootstrap.sh"], cwd=repo_path)
step_msg("Running carthage substitution script")
run_cmd_checked(