Skip to content

Commit a6cfd4b

Browse files
authored
Merge pull request #11 from soumeh01/workflow_improvments
Improved CI workflow with concurrenct setup/installation and updates
2 parents b65986d + 7916264 commit a6cfd4b

File tree

4 files changed

+257
-109
lines changed

4 files changed

+257
-109
lines changed

.github/scripts/run-tests.sh

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#!/bin/bash
2+
set -e # Exit on error
3+
4+
# Script to run all test configurations
5+
# Usage: ./run-tests.sh <config_file>
6+
7+
CONFIG_FILE="${1:-.github/workflows/test-matrix.json}"
8+
9+
# Initialize counters and tracking
10+
total=0
11+
passed=0
12+
failed=0
13+
declare -a failed_configs
14+
declare -a failed_log_dirs
15+
16+
# Initialize GitHub Summary if running in GitHub Actions
17+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
18+
echo "# Build and Execution Test Results" >> "$GITHUB_STEP_SUMMARY"
19+
echo "" >> "$GITHUB_STEP_SUMMARY"
20+
echo "| # | Configuration | Status | Details |" >> "$GITHUB_STEP_SUMMARY"
21+
echo "|---|---------------|--------|---------|" >> "$GITHUB_STEP_SUMMARY"
22+
fi
23+
24+
# Function to add result to summary
25+
add_to_summary() {
26+
local num=$1
27+
local config=$2
28+
local status=$3
29+
local details=$4
30+
31+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
32+
echo "| $num | $config | $status | $details |" >> "$GITHUB_STEP_SUMMARY"
33+
fi
34+
}
35+
36+
# Function to build, execute and verify a configuration
37+
test_configuration() {
38+
local compiler=$1
39+
local ext=$2
40+
local target=$3
41+
local model=$4
42+
local uart=$5
43+
local build=$6
44+
45+
local config_name="$build+$target with $compiler"
46+
local failure_reason=""
47+
local log_file="./logs/${target}_${compiler}_${build}.log"
48+
49+
# Create logs directory
50+
mkdir -p "./logs"
51+
52+
# Initialize log file with header
53+
echo "=========================================" > "$log_file"
54+
echo "Configuration: $config_name" >> "$log_file"
55+
echo "Date: $(date)" >> "$log_file"
56+
echo "=========================================" >> "$log_file"
57+
echo "" >> "$log_file"
58+
59+
echo ""
60+
echo "=========================================="
61+
echo "[$total/60] Testing: $config_name"
62+
echo "=========================================="
63+
64+
# Build
65+
echo "▶ Building..."
66+
echo "=========================================" >> "$log_file"
67+
echo "BUILD OUTPUT" >> "$log_file"
68+
echo "=========================================" >> "$log_file"
69+
if ! cbuild Hello.csolution.yml --packs \
70+
--context "Hello.$build+$target" \
71+
--toolchain "$compiler" --rebuild 2>&1 | tee -a "$log_file"; then
72+
failure_reason="Build failed"
73+
echo "$failure_reason"
74+
echo "" >> "$log_file"
75+
echo "Result: FAILED - $failure_reason" >> "$log_file"
76+
failed=$((failed + 1))
77+
failed_configs+=("[$total] $config_name - $failure_reason")
78+
failed_log_dirs+=("$log_file")
79+
add_to_summary "$total" "$config_name" "❌ Failed" "$failure_reason"
80+
return 1
81+
fi
82+
echo "✅ Build successful"
83+
84+
# Execute
85+
echo "▶ Executing on $model..."
86+
echo "" >> "$log_file"
87+
echo "=========================================" >> "$log_file"
88+
echo "EXECUTION OUTPUT" >> "$log_file"
89+
echo "=========================================" >> "$log_file"
90+
if ! "$model" \
91+
-a "./out/Hello/$target/$build/$compiler/Hello.$ext" \
92+
-f "./FVP/$model/fvp_config.txt" \
93+
-C "$uart.out_file=./out/Hello/$target/$build/$compiler/fvp_stdout.log" \
94+
--simlimit 60 --stat 2>&1 | tee -a "$log_file"; then
95+
failure_reason="Execution failed"
96+
echo "$failure_reason"
97+
echo "" >> "$log_file"
98+
echo "Result: FAILED - $failure_reason" >> "$log_file"
99+
failed=$((failed + 1))
100+
failed_configs+=("[$total] $config_name - $failure_reason")
101+
failed_log_dirs+=("$log_file")
102+
add_to_summary "$total" "$config_name" "❌ Failed" "$failure_reason"
103+
return 1
104+
fi
105+
echo "✅ Execution successful"
106+
107+
echo "Actual UART output:"
108+
cat "./out/Hello/$target/$build/$compiler/fvp_stdout.log" || echo "Could not read log file"
109+
110+
if grep -q "Hello World 100" "./out/Hello/$target/$build/$compiler/fvp_stdout.log"; then
111+
echo "✅ Test PASSED"
112+
passed=$((passed + 1))
113+
add_to_summary "$total" "$config_name" "✅ Passed" ""
114+
# Clean up log for passed test
115+
rm -f "$log_file"
116+
return 0
117+
else
118+
failure_reason="Verification failed - 'Hello World 100' not found"
119+
echo "$failure_reason"
120+
121+
# Add UART output to log file
122+
echo "" >> "$log_file"
123+
echo "=========================================" >> "$log_file"
124+
echo "UART OUTPUT" >> "$log_file"
125+
echo "=========================================" >> "$log_file"
126+
cat "./out/Hello/$target/$build/$compiler/fvp_stdout.log" >> "$log_file" 2>/dev/null || echo "Could not read UART log" >> "$log_file"
127+
echo "" >> "$log_file"
128+
echo "Result: FAILED - $failure_reason" >> "$log_file"
129+
130+
failed=$((failed + 1))
131+
failed_configs+=("[$total] $config_name - $failure_reason")
132+
failed_log_dirs+=("$log_file")
133+
add_to_summary "$total" "$config_name" "❌ Failed" "$failure_reason"
134+
return 1
135+
fi
136+
}
137+
138+
# Main execution loop
139+
echo "Reading configurations from: $CONFIG_FILE"
140+
141+
# Generate all combinations from compilers × targets × builds
142+
while IFS= read -r compiler_data; do
143+
compiler=$(echo "$compiler_data" | jq -r '.name')
144+
ext=$(echo "$compiler_data" | jq -r '.ext')
145+
146+
while IFS= read -r target_data; do
147+
target=$(echo "$target_data" | jq -r '.type')
148+
model=$(echo "$target_data" | jq -r '.model')
149+
uart=$(echo "$target_data" | jq -r '.uart')
150+
151+
while IFS= read -r build; do
152+
total=$((total + 1))
153+
test_configuration "$compiler" "$ext" "$target" "$model" "$uart" "$build" || true
154+
done < <(jq -r '.builds[]' "$CONFIG_FILE")
155+
156+
done < <(jq -c '.targets[]' "$CONFIG_FILE")
157+
158+
done < <(jq -c '.compilers[]' "$CONFIG_FILE")
159+
160+
# Add summary statistics to GitHub Summary
161+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
162+
echo "" >> "$GITHUB_STEP_SUMMARY"
163+
echo "## Summary" >> "$GITHUB_STEP_SUMMARY"
164+
echo "" >> "$GITHUB_STEP_SUMMARY"
165+
echo "- **Total Configurations:** $total" >> "$GITHUB_STEP_SUMMARY"
166+
echo "- **✅ Passed:** $passed" >> "$GITHUB_STEP_SUMMARY"
167+
echo "- **❌ Failed:** $failed" >> "$GITHUB_STEP_SUMMARY"
168+
fi
169+
170+
# Print comprehensive summary
171+
echo ""
172+
echo "=========================================="
173+
echo " FINAL SUMMARY"
174+
echo "=========================================="
175+
echo "Total configurations: $total"
176+
echo "Passed: $passed"
177+
echo "Failed: $failed"
178+
echo ""
179+
180+
if [ $failed -gt 0 ]; then
181+
echo "❌ FAILED CONFIGURATIONS:"
182+
echo "=========================================="
183+
for fail_info in "${failed_configs[@]}"; do
184+
echo "$fail_info"
185+
done
186+
echo "=========================================="
187+
echo ""
188+
echo "Logs for failed configurations saved in: ./logs/"
189+
echo "Total failed log files: ${#failed_log_dirs[@]}"
190+
exit 1
191+
else
192+
echo "✅ All tests passed!"
193+
# Clean up logs directory if all tests passed
194+
rm -rf ./logs
195+
fi

