-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (136 loc) · 5.44 KB
/
Copy pathbuild_samples.yml
File metadata and controls
155 lines (136 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build Samples
on:
push:
branches:
- main
pull_request:
branches:
- '*'
schedule:
- cron: "0 0 * * 1"
env:
platforms: |
nucleo_f446re
radio_module
sensor_module
power_module
deployment_module
linux_only_platforms: |
native_sim
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
path: FSW
fetch-depth: 2
- name: Run Starter Steps
uses: ./FSW/.github/actions/fsw-setup
- name: Set test_roots based on changes
id: set_test_roots
shell: bash
working-directory: FSW
continue-on-error: false
run: |
if [ "$GITHUB_REF_NAME" = "main" ]; then
python3 .github/scripts/determine_test_roots.py --map .github/sample-roots.yaml --run-all > test_roots.txt
else
git fetch origin main:refs/remotes/origin/main
git diff --name-only origin/main...HEAD > changed_files.txt
cat changed_files.txt | python3 .github/scripts/determine_test_roots.py --map .github/sample-roots.yaml > test_roots.txt
fi
if [ ! -s test_roots.txt ]; then
echo "No test roots to run. Exiting early."
exit 0
fi
echo "test_roots<<EOF" >> $GITHUB_ENV
cat test_roots.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "Test roots set to: ${{ env.test_roots }}"
- name: Build firmware
if: steps.set_test_roots.outcome == 'success' && env.test_roots != ''
working-directory: FSW
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
EXTRA_TWISTER_FLAGS="--short-build-path -O/tmp/twister-out"
fi
if [ "${{ runner.os }}" = "Linux" ]; then
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
fi
function add_arglist () {
echo "$2" | while read -r line; do
[ -z "$line" ] && continue
echo -n " $1 $line "
done;
}
west twister $(add_arglist -T "${{ env.test_roots }}") $(add_arglist -p "${{ env.platforms }}") $(if [ "${{ runner.os }}" = "Linux" ]; then add_arglist -p "${{ env.linux_only_platforms }}"; fi) -v --inline-logs --integration $EXTRA_TWISTER_FLAGS
- name: Print Test Results Summary
if: runner.os == 'Linux' && steps.set_test_roots.outcome == 'success' && env.test_roots != ''
working-directory: FSW
shell: bash
run: |
if [ -f "twister-out/twister.json" ]; then
python3 << 'PYTHON_SCRIPT'
import json
import sys
try:
with open('twister-out/twister.json', 'r') as f:
data = json.load(f)
print("\n" + "="*80)
print("TWISTER TEST RESULTS SUMMARY")
print("="*80)
# Environment info
env = data.get('environment', {})
print(f"\nEnvironment:")
print(f" OS: {env.get('os', 'N/A')}")
print(f" Zephyr Version: {env.get('zephyr_version', 'N/A')}")
print(f" Run Date: {env.get('run_date', 'N/A')}")
# Test statistics
testsuites = data.get('testsuites', [])
total = len(testsuites)
status_counts = {}
for suite in testsuites:
status = suite.get('status', 'unknown')
status_counts[status] = status_counts.get(status, 0) + 1
print(f"\nTest Statistics:")
print(f" Total Test Suites: {total}")
for status, count in sorted(status_counts.items()):
print(f" {status.capitalize()}: {count}")
# Total build time
total_build_time = sum(float(suite.get('build_time', 0)) for suite in testsuites)
print(f"\nTotal Build Time: {total_build_time:.2f}s")
# Per-suite details
print(f"\nTest Suite Details:")
print(f"{'Name':<50} {'Platform':<25} {'Status':<12} {'Build Time':<10}")
print("-"*100)
for suite in testsuites:
name = suite.get('name', 'unknown')[:48]
platform = suite.get('platform', 'unknown')[:23]
status = suite.get('status', 'unknown')[:10]
build_time = suite.get('build_time', '0')
print(f"{name:<50} {platform:<25} {status:<12} {build_time:<10}s")
print("="*80 + "\n")
except Exception as e:
print(f"Error parsing twister.json: {e}", file=sys.stderr)
sys.exit(1)
PYTHON_SCRIPT
else
echo "Warning: twister-out/twister.json not found"
fi
- name: Upload Twister Reports
if: runner.os == 'Linux' && steps.set_test_roots.outcome == 'success' && env.test_roots != ''
uses: actions/upload-artifact@v4
with:
name: twister-reports-samples
path: |
FSW/twister-out/twister.html
FSW/twister-out/twister.json
FSW/twister-out/twister.xml
if-no-files-found: warn