Skip to content

Commit

Permalink
Bug 1800542 - Update references to DependenciesPlugin.kt and Gecko.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielluong committed Nov 16, 2022
1 parent 1184a8b commit cb355bc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
20 changes: 10 additions & 10 deletions src/android_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _update_gv_version(
ac_repo, old_gv_version, new_gv_version, branch, channel, author
):
contents = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Gecko.kt", ref=branch
"android-components/plugins/dependencies/src/main/java/Gecko.kt", ref=branch
)
content = contents.decoded_content.decode("utf-8")
new_content = content.replace(
Expand All @@ -85,7 +85,7 @@ def _update_gv_version(

def _update_as_version(ac_repo, old_as_version, new_as_version, branch, author):
contents = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Dependencies.kt", ref=branch
"android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt", ref=branch
)
content = contents.decoded_content.decode("utf-8")
new_content = content.replace(
Expand All @@ -94,7 +94,7 @@ def _update_as_version(ac_repo, old_as_version, new_as_version, branch, author):
)
if content == new_content:
raise Exception(
"Update to Dependencies.kt resulted in no changes: maybe the file was already up to date?"
"Update to DependenciesPlugin.kt resulted in no changes: maybe the file was already up to date?"
)

ac_repo.update_file(
Expand All @@ -111,7 +111,7 @@ def _update_glean_version(
ac_repo, old_glean_version, new_glean_version, branch, author
):
contents = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Dependencies.kt", ref=branch
"android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt", ref=branch
)
content = contents.decoded_content.decode("utf-8")
new_content = content.replace(
Expand All @@ -120,7 +120,7 @@ def _update_glean_version(
)
if content == new_content:
raise Exception(
"Update to Dependencies.kt resulted in no changes: maybe the file was already up to date?"
"Update to DependenciesPlugin.kt resulted in no changes: maybe the file was already up to date?"
)

ac_repo.update_file(
Expand Down Expand Up @@ -218,10 +218,10 @@ def _update_geckoview(
print(f"{ts()} Created branch {pr_branch_name} on {release_branch.commit.sha}")

#
# Update android-components/buildSrc/src/main/java/Gecko.kt
# Update android-components/plugins/dependencies/src/main/java/Gecko.kt
#

print(f"{ts()} Updating android-components/buildSrc/src/main/java/Gecko.kt")
print(f"{ts()} Updating android-components/plugins/dependencies/src/main/java/Gecko.kt")
_update_gv_version(
ac_repo,
current_gv_version,
Expand All @@ -233,7 +233,7 @@ def _update_geckoview(

if current_glean_version != latest_glean_version:
print(
f"{ts()} Updating android-components/buildSrc/src/main/java/Dependencies.kt"
f"{ts()} Updating android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt"
)
_update_glean_version(
ac_repo,
Expand Down Expand Up @@ -348,11 +348,11 @@ def _update_application_services(
print(f"{ts()} Created branch {pr_branch_name} on {release_branch.commit.sha}")

#
# Update android-components/buildSrc/src/main/java/Gecko.kt
# Update android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt
#

print(
f"{ts()} Updating android-components/buildSrc/src/main/java/Dependencies.kt"
f"{ts()} Updating android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt"
)
_update_as_version(
ac_repo, current_as_version, latest_as_version, pr_branch_name, author
Expand Down
12 changes: 6 additions & 6 deletions src/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ def test_match_gv_version():


def test_get_current_gv_version(gh):
repo = gh.get_repo("gabrielluong/firefox-android")
assert get_current_gv_version(repo, "relbot-test") == "106.0.20220915094451"
repo = gh.get_repo("mozilla-mobile/firefox-android")
assert get_current_gv_version(repo, "do-not-delete-use-for-relbot-tests") == "109.0.20221115095444"


def test_match_gv_channel():
assert match_gv_channel(GECKO_KT) == "nightly"


def test_get_current_gv_channel(gh):
repo = gh.get_repo(f"gabrielluong/firefox-android")
assert get_current_gv_channel(repo, "relbot-test") == "nightly"
repo = gh.get_repo(f"mozilla-mobile/firefox-android")
assert get_current_gv_channel(repo, "do-not-delete-use-for-relbot-tests") == "nightly"


ANDROID_COMPONENTS_KT = """
Expand Down Expand Up @@ -346,8 +346,8 @@ def test_get_relevant_ac_versions(gh):


def test_get_current_glean_version(gh):
repo = gh.get_repo(f"gabrielluong/firefox-android")
assert get_current_glean_version(repo, "relbot-test") == "51.2.0"
repo = gh.get_repo(f"mozilla-mobile/firefox-android")
assert get_current_glean_version(repo, "do-not-delete-use-for-relbot-tests") == "51.8.0"


def test_get_latest_glean_version_release(gh):
Expand Down
16 changes: 8 additions & 8 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def match_gv_version(src):
def get_current_gv_version(ac_repo, release_branch_name):
"""Return the current gv version used on the given release branch"""
content_file = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Gecko.kt", ref=release_branch_name
"android-components/plugins/dependencies/src/main/java/Gecko.kt", ref=release_branch_name
)
return match_gv_version(content_file.decoded_content.decode("utf8"))

Expand All @@ -86,7 +86,7 @@ def match_gv_channel(src):
def get_current_gv_channel(ac_repo, release_branch_name):
"""Return the current gv channel used on the given release branch"""
content_file = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Gecko.kt", ref=release_branch_name
"android-components/plugins/dependencies/src/main/java/Gecko.kt", ref=release_branch_name
)
return match_gv_channel(content_file.decoded_content.decode("utf8"))

Expand Down Expand Up @@ -310,36 +310,36 @@ def validate_as_version(v):


def match_as_version(src):
"""Find the A-S version in the contents of the given Dependencies.kt file."""
"""Find the A-S version in the contents of the given DependenciesPlugin.kt file."""
if match := re.compile(
r'const val mozilla_appservices = "([^"]*)"', re.MULTILINE
).search(src):
return validate_as_version(match[1])
raise Exception(f"Could not match mozilla_appservices in Dependencies.kt")
raise Exception(f"Could not match mozilla_appservices in DependenciesPlugin.kt")


def get_current_as_version(ac_repo, release_branch_name):
"""Return the current as version used on the given release branch"""
content_file = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Dependencies.kt",
"android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt",
ref=release_branch_name,
)
return match_as_version(content_file.decoded_content.decode("utf8"))


def match_glean_version(src):
"""Find the Glean version in the contents of the given Dependencies.kt file."""
"""Find the Glean version in the contents of the given DependenciesPlugin.kt file."""
if match := re.compile(
rf'const val mozilla_glean = "([^"]*)"', re.MULTILINE
).search(src):
return validate_as_version(match[1])
raise Exception(f"Could not match glean in Dependencies.kt")
raise Exception(f"Could not match glean in DependenciesPlugin.kt")


def get_current_glean_version(ac_repo, release_branch_name):
"""Return the current Glean version used on the given release branch"""
content_file = ac_repo.get_contents(
"android-components/buildSrc/src/main/java/Dependencies.kt",
"android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt",
ref=release_branch_name,
)
return match_glean_version(content_file.decoded_content.decode("utf8"))
Expand Down

0 comments on commit cb355bc

Please sign in to comment.