Skip to content

Commit

Permalink
infra: prerelease dep checking on release (#23269)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Jul 16, 2024
1 parent 616196c commit 6c3e65a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/scripts/check_prerelease_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys
import tomllib

if __name__ == "__main__":
# Get the TOML file path from the command line argument
toml_file = sys.argv[1]

# read toml file
with open(toml_path, "rb") as file:
toml_data = tomllib.load(file)

# see if we're releasing an rc
version = toml_data["tool"]["poetry"]["version"]
releasing_rc = "rc" in version

# if not, iterate through dependencies and make sure none allow prereleases
if not releasing_rc:
dependencies = toml_data["tool"]["poetry"]["dependencies"]
for lib in dependencies:
dep_version = dependencies[lib]
dep_version_string = (
dep_version["version"] if isinstance(dep_version, dict) else dep_version
)

if "rc" in dep_version_string:
raise ValueError(
f"Dependency {lib} has a prerelease version. Please remove this."
)

if isinstance(dep_version, dict) and dep_version.get(
"allow-prereleases", False
):
raise ValueError(
f"Dependency {lib} has allow-prereleases set to true. Please remove this."
)
5 changes: 5 additions & 0 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ jobs:
run: make tests
working-directory: ${{ inputs.working-directory }}

- name: Check for prerelease versions
working-directory: ${{ inputs.working-directory }}
run: |
poetry run python $GITHUB_WORKSPACE/.github/scripts/check_prerelease_dependencies.py pyproject.toml
- name: Get minimum versions
working-directory: ${{ inputs.working-directory }}
id: min-version
Expand Down

0 comments on commit 6c3e65a

Please sign in to comment.