diff --git a/obs_common/update_obs_common.py b/obs_common/update_obs_common.py deleted file mode 100644 index 13bc389..0000000 --- a/obs_common/update_obs_common.py +++ /dev/null @@ -1,42 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. - -import re -import sys -from pathlib import Path - -import requests - -REQUIREMENT_PATTERN = re.compile("^obs-common @ https://.*$", re.MULTILINE) - - -def main(): - latest_release = requests.get( - "https://api.github.com/repos/mozilla-services/obs-common/releases/latest", - timeout=5, - ).json() - assets_url = latest_release["assets_url"] - assets = requests.get(assets_url, timeout=5).json() - for asset in assets: - if asset["name"].endswith(".whl"): - break - else: - print("could not find wheel in latest release assets", file=sys.stderr) - return 1 - download_url = asset["browser_download_url"] - req_in = Path("requirements.in") - req_in_text = req_in.read_text() - if download_url in req_in_text: - return 0 - if not REQUIREMENT_PATTERN.findall(req_in_text): - print("could not find obs-common in requirements.in") - return 1 - req_in.write_text( - REQUIREMENT_PATTERN.sub(f"obs-common @ {download_url}", req_in_text, count=1) - ) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/pyproject.toml b/pyproject.toml index 3f79fba..ecc890b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,6 @@ dynamic = ["version"] [project.scripts] license-check = "obs_common.license_check:main" service-status = "obs_common.service_status:main" -update-obs-common = "obs_common.update_obs_common:main" gcs-cli = "obs_common.gcs_cli:main" pubsub-cli = "obs_common.pubsub_cli:main" sentry-wrap = "obs_common.sentry_wrap:cli_main" diff --git a/tests/test_update_obs_common.py b/tests/test_update_obs_common.py deleted file mode 100644 index c56b90c..0000000 --- a/tests/test_update_obs_common.py +++ /dev/null @@ -1,40 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. -import os -import re - -import pytest - -from obs_common import update_obs_common - - -@pytest.fixture -def tmp_cwd(tmp_path): - orig_wd = os.getcwd() - os.chdir(tmp_path) - try: - yield tmp_path - finally: - os.chdir(orig_wd) - - -def test_update_from_old(tmp_cwd): - req = tmp_cwd / "requirements.in" - req.write_text("obs-common @ https://path/to/package.whl\n") - EXPECT_PATTERN = re.compile( - "obs-common @ https://github.com/mozilla-services/obs-common/" - "releases/download/[^/]+/obs_common-[^-]+-py2.py3-none-any.whl\n", - re.MULTILINE, - ) - assert update_obs_common.main() == 0 - assert EXPECT_PATTERN.fullmatch(req.read_text()) - - -def test_update_idempotent(tmp_cwd): - req = tmp_cwd / "requirements.in" - req.write_text("obs-common @ https://path/to/package.whl\n") - assert update_obs_common.main() == 0 - expect = req.read_text() - assert update_obs_common.main() == 0 - assert req.read_text() == expect