Skip to content

Commit 74af490

Browse files
fix: Correct YAML syntax in update-e2e-status workflow
1 parent 27cbbf7 commit 74af490

1 file changed

Lines changed: 79 additions & 47 deletions

File tree

.github/workflows/update-e2e-status.yml

Lines changed: 79 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ jobs:
2222
with:
2323
ref: main
2424

25-
- name: Get job statuses and update README
25+
- name: Get job statuses
26+
id: get-status
2627
uses: actions/github-script@v7
2728
with:
2829
script: |
29-
const fs = require('fs');
30-
3130
// Get the triggering workflow run or latest run
3231
let runId;
3332
if (context.payload.workflow_run) {
@@ -43,12 +42,15 @@ jobs:
4342
});
4443
if (runs.data.workflow_runs.length === 0) {
4544
console.log('No workflow runs found');
45+
core.setOutput('found', 'false');
4646
return;
4747
}
4848
runId = runs.data.workflow_runs[0].id;
4949
}
5050
5151
console.log(`Processing workflow run: ${runId}`);
52+
core.setOutput('run-id', runId);
53+
core.setOutput('run-url', `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`);
5254
5355
// Get jobs for this run
5456
const jobs = await github.rest.actions.listJobsForWorkflowRun({
@@ -57,60 +59,90 @@ jobs:
5759
run_id: runId
5860
});
5961
60-
// Map job names to their status badges
62+
// Map job names to their status
6163
const jobStatusMap = {
62-
'Python OpenAI Agent': { key: 'python-openai', label: 'Python OpenAI' },
63-
'Node.js OpenAI Agent': { key: 'nodejs-openai', label: 'Node.js OpenAI' },
64-
'.NET Semantic Kernel Agent': { key: 'dotnet-sk', label: '.NET Semantic Kernel' },
65-
'.NET Agent Framework Agent': { key: 'dotnet-af', label: '.NET Agent Framework' }
64+
'Python OpenAI Agent': 'python-openai',
65+
'Node.js OpenAI Agent': 'nodejs-openai',
66+
'.NET Semantic Kernel Agent': 'dotnet-sk',
67+
'.NET Agent Framework Agent': 'dotnet-af'
6668
};
6769
68-
const statuses = {};
6970
for (const job of jobs.data.jobs) {
70-
const mapping = jobStatusMap[job.name];
71-
if (mapping) {
72-
const conclusion = job.conclusion || job.status;
73-
let badge;
74-
if (conclusion === 'success') {
75-
badge = `![${mapping.label}](https://img.shields.io/badge/${encodeURIComponent(mapping.label)}-passing-brightgreen)`;
76-
} else if (conclusion === 'failure') {
77-
badge = `![${mapping.label}](https://img.shields.io/badge/${encodeURIComponent(mapping.label)}-failing-red)`;
78-
} else if (conclusion === 'in_progress' || job.status === 'in_progress') {
79-
badge = `![${mapping.label}](https://img.shields.io/badge/${encodeURIComponent(mapping.label)}-running-yellow)`;
80-
} else {
81-
badge = `![${mapping.label}](https://img.shields.io/badge/${encodeURIComponent(mapping.label)}-pending-lightgrey)`;
82-
}
83-
statuses[mapping.key] = badge;
84-
console.log(`${job.name}: ${conclusion} -> ${badge}`);
71+
const key = jobStatusMap[job.name];
72+
if (key) {
73+
const conclusion = job.conclusion || job.status || 'unknown';
74+
core.setOutput(key, conclusion);
75+
console.log(`${job.name}: ${conclusion}`);
8576
}
8677
}
87-
88-
// Read current README
89-
let readme = fs.readFileSync('README.md', 'utf8');
90-
91-
// Generate new status table
92-
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
93-
const newTable = `## E2E Test Status
78+
core.setOutput('found', 'true');
79+
core.setOutput('date', new Date().toISOString().split('T')[0]);
9480
95-
| Sample | Status |
96-
|--------|--------|
97-
| Python OpenAI | ${statuses['python-openai'] || '![Python OpenAI](https://img.shields.io/badge/Python%20OpenAI-unknown-lightgrey)'} |
98-
| Node.js OpenAI | ${statuses['nodejs-openai'] || '![Node.js OpenAI](https://img.shields.io/badge/Node.js%20OpenAI-unknown-lightgrey)'} |
99-
| .NET Semantic Kernel | ${statuses['dotnet-sk'] || '![.NET SK](https://img.shields.io/badge/.NET%20SK-unknown-lightgrey)'} |
100-
| .NET Agent Framework | ${statuses['dotnet-af'] || '![.NET AF](https://img.shields.io/badge/.NET%20AF-unknown-lightgrey)'} |
81+
- name: Update README
82+
if: steps.get-status.outputs.found == 'true'
83+
env:
84+
PYTHON_STATUS: ${{ steps.get-status.outputs.python-openai }}
85+
NODEJS_STATUS: ${{ steps.get-status.outputs.nodejs-openai }}
86+
DOTNET_SK_STATUS: ${{ steps.get-status.outputs.dotnet-sk }}
87+
DOTNET_AF_STATUS: ${{ steps.get-status.outputs.dotnet-af }}
88+
RUN_URL: ${{ steps.get-status.outputs.run-url }}
89+
UPDATE_DATE: ${{ steps.get-status.outputs.date }}
90+
run: |
91+
python3 << 'EOF'
92+
import os
93+
import re
94+
95+
def create_badge(name, status):
96+
encoded_name = name.replace(' ', '%20').replace('.', '%2E')
97+
if status == 'success':
98+
return f'![{name}](https://img.shields.io/badge/{encoded_name}-passing-brightgreen)'
99+
elif status == 'failure':
100+
return f'![{name}](https://img.shields.io/badge/{encoded_name}-failing-red)'
101+
elif status == 'in_progress':
102+
return f'![{name}](https://img.shields.io/badge/{encoded_name}-running-yellow)'
103+
else:
104+
return f'![{name}](https://img.shields.io/badge/{encoded_name}-unknown-lightgrey)'
105+
106+
python_badge = create_badge('Python OpenAI', os.environ.get('PYTHON_STATUS', 'unknown'))
107+
nodejs_badge = create_badge('Node.js OpenAI', os.environ.get('NODEJS_STATUS', 'unknown'))
108+
dotnet_sk_badge = create_badge('.NET SK', os.environ.get('DOTNET_SK_STATUS', 'unknown'))
109+
dotnet_af_badge = create_badge('.NET AF', os.environ.get('DOTNET_AF_STATUS', 'unknown'))
110+
run_url = os.environ.get('RUN_URL', '#')
111+
update_date = os.environ.get('UPDATE_DATE', 'unknown')
112+
113+
new_section = f'''## E2E Test Status
101114
102-
*Last updated: ${new Date().toISOString().split('T')[0]} | [View Run](${runUrl})*`;
103-
104-
// Replace the status section
105-
const statusRegex = /## E2E Test Status[\s\S]*?\n(?=\n>|$)/;
106-
if (statusRegex.test(readme)) {
107-
readme = readme.replace(statusRegex, newTable + '\n');
108-
}
109-
110-
fs.writeFileSync('README.md', readme);
111-
console.log('README updated successfully');
115+
| Sample | Status |
116+
|--------|--------|
117+
| Python OpenAI | {python_badge} |
118+
| Node.js OpenAI | {nodejs_badge} |
119+
| .NET Semantic Kernel | {dotnet_sk_badge} |
120+
| .NET Agent Framework | {dotnet_af_badge} |
121+
122+
*Last updated: {update_date} | [View Run]({run_url})*
123+
124+
'''
125+
126+
# Remove leading spaces from heredoc
127+
new_section = '\n'.join(line.lstrip() for line in new_section.split('\n'))
128+
129+
with open('README.md', 'r') as f:
130+
content = f.read()
131+
132+
# Pattern to match the E2E Test Status section until the next section
133+
pattern = r'## E2E Test Status\n.*?(?=\n> ####|\n## [^E]|\Z)'
134+
135+
if re.search(pattern, content, re.DOTALL):
136+
content = re.sub(pattern, new_section, content, flags=re.DOTALL)
137+
with open('README.md', 'w') as f:
138+
f.write(content)
139+
print('README updated successfully')
140+
else:
141+
print('E2E Test Status section not found')
142+
EOF
112143
113144
- name: Commit and push changes
145+
if: steps.get-status.outputs.found == 'true'
114146
run: |
115147
git config --local user.email "github-actions[bot]@users.noreply.github.com"
116148
git config --local user.name "github-actions[bot]"

0 commit comments

Comments
 (0)