@@ -19,38 +19,24 @@ jobs:
1919 runs-on : ubuntu-latest
2020 outputs :
2121 build_status : ${{ steps.build_step.outcome }}
22- build_timestamp : ${{ steps.set_timestamp.outputs.timestamp }}
2322
2423 steps :
2524 - name : Checkout repo
2625 uses : actions/checkout@v4
2726
28- - name : Set timestamp
29- id : set_timestamp
30- run : echo "timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
31-
3227 - name : Install tools
33- id : install_tools
3428 uses : ARM-software/cmsis-actions/vcpkg@v1
3529 with :
3630 config : " .ci/vcpkg-configuration.json"
3731 continue-on-error : false
3832
39- - name : Save tool installation logs
33+ - name : Capture vcpkg activation output
4034 if : always()
4135 run : |
4236 mkdir -p logs
43- echo "=== Tool Installation Information ===" > logs/install_tools.log
44- echo "Timestamp: $(date -u +"%Y-%m-%d %H:%M:%S")" >> logs/install_tools.log
45- echo "" >> logs/install_tools.log
46-
47- # Check if cbuild is available and get its version
48- if command -v cbuild &> /dev/null; then
49- echo "=== CMSIS Toolbox Version ===" >> logs/install_tools.log
50- cbuild --version 2>&1 >> logs/install_tools.log || echo "Version unavailable" >> logs/install_tools.log
51- else
52- echo "cbuild command not found" >> logs/install_tools.log
53- fi
37+ echo "=== vcpkg Artifacts Activation ===" > logs/vcpkg_artifacts.log
38+ cd $(dirname ".ci/vcpkg-configuration.json")
39+ vcpkg activate 2>&1 | tee -a $GITHUB_WORKSPACE/logs/vcpkg_artifacts.log || echo "vcpkg activate failed" >> $GITHUB_WORKSPACE/logs/vcpkg_artifacts.log
5440
5541 - name : Upload tool logs
5642 if : always()
@@ -80,12 +66,12 @@ jobs:
8066
8167 - name : Parse and collect data
8268 run : |
83- # Parse tool installation log
84- if [ -f logs/install_tools .log ]; then
85- echo "Parsing tool installation log..."
86- cat logs/install_tools .log
69+ # Parse vcpkg artifacts log
70+ if [ -f logs/vcpkg_artifacts .log ]; then
71+ echo "Parsing vcpkg artifacts log..."
72+ cat logs/vcpkg_artifacts .log
8773 else
88- echo "No tool installation log found"
74+ echo "No vcpkg artifacts log found"
8975 fi
9076
9177 - name : Generate JSON report
@@ -95,46 +81,40 @@ jobs:
9581 import re
9682 from datetime import datetime
9783
98- def parse_tool_log (log_path):
84+ def parse_vcpkg_artifacts_log (log_path):
9985 cmsis_toolbox_info = None
10086 try:
10187 with open(log_path, 'r') as f:
10288 content = f.read()
10389
104- # Parse cbuild --version output
105- # Looking for version number like " 2.12.0" or similar
106- match = re.search(r'=== CMSIS Toolbox Version ===\s*(.+?)(?:\n|$) ', content)
90+ # Parse the vcpkg artifacts table for cmsis-toolbox
91+ # Looking for line like: "arm:tools/open-cmsis-pack/cmsis-toolbox 2.12.0 will install"
92+ match = re.search(r'arm:tools/open-cmsis-pack/cmsis-toolbox\s+(\S+)\s+ ', content)
10793 if match:
108- version = match.group(1).strip()
94+ version = match.group(1)
10995 cmsis_toolbox_info = {
11096 "version": version,
11197 "tool": "cmsis-toolbox"
11298 }
11399
114100 except FileNotFoundError:
115- print("Tool log file not found")
101+ print("vcpkg artifacts log file not found")
116102 except Exception as e:
117- print(f"Error parsing tool log: {e}")
103+ print(f"Error parsing vcpkg artifacts log: {e}")
118104
119105 return cmsis_toolbox_info
120106
121107 # Collect data
122108 data = {
123109 "workflow": "CubeMX: Test Build",
110+ "repo": "${{ github.repository }}",
111+ "run_id": "${{ github.run_id }}",
124112 "build_job": {
125- "last_run": "${{ needs.Build.outputs.build_timestamp }}" ,
113+ "last_run": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") ,
126114 "status": "${{ needs.Build.outputs.build_status }}",
127115 "passed": "${{ needs.Build.outputs.build_status }}" == "success"
128116 },
129- "cmsis_toolbox": parse_tool_log("logs/install_tools.log"),
130- "metadata": {
131- "run_id": "${{ github.run_id }}",
132- "run_number": "${{ github.run_number }}",
133- "workflow_ref": "${{ github.workflow_ref }}",
134- "event": "${{ github.event_name }}",
135- "branch": "${{ github.ref_name }}",
136- "commit": "${{ github.sha }}"
137- }
117+ "cmsis_toolbox": parse_vcpkg_artifacts_log("logs/vcpkg_artifacts.log")
138118 }
139119
140120 # Print JSON
@@ -148,7 +128,9 @@ jobs:
148128 python3 collect_data.py
149129
150130 - name : Display collected data
131+ id : collected_data
151132 run : |
133+ echo "json=$(jq -c '.' workflow_data.json)" >> "$GITHUB_OUTPUT"
152134 echo "=== Workflow Data Collection ==="
153135 cat workflow_data.json
154136
@@ -157,3 +139,16 @@ jobs:
157139 with :
158140 name : workflow-data
159141 path : workflow_data.json
142+
143+ - name : Emit to central repo
144+ uses : peter-evans/repository-dispatch@v4
145+ with :
146+ token : ${{ secrets.METRICS_PAT }} # PAT or GitHub App token
147+ repository : soumeh01/test_ts_app # <-- your central repo
148+ event-type : ci_metrics
149+ client-payload : |
150+ {
151+ "source": "${{ github.repository }}",
152+ "workflow": "CubeMX: Test Build",
153+ "metrics": ${{ steps.collected_data.outputs.json }}
154+ }
0 commit comments