This commit is contained in:
Dobromir Popov
2024-07-29 18:20:51 +03:00
parent e570f0a1b2
commit a2457e8006
6 changed files with 185 additions and 11 deletions

View File

@ -34,10 +34,15 @@ if 'branches' in config:
# Check for inactive branches and configurations in the comments
lines = appveyor_yml.splitlines()
for i, line in enumerate(lines):
# Check for commented branches
if re.match(r'#\s*-\s*(\w+)', line):
inactive_configs.setdefault(lines[i-1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_'))
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().replace('-', '_'))
branch_name = re.findall(r'#\s*-\s*(\w+)', line)[0]
if 'branches' in lines[i - 1] and 'only:' in lines[i - 2]:
inactive_branches.append(branch_name.replace('-', '_'))
# Check for commented configurations
if re.match(r'#\s*-\s*(\w+)', line):
inactive_configs.setdefault(lines[i - 1].strip().split()[1], []).append(re.findall(r'#\s*-\s*(\w+)', line)[0].replace('-', '_'))
# Extract deployment configurations
if 'deploy' in config:
@ -67,14 +72,18 @@ for branch in branches.keys():
for branch, configs in branches.items():
branch_id = branch.replace('-', '_')
for idx, config in enumerate(configs):
config_id = f"{branch_id}{idx+1}"
config_id = f"{branch_id}{idx + 1}"
mermaid_graph += f" {branch_id} --> {config_id}[{config}]\n"
# Add deployments to the configurations
for deploy in deployments.get(branch, []):
configuration = deploy.get('configuration')
if configuration == config:
service = deploy.get('service', '')
mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('on', {}).get('configuration', '')} on {branch}]\n"
# Add deployments to the configurations
for branch, deploys in deployments.items():
branch_id = branch.replace('-', '_')
for deploy in deploys:
configuration = deploy.get('configuration')
if configuration:
config_id = f"{branch_id}{branches[branch].index(configuration) + 1}"
service_id = deploy.get('website', '').replace('-', '_')
mermaid_graph += f" {config_id} --> {service_id}[{deploy.get('provider', '')} on {branch}]\n"
# Highlight inactive branches and configurations with a dotted style
for branch in inactive_branches: