Skip to content

Commit 13b23ed

Browse files
authored
Add workflowSummary.yml workflow (#1577)
Add a workflow that scans all Eclipse GLSP repositories and creates a summary of all workflows executed on the default branch (master/main)
1 parent 9e4723e commit 13b23ed

File tree

2 files changed

+237
-0
lines changed

2 files changed

+237
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Initialize counters
5+
total_repos=0
6+
total_workflows=0
7+
total_failed=0
8+
total_success=0
9+
failed_jobs=()
10+
repo_details=()
11+
all_workflows=()
12+
13+
echo "# Eclipse GLSP Workflow Status"
14+
echo ""
15+
echo "Overview of all Workflows in the Eclipse GLSP organization running on master or main"
16+
echo ""
17+
echo "Generated on: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
18+
echo ""
19+
20+
# Get all repositories in eclipse-glsp organization
21+
echo "Fetching repositories from eclipse-glsp organization..."
22+
repos=$(gh api --paginate "orgs/eclipse-glsp/repos" --jq '.[].name' | sort)
23+
24+
# For testing, limit to first few repos if TEST_MODE is set
25+
if [ "$TEST_MODE" = "true" ]; then
26+
repos=$(echo "$repos" | head -3)
27+
echo "TEST MODE: Processing only first 3 repositories"
28+
fi
29+
30+
# Process each repository
31+
for repo in $repos; do
32+
echo "Processing repository: $repo"
33+
total_repos=$((total_repos + 1))
34+
35+
# Get default branch for this repo
36+
default_branch=$(gh api "repos/eclipse-glsp/$repo" --jq '.default_branch')
37+
38+
# Override default branch for specific repos
39+
case "$repo" in
40+
"glsp-playwright"|"glsp-server-node")
41+
# These repos might have different default branches, but we'll use the detected one
42+
;;
43+
*)
44+
# Most repos use master as default
45+
if [ "$default_branch" != "master" ]; then
46+
echo " Note: $repo uses '$default_branch' as default branch (not master)"
47+
fi
48+
;;
49+
esac
50+
51+
# Get workflows for this repository (exclude Dependabot Updates workflows)
52+
workflows=$(gh api "repos/eclipse-glsp/$repo/actions/workflows" --jq '.workflows[] | select(.state == "active" and .name != "Dependabot Updates") | {id: .id, name: .name, path: .path}')
53+
54+
if [ -z "$workflows" ]; then
55+
echo " No active workflows found in $repo"
56+
repo_details+=("## $repo|No active workflows found")
57+
continue
58+
fi
59+
60+
repo_workflows=()
61+
repo_workflow_count=0
62+
63+
# Process each workflow
64+
while IFS= read -r workflow; do
65+
if [ -z "$workflow" ]; then
66+
continue
67+
fi
68+
69+
workflow_id=$(echo "$workflow" | jq -r '.id')
70+
workflow_name=$(echo "$workflow" | jq -r '.name')
71+
workflow_path=$(echo "$workflow" | jq -r '.path')
72+
73+
repo_workflow_count=$((repo_workflow_count + 1))
74+
total_workflows=$((total_workflows + 1))
75+
76+
echo " Processing workflow: $workflow_name (ID: $workflow_id)"
77+
78+
# Get the latest workflow run on the default branch, excluding dependabot
79+
latest_run=$(gh api "repos/eclipse-glsp/$repo/actions/workflows/$workflow_id/runs?per_page=10&branch=$default_branch" \
80+
--jq ".workflow_runs[] | select(.actor.login != \"dependabot[bot]\") | {
81+
id: .id,
82+
status: .status,
83+
conclusion: .conclusion,
84+
created_at: .created_at,
85+
html_url: .html_url,
86+
head_sha: .head_sha,
87+
actor: .actor.login
88+
}" | head -n 1)
89+
90+
if [ -z "$latest_run" ]; then
91+
echo " No recent runs found (excluding dependabot)"
92+
repo_workflows+=("| $workflow_name | No recent run |")
93+
continue
94+
fi
95+
96+
run_status=$(echo "$latest_run" | jq -r '.status')
97+
run_conclusion=$(echo "$latest_run" | jq -r '.conclusion')
98+
run_url=$(echo "$latest_run" | jq -r '.html_url')
99+
run_actor=$(echo "$latest_run" | jq -r '.actor')
100+
run_date=$(echo "$latest_run" | jq -r '.created_at' | cut -d'T' -f1)
101+
102+
# Determine if job failed or succeeded and format status
103+
if [ "$run_conclusion" = "failure" ] || [ "$run_conclusion" = "cancelled" ] || [ "$run_conclusion" = "timed_out" ]; then
104+
total_failed=$((total_failed + 1))
105+
status_link="[$run_conclusion]($run_url)"
106+
failed_jobs+=("| $repo | $workflow_name | $status_link |")
107+
repo_workflows+=("| $workflow_name | $status_link |")
108+
elif [ "$run_conclusion" = "success" ]; then
109+
total_success=$((total_success + 1))
110+
status_link="[success]($run_url)"
111+
repo_workflows+=("| $workflow_name | $status_link |")
112+
elif [ "$run_status" = "in_progress" ] || [ "$run_status" = "queued" ]; then
113+
status_link="[$run_status]($run_url)"
114+
repo_workflows+=("| $workflow_name | $status_link |")
115+
else
116+
status_link="[$run_conclusion]($run_url)"
117+
repo_workflows+=("| $workflow_name | $status_link |")
118+
fi
119+
120+
done <<< "$(echo "$workflows" | jq -c '.')"
121+
122+
# Build repo details section with table
123+
if [ ${#repo_workflows[@]} -gt 0 ]; then
124+
repo_section="## $repo ($repo_workflow_count workflows)~| Workflow | Status |~|---|---|"
125+
for workflow in "${repo_workflows[@]}"; do
126+
repo_section="$repo_section~$workflow"
127+
done
128+
repo_details+=("$repo_section")
129+
else
130+
repo_details+=("## $repo~~No active workflows found")
131+
fi
132+
133+
done
134+
135+
# Generate the final report
136+
echo ""
137+
echo "## Overview"
138+
echo ""
139+
echo "- **Total Repositories:** $total_repos"
140+
echo "- **Total Workflows:** $total_workflows"
141+
echo "- **Failed Jobs:** $total_failed"
142+
echo "- **Successful Jobs:** $total_success"
143+
echo ""
144+
145+
if [ ${#failed_jobs[@]} -gt 0 ]; then
146+
echo "### Failed Jobs Summary"
147+
echo ""
148+
echo "| Repository | Workflow | Status |"
149+
echo "|---|---|---|"
150+
for job in "${failed_jobs[@]}"; do
151+
echo "$job"
152+
done
153+
echo ""
154+
else
155+
echo "### Failed Jobs Summary"
156+
echo ""
157+
echo "🎉 No failed jobs found!"
158+
echo ""
159+
fi
160+
161+
echo "## Repository Details"
162+
echo ""
163+
164+
for detail in "${repo_details[@]}"; do
165+
echo "$detail" | tr '~' '\n'
166+
echo ""
167+
done
168+
169+
# Export to GitHub Step Summary for workflow output
170+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
171+
{
172+
echo "# Eclipse GLSP Workflow Status"
173+
echo ""
174+
echo "Overview of all Workflows in the Eclipse GLSP organization running on master or main"
175+
echo ""
176+
echo "Generated on: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
177+
echo ""
178+
echo "## Overview"
179+
echo ""
180+
echo "- **Total Repositories:** $total_repos"
181+
echo "- **Total Workflows:** $total_workflows"
182+
echo "- **Failed Jobs:** $total_failed"
183+
echo "- **Successful Jobs:** $total_success"
184+
echo ""
185+
186+
if [ ${#failed_jobs[@]} -gt 0 ]; then
187+
echo "### Failed Jobs Summary"
188+
echo ""
189+
echo "| Repository | Workflow | Status |"
190+
echo "|---|---|---|"
191+
for job in "${failed_jobs[@]}"; do
192+
echo "$job"
193+
done
194+
echo ""
195+
else
196+
echo "### Failed Jobs Summary"
197+
echo ""
198+
echo "🎉 No failed jobs found!"
199+
echo ""
200+
fi
201+
202+
echo "## Repository Details"
203+
echo ""
204+
205+
for detail in "${repo_details[@]}"; do
206+
echo "$detail" | tr '~' '\n'
207+
echo ""
208+
done
209+
} >> "$GITHUB_STEP_SUMMARY"
210+
211+
echo "Summary exported to GitHub Step Summary"
212+
fi
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Workflow Summary Report
2+
3+
on:
4+
schedule:
5+
# Run weekly on Sundays at midnight
6+
- cron: '0 0 * * 0'
7+
workflow_dispatch:
8+
9+
jobs:
10+
generate-summary:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18+
19+
- name: Make script executable
20+
run: chmod +x .github/workflows/scripts/generate-workflow-summary.sh
21+
22+
- name: Generate Workflow Summary
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: .github/workflows/scripts/generate-workflow-summary.sh

0 commit comments

Comments
 (0)