Skip to content

Commit f338cfb

Browse files
committed
Cature installed tools logs from vcpkg
1 parent f4338a3 commit f338cfb

File tree

1 file changed

+40
-46
lines changed

1 file changed

+40
-46
lines changed

.github/workflows/CubeMX-CI.yml

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -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,45 +81,38 @@ jobs:
9581
import re
9682
from datetime import datetime
9783
98-
def parse_tool_log(log_path):
99-
cmsis_toolbox_info = None
84+
def parse_vcpkg_artifacts_log(log_path):
85+
cmsis_toolbox_version = 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()
109-
cmsis_toolbox_info = {
110-
"version": version,
111-
"tool": "cmsis-toolbox"
112-
}
94+
cmsis_toolbox_version = match.group(1)
11395
11496
except FileNotFoundError:
115-
print("Tool log file not found")
97+
print("vcpkg artifacts log file not found")
11698
except Exception as e:
117-
print(f"Error parsing tool log: {e}")
99+
print(f"Error parsing vcpkg artifacts log: {e}")
118100
119-
return cmsis_toolbox_info
101+
return cmsis_toolbox_version
120102
121103
# Collect data
122104
data = {
123105
"workflow": "CubeMX: Test Build",
124-
"build_job": {
125-
"last_run": "${{ needs.Build.outputs.build_timestamp }}",
106+
"repo": "${{ github.repository }}",
107+
"run_id": "${{ github.run_id }}",
108+
"run_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
109+
"job": {
110+
"last_run": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
126111
"status": "${{ needs.Build.outputs.build_status }}",
127112
"passed": "${{ needs.Build.outputs.build_status }}" == "success"
128113
},
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 }}"
114+
"tools": {
115+
"cmsis_toolbox": parse_vcpkg_artifacts_log("logs/vcpkg_artifacts.log")
137116
}
138117
}
139118
@@ -148,7 +127,9 @@ jobs:
148127
python3 collect_data.py
149128
150129
- name: Display collected data
130+
id: collected_data
151131
run: |
132+
echo "json=$(jq -c '.' workflow_data.json)" >> "$GITHUB_OUTPUT"
152133
echo "=== Workflow Data Collection ==="
153134
cat workflow_data.json
154135
@@ -157,3 +138,16 @@ jobs:
157138
with:
158139
name: workflow-data
159140
path: workflow_data.json
141+
142+
- name: Emit to central repo
143+
uses: peter-evans/repository-dispatch@v4
144+
with:
145+
token: ${{ secrets.METRICS_PAT }} # PAT or GitHub App token
146+
repository: soumeh01/test_ts_app # <-- your central repo
147+
event-type: ci_metrics
148+
client-payload: |
149+
{
150+
"source": "${{ github.repository }}",
151+
"workflow": "CubeMX: Test Build",
152+
"metrics": ${{ steps.collected_data.outputs.json }}
153+
}

0 commit comments

Comments
 (0)