Skip to content

Commit 724bbd7

Browse files
committed
update ci/cd 11
1 parent d76c7da commit 724bbd7

3 files changed

Lines changed: 188 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,16 @@ jobs:
327327
# Pre-build matplotlib font cache to avoid timeout during tests
328328
echo "=== Building matplotlib font cache ==="
329329
python -c "
330-
import os
331-
os.environ['MPLBACKEND'] = 'Agg'
332-
try:
333-
import matplotlib.font_manager
334-
matplotlib.font_manager._rebuild()
335-
print('Font cache built successfully')
336-
except Exception as e:
337-
print(f'Warning: Failed to build font cache: {e}')
338-
print('This is not critical, continuing...')
339-
"
330+
import os
331+
os.environ['MPLBACKEND'] = 'Agg'
332+
try:
333+
import matplotlib.font_manager
334+
matplotlib.font_manager._rebuild()
335+
print('Font cache built successfully')
336+
except Exception as e:
337+
print(f'Warning: Failed to build font cache: {e}')
338+
print('This is not critical, continuing...')
339+
"
340340
341341
- name: Test basic functionality
342342
timeout-minutes: 5
@@ -358,25 +358,3 @@ except Exception as e:
358358
print('Basic functionality test passed!')
359359
"
360360
361-
# Summary job to determine overall workflow status
362-
ci-success:
363-
name: CI Status
364-
runs-on: ubuntu-latest
365-
needs: [test, lint, build] # Only depend on core jobs
366-
if: always()
367-
368-
steps:
369-
- name: Check core jobs status
370-
run: |
371-
echo "=== Core Jobs Status ==="
372-
echo "Test job: ${{ needs.test.result }}"
373-
echo "Lint job: ${{ needs.lint.result }}"
374-
echo "Build job: ${{ needs.build.result }}"
375-
376-
# Fail if any core job failed
377-
if [[ "${{ needs.test.result }}" == "failure" || "${{ needs.lint.result }}" == "failure" || "${{ needs.build.result }}" == "failure" ]]; then
378-
echo "❌ One or more core jobs failed"
379-
exit 1
380-
else
381-
echo "✅ All core jobs passed"
382-
fi

.github/workflows/status-check.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Status Check
2+
3+
# This is a simple workflow that always passes
4+
# Use this to verify workflow execution basics
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches: [ master ]
10+
paths:
11+
- '.github/workflows/status-check.yml'
12+
13+
jobs:
14+
status-check:
15+
name: Simple Status Check
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 5
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Check repository status
24+
run: |
25+
echo "✅ Repository checked out successfully"
26+
echo "✅ Simple status check passed"
27+
echo "Current commit: $(git rev-parse HEAD)"
28+
echo "Current branch: $(git branch --show-current)"
29+
30+
- name: Verify Python
31+
run: |
32+
python --version
33+
echo "✅ Python verification passed"