.github/test-matrix.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilers": [
3+
{"name": "AC6", "ext": "axf"},
4+
{"name": "GCC", "ext": "elf"}
5+
],
6+
"targets": [
7+
{"type": "CM0", "model": "FVP_MPS2_Cortex-M0", "uart": "fvp_mps2.UART0"},
8+
{"type": "CM0plus", "model": "FVP_MPS2_Cortex-M0plus", "uart": "fvp_mps2.UART0"},
9+
{"type": "CM3", "model": "FVP_MPS2_Cortex-M3", "uart": "fvp_mps2.UART0"},
10+
{"type": "CM4", "model": "FVP_MPS2_Cortex-M4", "uart": "fvp_mps2.UART0"},
11+
{"type": "CM4_FP", "model": "FVP_MPS2_Cortex-M4", "uart": "fvp_mps2.UART0"},
12+
{"type": "CM7", "model": "FVP_MPS2_Cortex-M7", "uart": "fvp_mps2.UART0"},
13+
{"type": "CM7_SP", "model": "FVP_MPS2_Cortex-M7", "uart": "fvp_mps2.UART0"},
14+
{"type": "CM7_DP", "model": "FVP_MPS2_Cortex-M7", "uart": "fvp_mps2.UART0"},
15+
{"type": "CM23", "model": "FVP_MPS2_Cortex-M23", "uart": "fvp_mps2.UART0"},
16+
{"type": "CM33", "model": "FVP_MPS2_Cortex-M33", "uart": "fvp_mps2.UART0"},
17+
{"type": "CM33_FP", "model": "FVP_MPS2_Cortex-M33", "uart": "fvp_mps2.UART0"},
18+
{"type": "CS300", "model": "FVP_Corstone_SSE-300", "uart": "mps3_board.uart0"},
19+
{"type": "CS310", "model": "FVP_Corstone_SSE-310", "uart": "mps3_board.uart0"},
20+
{"type": "CS315", "model": "FVP_Corstone_SSE-315", "uart": "mps4_board.uart0"}
21+
],
22+
"builds": ["Release", "Debug"]
23+
}

