|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +# -------------------------------------------------------------------------------------------- |
| 4 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 5 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 6 | +# -------------------------------------------------------------------------------------------- |
| 7 | + |
| 8 | +import argparse |
| 9 | +import sys |
| 10 | +import os |
| 11 | + |
| 12 | +from ci_tools.environment_exclusions import get_config_setting |
| 13 | + |
| 14 | +root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..")) |
| 15 | + |
| 16 | +def verify_ci_enabled(package_name: str, package_path: str) -> None: |
| 17 | + """Verifies that ci_enabled=false is not present in the package's pyproject.toml. |
| 18 | + This prevents releasing packages that have disabled their CI. |
| 19 | + """ |
| 20 | + |
| 21 | + ci_enabled = get_config_setting(package_path, "ci_enabled") |
| 22 | + if ci_enabled is False: |
| 23 | + print( |
| 24 | + f"ci_enabled is set to false in {package_name}/pyproject.toml. " \ |
| 25 | + "You must remove this setting before releasing the package." |
| 26 | + ) |
| 27 | + sys.exit(1) |
| 28 | + |
| 29 | + |
| 30 | +if __name__ == "__main__": |
| 31 | + parser = argparse.ArgumentParser( |
| 32 | + description="Verifies ci_enabled=true or is not present in the package's pyproject.toml, Called from DevOps YAML Pipeline" |
| 33 | + ) |
| 34 | + |
| 35 | + parser.add_argument( |
| 36 | + "--package-name", |
| 37 | + required=True, |
| 38 | + help="name of package (accepts both formats: azure-service-package and azure_service_package)", |
| 39 | + ) |
| 40 | + parser.add_argument( |
| 41 | + "--service", |
| 42 | + required=True, |
| 43 | + help="name of the service for which to set the dev build id (e.g. keyvault)", |
| 44 | + ) |
| 45 | + |
| 46 | + args = parser.parse_args() |
| 47 | + |
| 48 | + package_name = args.package_name.replace("_", "-") |
| 49 | + path_to_setup = os.path.join(root_dir, "sdk", args.service, package_name, "setup.py") |
| 50 | + verify_ci_enabled(package_name, path_to_setup) |
0 commit comments