fixes. added appbeyor script and diagram (wip)

This commit is contained in:
Dobromir Popov
2024-07-16 14:24:47 +03:00
parent 7568039e16
commit d7672c1959
3 changed files with 137 additions and 15 deletions

View File

@ -0,0 +1,85 @@
import yaml
# Load the YAML content from the file
with open('appveyor.yml', 'r') as file:
appveyor_yml = file.read()
# Parsing the YAML content
config = yaml.safe_load(appveyor_yml)
# Extract branches and configurations from the YAML
branches = {}
deployments = {}
inactive_branches = []
# Extract specific branch configurations
if 'for' in config:
for branch_config in config['for']:
branch_names = branch_config.get('branches', {}).get('only', [])
configurations = branch_config.get('configuration', [])
for branch in branch_names:
if branch not in branches:
branches[branch] = []
branches[branch].extend(configurations)
# Manually add common branches and configurations if not already included
if 'branches' in config:
common_branches = config['branches'].get('only', [])
for branch in common_branches:
if branch not in branches:
branches[branch] = config.get('configuration', [])
# Check for inactive branches in the comments
lines = appveyor_yml.splitlines()
for i, line in enumerate(lines):
if line.strip().startswith('#') and i + 2 < len(lines) and 'branches:' in lines[i + 1] and 'only:' in lines[i + 2]:
inactive_branches.append(lines[i + 2].split(':')[1].strip())
# Extract deployment configurations
if 'deploy' in config:
deployments['common'] = config['deploy']
if 'for' in config:
for branch_config in config['for']:
branch_names = branch_config.get('branches', {}).get('only', [])
if 'deploy' in branch_config:
for branch in branch_names:
if branch not in deployments:
deployments[branch] = []
deployments[branch].extend(branch_config['deploy'])
# Generate the Mermaid graph content
mermaid_graph = """
graph TD
A[Common Configuration] --> B[master]
"""
# Add branches to the graph
for branch in branches.keys():
if branch != 'master':
mermaid_graph += f" A --> {branch.replace('-', '_')}\n"
# Add configurations to the branches
for branch, configs in branches.items():
for config in configs:
mermaid_graph += f" {branch.replace('-', '_')} --> {branch.replace('-', '_')}{config}\n"
# Add deployments to the configurations
for branch, deploys in deployments.items():
for deploy in deploys:
configuration = deploy.get('configuration')
website = deploy.get('website')
if configuration and website:
mermaid_graph += f" {branch.replace('-', '_')}{configuration.replace('_', '')} --> {branch.replace('-', '_')}{website.replace('-', '_')}\n"
# Highlight inactive branches
for inactive_branch in inactive_branches:
mermaid_graph += f" style {inactive_branch.replace('-', '_')} fill:#f96,stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5\n"
# Add styles to the graph
mermaid_graph += """
style A fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#bbf,stroke:#333,stroke-width:2px
"""
print(mermaid_graph)