.github/workflows/hello-ci-ubuntu-2404-arm.yml

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,17 @@ env:
1414
GIT_TRACE: True
1515
GIT_SSH_COMMAND: ssh -vvv
1616

17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true # Cancel previous runs on new push
20+
1721
jobs:
1822
install_build_execute:
1923
runs-on: ubuntu-24.04-arm
2024

21-
strategy:
22-
matrix:
23-
compiler: [
24-
{name: AC6, ext: axf},
25-
{name: GCC, ext: elf}
26-
]
27-
target: [
28-
{type: CM0, model: FVP_MPS2_Cortex-M0, uart: fvp_mps2.UART0},
29-
{type: CM0plus, model: FVP_MPS2_Cortex-M0plus, uart: fvp_mps2.UART0},
30-
{type: CM3, model: FVP_MPS2_Cortex-M3, uart: fvp_mps2.UART0},
31-
{type: CM4, model: FVP_MPS2_Cortex-M4, uart: fvp_mps2.UART0},
32-
{type: CM4_FP, model: FVP_MPS2_Cortex-M4, uart: fvp_mps2.UART0},
33-
{type: CM7, model: FVP_MPS2_Cortex-M7, uart: fvp_mps2.UART0},
34-
{type: CM7_SP, model: FVP_MPS2_Cortex-M7, uart: fvp_mps2.UART0},
35-
{type: CM7_DP, model: FVP_MPS2_Cortex-M7, uart: fvp_mps2.UART0},
36-
{type: CM23, model: FVP_MPS2_Cortex-M23, uart: fvp_mps2.UART0},
37-
{type: CM33, model: FVP_MPS2_Cortex-M33, uart: fvp_mps2.UART0},
38-
{type: CM33_FP, model: FVP_MPS2_Cortex-M33, uart: fvp_mps2.UART0},
39-
{type: CS300, model: FVP_Corstone_SSE-300, uart: mps3_board.uart0},
40-
{type: CS310, model: FVP_Corstone_SSE-310, uart: mps3_board.uart0},
41-
{type: CS315, model: FVP_Corstone_SSE-315, uart: mps4_board.uart0},
42-
{type: CS320, model: FVP_Corstone_SSE-320, uart: mps4_board.uart0}
43-
]
44-
build: [
45-
{type: Release},
46-
{type: Debug}
47-
]
48-
4925
steps:
5026
- name: Checkout repo
51-
uses: actions/checkout@v4
27+
uses: actions/checkout@v6
5228

