1+ name : Sync Project Tracking
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ paths :
7+ - ' src/**'
8+ - ' docs/**'
9+ - ' scripts/**'
10+ - ' tests/**'
11+ - ' ROADMAP_STATUS.md'
12+ - ' VERSION_MAPPING.md'
13+ - ' README.md'
14+
15+ jobs :
16+ sync-tracking :
17+ runs-on : ubuntu-latest
18+ permissions :
19+ issues : write
20+ contents : read
21+ pull-requests : write
22+
23+ steps :
24+ - uses : actions/checkout@v3
25+ with :
26+ fetch-depth : 0 # Fetch all history for git log
27+
28+ - name : Set up Python
29+ uses : actions/setup-python@v4
30+ with :
31+ python-version : ' 3.x'
32+
33+ - name : Install dependencies
34+ run : |
35+ python -m pip install --upgrade pip
36+ pip install PyGithub gitpython
37+
38+ - name : Analyze changes and update tracking
39+ env :
40+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41+ run : |
42+ cat > sync_tracking.py << 'EOL'
43+ import os
44+ import re
45+ from github import Github
46+ from git import Repo
47+ import json
48+
49+ # Initialize GitHub client
50+ g = Github(os.environ['GITHUB_TOKEN'])
51+ repo = g.get_repo(os.environ['GITHUB_REPOSITORY'])
52+
53+ # Get the latest commit
54+ git_repo = Repo('.')
55+ latest_commit = git_repo.head.commit
56+
57+ def extract_progress(content, section):
58+ """Extract progress percentage from markdown content"""
59+ pattern = rf"{section}.*?(\d+)%"
60+ match = re.search(pattern, content, re.DOTALL)
61+ return int(match.group(1)) if match else None
62+
63+ def update_issue_progress(issue_number, progress):
64+ """Update issue with progress information"""
65+ issue = repo.get_issue(issue_number)
66+ body = issue.body or ""
67+
68+ # Check if progress has changed
69+ current_progress = extract_progress(body, "Current Status")
70+ if current_progress != progress:
71+ comment = f"Progress Update: {progress}% complete\n\nAutomatically updated based on latest changes."
72+ issue.create_comment(comment)
73+
74+ # Read ROADMAP_STATUS.md
75+ with open('ROADMAP_STATUS.md', 'r') as f:
76+ roadmap_content = f.read()
77+
78+ # Map of feature keywords to issue numbers
79+ feature_mapping = {
80+ 'UART driver': 2,
81+ 'GDB integration': 1,
82+ 'semihosting': 3,
83+ 'QEMU machine': 4,
84+ 'testing framework': 8,
85+ 'network simulation': 5,
86+ 'virtual sensors': 7,
87+ 'state snapshots': 9,
88+ 'OTA update': 10,
89+ 'CI/CD': 6,
90+ 'automated testing': 11,
91+ 'documentation': 12,
92+ 'project tracking': 13
93+ }
94+
95+ # Extract changed files from commit
96+ changed_files = [item.a_path for item in latest_commit.diff('HEAD~1')]
97+
98+ # Analyze changes and update relevant issues
99+ for file in changed_files:
100+ # Extract relevant section from ROADMAP_STATUS.md based on changed files
101+ if file.startswith('src/custom_uart'):
102+ progress = extract_progress(roadmap_content, 'Custom UART driver')
103+ if progress:
104+ update_issue_progress(2, progress)
105+ elif file.startswith('src/network'):
106+ progress = extract_progress(roadmap_content, 'Network simulation')
107+ if progress:
108+ update_issue_progress(5, progress)
109+ # Add more file patterns and their corresponding issues
110+
111+ # Create a tracking update comment on the sync process issue
112+ sync_issue = repo.get_issue(13)
113+ sync_issue.create_comment(f"""
114+ Automatic Tracking Sync Report
115+
116+ Commit: {latest_commit.hexsha}
117+ Changed files: {len(changed_files)}
118+
119+ Files analyzed:
120+ {chr(10).join(f"- {file}" for file in changed_files)}
121+
122+ Progress updates applied based on ROADMAP_STATUS.md changes.
123+ """)
124+ EOL
125+
126+ python sync_tracking.py
127+
128+ - name : Check for milestone updates
129+ run : |
130+ cat > check_milestones.py << 'EOL'
131+ import os
132+ from github import Github
133+ from datetime import datetime, timezone
134+
135+ g = Github(os.environ['GITHUB_TOKEN'])
136+ repo = g.get_repo(os.environ['GITHUB_REPOSITORY'])
137+
138+ # Get all open milestones
139+ milestones = repo.get_milestones(state='open')
140+
141+ # Check each milestone's progress
142+ for milestone in milestones:
143+ total_issues = milestone.open_issues + milestone.closed_issues
144+ if total_issues > 0:
145+ progress = (milestone.closed_issues / total_issues) * 100
146+
147+ # Create a progress update comment if significant change
148+ if progress % 10 == 0: # Update on every 10% progress
149+ for issue in repo.get_issues(milestone=milestone):
150+ if "tracking" in issue.title.lower():
151+ issue.create_comment(f"""
152+ Milestone Progress Update: {milestone.title}
153+
154+ Current Progress: {progress:.1f}%
155+ Open Issues: {milestone.open_issues}
156+ Closed Issues: {milestone.closed_issues}
157+ Due Date: {milestone.due_on.strftime('%Y-%m-%d')}
158+ """)
159+ EOL
160+
161+ python check_milestones.py
162+
163+ - name : Update documentation if needed
164+ if : success()
165+ run : |
166+ # Check if we need to update any documentation
167+ if git diff --name-only HEAD~1 | grep -q "src/"; then
168+ echo "Source changes detected, checking documentation..."
169+ # Add logic to verify and potentially update documentation
170+ fi
0 commit comments