Copy releases from products frontmatter (#465)
Copy releases, without their properties, from product data (frontmatter) to release data. This script is not intended to be declared in the frontmatter: it is for internal use only. It executes before all other scripts, and helps the following scripts to work with releases.
This commit is contained in:
12
src/_copy_product_releases.py
Normal file
12
src/_copy_product_releases.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from common import releasedata
|
||||
|
||||
"""Copy releases, without their properties, from product data (frontmatter) to release data.
|
||||
|
||||
This script is not intended to be declared in the frontmatter: it is for internal use only.
|
||||
It executes before all other scripts, and helps the following scripts to work with releases.
|
||||
"""
|
||||
|
||||
frontmatter, _ = releasedata.parse_argv(ignore_auto_config=True)
|
||||
with releasedata.ProductData(frontmatter.name) as product_data:
|
||||
for frontmatter_release in frontmatter.get_releases():
|
||||
product_data.get_release(frontmatter_release.get("releaseCycle"))
|
||||
@@ -193,7 +193,7 @@ class ProductData:
|
||||
def config_from_argv() -> endoflife.AutoConfig:
|
||||
return parse_argv()[1]
|
||||
|
||||
def parse_argv() -> tuple[endoflife.ProductFrontmatter, endoflife.AutoConfig]:
|
||||
def parse_argv(ignore_auto_config: bool = False) -> tuple[endoflife.ProductFrontmatter, endoflife.AutoConfig]:
|
||||
parser = argparse.ArgumentParser(description=sys.argv[0])
|
||||
parser.add_argument('-p', '--product', required=True, help='path to the product')
|
||||
parser.add_argument('-m', '--method', required=True, help='method to filter by')
|
||||
@@ -205,4 +205,5 @@ def parse_argv() -> tuple[endoflife.ProductFrontmatter, endoflife.AutoConfig]:
|
||||
logging.basicConfig(format="%(message)s", level=(logging.DEBUG if args.verbose else logging.INFO))
|
||||
|
||||
product = endoflife.ProductFrontmatter(Path(args.product))
|
||||
return product, product.auto_config(args.method, args.url)
|
||||
auto_config = None if ignore_auto_config else product.auto_config(args.method, args.url)
|
||||
return product, auto_config
|
||||
|
||||
@@ -105,13 +105,18 @@ def run_scripts(summary: GitHubStepSummary, products: list[ProductFrontmatter])
|
||||
exec_summary = ScriptExecutionSummary()
|
||||
|
||||
for product in products:
|
||||
if not product.has_auto_configs():
|
||||
continue
|
||||
configs = product.auto_configs()
|
||||
|
||||
if not configs:
|
||||
continue # skip products without auto configs
|
||||
|
||||
# Add default configs
|
||||
configs = [AutoConfig(product.name, {"_copy_product_releases": ""})] + configs
|
||||
|
||||
with GitHubGroup(product.name):
|
||||
try:
|
||||
__delete_data(product)
|
||||
for config in product.auto_configs():
|
||||
for config in configs:
|
||||
success = __run_script(product, config, exec_summary)
|
||||
if not success:
|
||||
__revert_data(product)
|
||||
|
||||
Reference in New Issue
Block a user