5329
- name: Install tools
5430
uses: ARM-software/cmsis-actions/vcpkg@v1
@@ -57,34 +33,23 @@ jobs:
5733
uses: ARM-software/cmsis-actions/armlm@v1
5834

5935
- name: Cache packs
60-
uses: actions/cache@v4
36+
uses: actions/cache@v5
6137
with:
62-
key: cmsis-packs
38+
key: cmsis-packs-${{ hashFiles('*.csolution.yml', '*.cproject.yml') }}
39+
restore-keys: |
40+
cmsis-packs-
6341
path: /home/runner/.cache/arm/packs
6442

65-
- name: Build context Hello.${{ matrix.build.type }}+${{ matrix.target.type }} with ${{ matrix.compiler.name }}
43+
- name: Build and Execute All Configurations
6644
working-directory: ./
6745
run: |
68-
cbuild Hello.csolution.yml --packs \
69-
--context Hello.${{ matrix.build.type }}+${{ matrix.target.type }} \
70-
--toolchain ${{ matrix.compiler.name }} --rebuild
46+
chmod +x .github/scripts/run-tests.sh
47+
.github/scripts/run-tests.sh .github/test-matrix.json
7148
72-
- name: Execute context Hello.${{ matrix.build.type }}+${{ matrix.target.type }} with ${{ matrix.compiler.name }}
73-
working-directory: ./
74-
run: |
75-
${{ matrix.target.model }} \
76-
-a ./out/Hello/${{ matrix.target.type }}/${{ matrix.build.type }}/${{ matrix.compiler.name }}/Hello.${{ matrix.compiler.ext }} \
77-
-f ./FVP/${{ matrix.target.model }}/fvp_config.txt \
78-
-C ${{ matrix.target.uart }}.out_file=./out/Hello/${{ matrix.target.type }}/${{ matrix.build.type }}/${{ matrix.compiler.name }}/fvp_stdout.log \
79-
--simlimit 60 --stat
80-
81-
echo " Show simulation UART output"
82-
cat ./out/Hello/${{ matrix.target.type }}/${{ matrix.build.type }}/${{ matrix.compiler.name }}/fvp_stdout.log
83-
84-
echo "Checking simulation UART output"
85-
if [ "$(grep -c "Hello World 100" ./out/Hello/${{ matrix.target.type }}/${{ matrix.build.type }}/${{ matrix.compiler.name }}/fvp_stdout.log)" -eq 1 ]
86-
then
87-
exit 0
88-
else
89-
exit 1
90-
fi
49+
- name: Upload Failed Test Logs
50+
if: failure()
51+
uses: actions/upload-artifact@v6
52+
with:
53+
name: failed-test-logs-${{ github.workflow }}
54+
path: logs/
55+
retention-days: 30

0 commit comments

Comments
 (0)