scripts/fix_workflow_status.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Diagnose and potentially fix workflow status issues
4+
"""
5+
6+
import subprocess
7+
import json
8+
import sys
9+
10+
11+
def run_command(cmd):
12+
"""Run shell command and return output."""
13+
try:
14+
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
15+
return result.stdout.strip(), result.stderr.strip(), result.returncode
16+
except Exception as e:
17+
return "", str(e), 1
18+
19+
20+
def get_workflow_status():
21+
"""Get detailed workflow status."""
22+
print("🔍 Analyzing current workflow status...\n")
23+
24+
# Get latest CI run
25+
cmd = "gh run list --repo cloudQuant/pyfolio --workflow ci.yml --limit 1 --json databaseId,status,conclusion,jobs"
26+
stdout, stderr, code = run_command(cmd)
27+
28+
if code != 0:
29+
print(f"❌ Failed to get workflow info: {stderr}")
30+
return False
31+
32+
try:
33+
runs = json.loads(stdout)
34+
if not runs:
35+
print("❌ No workflow runs found")
36+
return False
37+
38+
run = runs[0]
39+
run_id = run.get('databaseId')
40+
41+
print(f"📊 Latest Run ID: {run_id}")
42+
print(f"📊 Status: {run.get('status')}")
43+
print(f"📊 Conclusion: {run.get('conclusion')}")
44+
print()
45+
46+
# Get detailed job information
47+
cmd = f"gh run view {run_id} --repo cloudQuant/pyfolio --json jobs"
48+
stdout, stderr, code = run_command(cmd)
49+
50+
if code != 0:
51+
print(f"❌ Failed to get job details: {stderr}")
52+
return False
53+
54+
run_details = json.loads(stdout)
55+
jobs = run_details.get('jobs', [])
56+
57+
print("📋 Job Status Summary:")
58+
all_core_passed = True
59+
60+
for job in jobs:
61+
name = job.get('name', 'Unknown')
62+
conclusion = job.get('conclusion', 'unknown')
63+
64+
# Identify core jobs
65+
is_core = any(keyword in name.lower() for keyword in
66+
['test python', 'lint', 'build distribution'])
67+
68+
if is_core:
69+
status_icon = "✅" if conclusion == "success" else "❌"
70+
print(f" {status_icon} {name}: {conclusion} (CORE)")
71+
if conclusion != "success":
72+
all_core_passed = False
73+
else:
74+
status_icon = "✅" if conclusion == "success" else "⚠️"
75+
optional_tag = " (OPTIONAL)" if "install" in name.lower() else ""
76+
print(f" {status_icon} {name}: {conclusion}{optional_tag}")
77+
78+
print()
79+
80+
# Analysis
81+
if all_core_passed and run.get('conclusion') == 'failure':
82+
print("⚠️ ISSUE DETECTED:")
83+
print(" All core jobs passed but workflow shows as failed")
84+
print(" This suggests a workflow configuration issue")
85+
return False
86+
elif all_core_passed:
87+
print("✅ ANALYSIS:")
88+
print(" All core jobs passed - workflow should show success")
89+
return True
90+
else:
91+
print("❌ ANALYSIS:")
92+
print(" Core jobs failed - workflow correctly shows failure")
93+
return False
94+
95+
except json.JSONDecodeError as e:
96+
print(f"❌ Failed to parse workflow data: {e}")
97+
return False
98+
99+
100+
def suggest_fixes():
101+
"""Suggest potential fixes."""
102+
print("\n💡 Suggested Actions:")
103+
print()
104+
print("1. **Immediate fixes:**")
105+
print(" - Check if any hidden jobs are failing")
106+
print(" - Verify no syntax errors in workflow YAML")
107+
print(" - Ensure no required status checks are blocking")
108+
print()
109+
print("2. **Diagnostic commands:**")
110+
print(" - gh run list --repo cloudQuant/pyfolio --workflow ci.yml --limit 5")
111+
print(" - gh run view [RUN_ID] --repo cloudQuant/pyfolio --log")
112+
print()
113+
print("3. **Potential solutions:**")
114+
print(" - Remove problematic continue-on-error jobs")
115+
print(" - Simplify workflow to only essential jobs")
116+
print(" - Check for GitHub Actions service issues")
117+
print()
118+
print("4. **Reset options:**")
119+
print(" - Create a simple test workflow to isolate issues")
120+
print(" - Temporarily disable non-essential jobs")
121+
122+
123+
def main():
124+
"""Main function."""
125+
print("🔧 Workflow Status Diagnostic Tool\n")
126+
127+
# Check if gh is available
128+
stdout, stderr, code = run_command("gh --version")
129+
if code != 0:
130+
print("❌ GitHub CLI not found. Please install from: https://cli.github.com/")
131+
sys.exit(1)
132+
133+
# Analyze current status
134+
status_ok = get_workflow_status()
135+
136+
if not status_ok:
137+
suggest_fixes()
138+
else:
139+
print("✅ Workflow status appears correct")
140+
print("\nIf badge still shows failure:")
141+
print(" python scripts/check_badge_status.py refresh")
142+
143+
144+
if __name__ == "__main__":
145+
main()

0 commit comments

Comments
 (0)