GITIGNORED_FILES_THAT_AFFECT_THE_BUILD = ["local.properties"] parser = argparse.ArgumentParser(description="Publish android packages to local maven repo, but only if changed since last publish") parser.parse_args() root_dir = find_app_services_root() if str(root_dir) != os.path.abspath(os.curdir): fatal_err(f"This only works if run from the repo root ({root_dir!r} != {os.path.abspath(os.curdir)!r})") # Calculate a hash reflecting the current state of the repo. contents_hash = hashlib.sha256() contents_hash.update( run_cmd_checked(["git", "rev-parse", "HEAD"], capture_output=True).stdout ) contents_hash.update(b"\x00") # Git can efficiently tell us about changes to tracked files, including # the diff of their contents, if you give it enough "-v"s. changes = run_cmd_checked(["git", "status", "-v", "-v"], capture_output=True).stdout contents_hash.update(changes) contents_hash.update(b"\x00") # But unfortunately it can only tell us the names of untracked # files, and it won't tell us anything about files that are in # .gitignore but can still affect the build. untracked_files = []
#!/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 """)
import argparse from shared import run_cmd_checked, find_app_services_root import re parser = argparse.ArgumentParser( description= "Run firefox iOS Smoke tests if the last commit in a PR contains the [ci smoketest firefox-ios] string." ) parser.add_argument("base_revision", help="The base revision this PR is based upon.") args = parser.parse_args() base_revision = args.base_revision root_dir = find_app_services_root() # CircleCI doesn't fetch the base revision, do it. run_cmd_checked(["git", "fetch", "origin", base_revision], cwd=root_dir) # Find out the commit message of the headmost revision of the PR. commit_msg = run_cmd_checked([ "git", "rev-list", "--format=%B", "--max-count=1", f"{base_revision}..HEAD" ], capture_output=True, text=True, cwd=root_dir).stdout match = re.search("\\[ci smoketest firefox-ios(?:=(.+))?\\]", commit_msg) if match is None: print("Trigger tag not present, exiting.") exit(0) branch = match[1]
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] cur_version_full = f"v{cur_version}"
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! # First, find out what names a-c uses to refer to apservices projects in dependency declarations.
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"]) step_msg("Running cargo update") run_cmd_checked(["cargo", "update"]) while True: step_msg("Regenerating dependency summaries") res = subprocess.run(["./tools/regenerate_dependency_summaries.sh"]) if res.returncode == 0: break print( "It looks like the dependency summary generation script couldn't complete."
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: run_cmd_checked(["git", "checkout", ac_branch], cwd=ac_repo_path)
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( ["./appservices_local_dev.sh", "enable",