mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Reading GITHUB_OUTPUT from env var.
This commit is contained in:
85
.github/workflows/Parameters.yml
vendored
85
.github/workflows/Parameters.yml
vendored
@@ -75,61 +75,75 @@ jobs:
|
||||
id: params
|
||||
shell: python
|
||||
run: |
|
||||
from os import getenv
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
from textwrap import dedent
|
||||
|
||||
name = "${{ inputs.name }}".strip()
|
||||
pythonVersion = "${{ inputs.python_version }}".strip()
|
||||
systems = "${{ inputs.system_list }}".strip()
|
||||
versions = "${{ inputs.python_version_list }}".strip()
|
||||
include_list = "${{ inputs.include_list }}".strip()
|
||||
exclude_list = "${{ inputs.exclude_list }}".strip()
|
||||
|
||||
|
||||
name = "${{ inputs.name }}".strip()
|
||||
python_version = "${{ inputs.python_version }}".strip()
|
||||
systems = "${{ inputs.system_list }}".strip()
|
||||
versions = "${{ inputs.python_version_list }}".strip()
|
||||
include_list = "${{ inputs.include_list }}".strip()
|
||||
exclude_list = "${{ inputs.exclude_list }}".strip()
|
||||
|
||||
currentMSYS2Version = "3.10"
|
||||
currentAlphaVersion = "3.12"
|
||||
currentAlphaRelease = "3.12.0-alpha.1"
|
||||
|
||||
|
||||
artifact_names = {
|
||||
"unittesting": f"{name}-TestReport",
|
||||
"codecoverage": f"{name}-Coverage",
|
||||
"statictyping": f"{name}-Typing",
|
||||
"package": f"{name}-Package",
|
||||
"documentation": f"{name}-Documentation",
|
||||
}
|
||||
|
||||
# Deprecated structure
|
||||
params = {
|
||||
'python_version': pythonVersion,
|
||||
'python_version': python_version,
|
||||
'artifacts': {
|
||||
'unittesting': f"{name}-TestReport",
|
||||
'coverage': f"{name}-Coverage",
|
||||
'typing': f"{name}-Typing",
|
||||
'package': f"{name}-Package",
|
||||
'doc': f"{name}-Documentation",
|
||||
'unittesting': f"{artifact_names['unittesting']}",
|
||||
'coverage': f"{artifact_names['codecoverage']}",
|
||||
'typing': f"{artifact_names['statictyping']}",
|
||||
'package': f"{artifact_names['package']}",
|
||||
'doc': f"{artifact_names['documentation']}",
|
||||
}
|
||||
}
|
||||
print(f"::set-output name=params::{params!s}")
|
||||
|
||||
print("Parameters:")
|
||||
pprint(params, indent=2)
|
||||
print(f" python_version: {python_version}")
|
||||
print(f" artifact_names:")
|
||||
for id, name in artifact_names.items():
|
||||
print(f" {id:>14}: {name}")
|
||||
|
||||
if systems == "":
|
||||
print("::error title=Parameter::system_list is empty.")
|
||||
else:
|
||||
systems = [sys.strip() for sys in systems.split(" ")]
|
||||
|
||||
|
||||
if versions == "":
|
||||
versions = [ pythonVersion ]
|
||||
versions = [ python_version ]
|
||||
else:
|
||||
versions = [ver.strip() for ver in versions.split(" ")]
|
||||
|
||||
|
||||
if include_list == "":
|
||||
includes = []
|
||||
else:
|
||||
includes = [tuple(include.strip().split(":")) for include in include_list.split(" ")]
|
||||
|
||||
|
||||
if exclude_list == "":
|
||||
excludes = []
|
||||
else:
|
||||
excludes = [exclude.strip() for exclude in exclude_list.split(" ")]
|
||||
|
||||
|
||||
if "3.6" in versions:
|
||||
print("::warning title=Deprecated::Support for Python 3.6 ended in 2021.12.23.")
|
||||
if "msys2" in systems:
|
||||
print("::warning title=Deprecated::System 'msys2' will be replaced by 'mingw64'.")
|
||||
if currentAlphaVersion in versions:
|
||||
print(f"::notice title=Experimental::Python {currentAlphaVersion} ({currentAlphaRelease}) is a pre-release.")
|
||||
|
||||
|
||||
data = {
|
||||
# Python and PyPy versions supported by "setup-python" action
|
||||
'python': {
|
||||
@@ -160,14 +174,14 @@ jobs:
|
||||
'ucrt64': { 'icon': '🟨', 'name': 'Windows+MSYS2 (x86-64) - UCRT64' },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print("includes:")
|
||||
for system,version in includes:
|
||||
print(f"- {system}:{version}")
|
||||
print("excludes:")
|
||||
for exclude in excludes:
|
||||
print(f"- {exclude}")
|
||||
|
||||
|
||||
combinations = [
|
||||
(system, version)
|
||||
for system in systems
|
||||
@@ -181,9 +195,9 @@ jobs:
|
||||
if system in data['sys']
|
||||
and version in data['python']
|
||||
]
|
||||
#print("combinations:")
|
||||
#print(combinations)
|
||||
|
||||
print("combinations:")
|
||||
print(combinations)
|
||||
|
||||
jobs = [
|
||||
{
|
||||
'sysicon': data['sys'][system]['icon'],
|
||||
@@ -208,18 +222,21 @@ jobs:
|
||||
}
|
||||
for runtime, version in combinations if runtime not in data['sys']
|
||||
]
|
||||
print(f'::set-output name=python_jobs::{jobs!s}')
|
||||
print("${{ GITHUB_OUTPUT }}")
|
||||
with Path("${{ GITHUB_OUTPUT }}").open("a+") as f:
|
||||
f.write(f"python_jobs2={jobs!s}")
|
||||
|
||||
|
||||
# Format jobs as list of dictionaries
|
||||
buffer = ""
|
||||
for job in jobs:
|
||||
buffer += f" {{ " + ", ".join([f"\"{key}\": \"{value}\"" for key, value in job.items()]) + f" }},\n"
|
||||
|
||||
|
||||
print(dedent(f"""\
|
||||
Python jobs:
|
||||
[
|
||||
{buffer} ]
|
||||
"""))
|
||||
|
||||
# Write jobs to special file
|
||||
with Path(getenv("GITHUB_OUTPUT")).open("a+") as f:
|
||||
f.write(f"python_version={python_version}")
|
||||
f.write(f"artifact_names={params['artifacts']!s}")
|
||||
f.write(f"params={params!s}")
|
||||
f.write(f"python_jobs={jobs!s}")
|
||||
|
||||
Reference in New Issue
Block a user