Skip to content

Commit

Permalink
Add graphs in sorted order and modify trigger graphs
Browse files Browse the repository at this point in the history
Signed-off-by: Charan-Sharan <[email protected]>
  • Loading branch information
Charan-Sharan committed Jul 19, 2024
1 parent 5a527bc commit ec5771e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/Actions-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ jobs:
with open( markdown ,'a') as markdownFile:
markdownFile.write('# GitHub Actions Workflow Overview\n\n')
for file in workflowDetails:
sortedDictionary=dict(sorted(workflowDetails.items(),key=lambda item:item[1]['name']))
for file in sortedDictionary:
uniqFileName=workflowDetails[file]['name']
uniqFileName=uniqFileName.replace(' ','_') #replace spaces with underscore
uniqFileName=uniqFileName.replace('(','_') #replace parenthesis with underscore
Expand All @@ -187,18 +188,18 @@ jobs:
fileBlock=f"{uniqFileName}[\"{workflowDetails[file]['name']}[{file}]\"]"
jobs=workflowDetails[file]['jobs']
markdownFile.write('```mermaid\n')
markdownFile.write('graph LR;')
markdownFile.write('\nflowchart LR\n')
for job in jobs:
needs=jobs[job]['needs']
needs=needs.replace('[','')
needs=needs.replace(']','')
needs=needs.replace(' ','')
if len(needs) == 0:
markdownFile.write(f"\n{fileBlock}--->{job}({job})")
markdownFile.write(f"\n {fileBlock} ---> {job}({job})")
else:
needs=list(needs.split(','))
for need in needs:
markdownFile.write(f"\n{need}({need})--needs-->{job}({job})")
markdownFile.write(f"\n {need}({need}) --needs--> {job}({job})")
uses=jobs[job]['uses']
if uses!="":
uses=uses.split('/')[-1]
Expand All @@ -207,29 +208,28 @@ jobs:
inputs=inputs.replace('\"','') #remove " (double quotes)
inputs=inputs.replace("\'",'') #remove ' (single quotes)
if len(inputs)!=0:
markdownFile.write(f"\n{job}(\"{job}\ninputs:[{inputs}]\")--uses-->{uses}(\"{workflowDetails[uses]['name']}[{uses}]\")")
markdownFile.write(f"\n {job}(\"{job}\ninputs:[{inputs}]\") --uses--> {uses}(\"{workflowDetails[uses]['name']}[{uses}]\")")
else:
markdownFile.write(f"\n{job}({job})--uses-->{uses}")
markdownFile.write(f"\n {job}({job}) --uses--> {uses}")
markdownFile.write('\n```\n\n')
markdownFile.write('\n\n```\n\n')
with open( markdown ,'a') as markdownFile:
markdownFile.write('## GitHub Actions Trigger Overview\n')
markdownFile.write('\n```mermaid')
markdownFile.write('\nmindmap')
markdownFile.write('\n ((HPCC Platform<br>GitHub Actions))')
# triggersList=['push','pull_request','workflow_dispatch','workflow_call','schedule']
triggersList=set()
for file in workflowDetails:
for trigger in workflowDetails[file]['trigger']:
triggersList.add(trigger) #triggersList contains unique list of all types of triggers used in the workflow file
for trigger in triggersList:
markdownFile.write(f'\n {trigger}(**{trigger}**)')
for file in workflowDetails:
for trigger in sorted(triggersList):
markdownFile.write('\n```mermaid\n')
markdownFile.write('\nflowchart TB\n')
markdownFile.write(f'\n subgraph {trigger.upper()}')
for file in sortedDictionary:
if trigger in workflowDetails[file]['trigger']:
markdownFile.write(f'\n {file}')
markdownFile.write('\n```\n')
markdownFile.write(f'\n {trigger} ---> {file}[\"{workflowDetails[file]["name"]}[{file}]\"]')
markdownFile.write('\n end\n')
markdownFile.write('\n```\n')
shell: python

- name: Upload Artifact
Expand Down

0 comments on commit ec5771e

Please sign in to comment.