Skip to content

Commit 7219fc7

Browse files
authored
Executes UTs from SCORE modules (#55)
* move bash scripts to common directory * run unit tests and generate summary execute external targets UTs on_release upload test report artifact to assets
1 parent 73e92bb commit 7219fc7

File tree

6 files changed

+151
-2
lines changed

6 files changed

+151
-2
lines changed

.github/workflows/test_integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6767
- name: Bazel build targets
6868
run: |
69-
./integration_test.sh --known-good known_good.updated.json
69+
scripts/integration_test.sh --known-good known_good.updated.json
7070
- name: Show disk space after build
7171
if: always()
7272
run: |

.github/workflows/unit_tests.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
name: Execute Unit Tests
15+
on:
16+
workflow_dispatch:
17+
pull_request:
18+
release:
19+
types: [created]
20+
schedule:
21+
- cron: '30 3 * * *' # Every night at 03:30 UTC on main branch
22+
jobs:
23+
integration_test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Show disk space before build
27+
run: |
28+
echo 'Disk space before build:'
29+
df -h
30+
31+
- name: Removing unneeded software
32+
run: |
33+
echo "Removing unneeded software... "
34+
if [ -d /usr/share/dotnet ]; then echo "Removing dotnet..."; start=$(date +%s); sudo rm -rf /usr/share/dotnet; end=$(date +%s); echo "Duration: $((end-start))s"; fi
35+
#if [ -d /usr/local/lib/android ]; then echo "Removing android..."; start=$(date +%s); sudo rm -rf /usr/local/lib/android; end=$(date +%s); echo "Duration: $((end-start))s"; fi
36+
if [ -d /opt/ghc ]; then echo "Removing haskell (ghc)..."; start=$(date +%s); sudo rm -rf /opt/ghc; end=$(date +%s); echo "Duration: $((end-start))s"; fi
37+
if [ -d /usr/local/.ghcup ]; then echo "Removing haskell (ghcup)..."; start=$(date +%s); sudo rm -rf /usr/local/.ghcup; end=$(date +%s); echo "Duration: $((end-start))s"; fi
38+
if [ -d /usr/share/swift ]; then echo "Removing swift..."; start=$(date +%s); sudo rm -rf /usr/share/swift; end=$(date +%s); echo "Duration: $((end-start))s"; fi
39+
if [ -d /usr/local/share/chromium ]; then echo "Removing chromium..."; start=$(date +%s); sudo rm -rf /usr/local/share/chromium; end=$(date +%s); echo "Duration: $((end-start))s"; fi
40+
41+
- name: Show disk space after cleanup
42+
run: |
43+
echo 'Disk space after cleanup:'
44+
df -h
45+
46+
- name: Checkout repository
47+
uses: actions/[email protected]
48+
49+
- name: Setup Bazel
50+
uses: bazel-contrib/[email protected]
51+
with:
52+
bazelisk-cache: true
53+
disk-cache: ${{ github.workflow }}
54+
repository-cache: true
55+
56+
- name: Bazel build targets
57+
run: |
58+
scripts/run_unit_tests.sh
59+
cat _logs/ut_summary.md
60+
61+
- name: Publish build summary
62+
if: always()
63+
run: |
64+
if [ -f _logs/ut_summary.md ]; then
65+
cat _logs/ut_summary.md >> "$GITHUB_STEP_SUMMARY"
66+
else
67+
echo "No build summary file found (_logs/ut_summary.md)" >> "$GITHUB_STEP_SUMMARY"
68+
fi
69+
70+
- name: Upload logs artifact
71+
if: always()
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: bazel-build-logs
75+
path: _logs/
76+
if-no-files-found: warn
77+
retention-days: 14
78+
79+
- name: Create archive of test reports
80+
if: github.ref_type == 'tag'
81+
run: |
82+
mkdir -p artifacts
83+
find bazel-testlogs/external -name 'test.xml' -print0 | xargs -0 -I{} cp --parents {} artifacts/
84+
zip -r ${{ github.event.repository.name }}_test_reports.zip artifacts/
85+
shell: bash
86+
87+
- name: Upload release asset (attach ZIP to GitHub Release)
88+
uses: softprops/[email protected]
89+
if: github.ref_type == 'tag'
90+
with:
91+
files: ${{ github.event.repository.name }}_test_reports.zip
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ local_path_override(module_name = "score_tooling", path = "../tooling")
148148

149149
### Rust
150150

151-
Use `./generate_rust_analyzer_support.sh` to generate rust_analyzer settings that will let VS Code work.
151+
Use `scripts/generate_rust_analyzer_support.sh` to generate rust_analyzer settings that will let VS Code work.
152152

153153
## 🗂 Notes
154154
Keep this file updated as integration issues are resolved. Prefer converting ad-hoc shell steps into Bazel rules or documented scripts under `tools/` for repeatability.

scripts/run_unit_tests.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -uo pipefail
3+
4+
# Integration unit test script.
5+
6+
CONFIG=${CONFIG:-bl-x86_64-linux}
7+
LOG_DIR=${LOG_DIR:-_logs/logs_ut}
8+
SUMMARY_FILE=${SUMMARY_FILE:-_logs/ut_summary.md}
9+
mkdir -p "${LOG_DIR}" || true
10+
11+
declare -A UT_TARGET_GROUPS=(
12+
[baselibs]="@score_baselibs//score/... -- \
13+
-@score_baselibs//score/language/safecpp/aborts_upon_exception:abortsuponexception_toolchain_test \
14+
-@score_baselibs//score/containers:dynamic_array_test" # nok, error in @score_baselibs//score/json/examples:json_buffer
15+
[communication]="@score_communication//score/..." # nok, error from trlc in score_communication//score/mw/com/requirements/feature_requirements
16+
[persistency]="@score_persistency//:unit_tests" # ok
17+
[orchestrator]="@score_orchestrator//src/..." # ok
18+
[kyron]="@score_kyron//:unit_tests" # ok
19+
[feo]="@score_feo//... --build_tests_only" # ok (flag required or error from docs)
20+
)
21+
22+
# Markdown table header
23+
echo -e "Status\tPassed\tFailed\tSkipped\tTotal\tGroup\tDuration(s)" >> "${SUMMARY_FILE}"
24+
25+
for group in "${!UT_TARGET_GROUPS[@]}"; do
26+
targets="${UT_TARGET_GROUPS[$group]}"
27+
command="bazel test --config="${CONFIG}" ${targets}"
28+
echo "==========================================="
29+
echo "Running unit tests for group: $group"
30+
echo "${command}"
31+
echo "==========================================="
32+
start_ts=$(date +%s)
33+
out=$(bazel test --test_summary=testcase --test_output=errors --nocache_test_results --config="${CONFIG}" ${targets} 2>&1 | tee "${LOG_DIR}/ut_${group}_output.log")
34+
build_status=${PIPESTATUS[0]}
35+
end_ts=$(date +%s)
36+
duration=$(( end_ts - start_ts ))
37+
38+
# Parse bazel output
39+
tests_passed=$(echo "$out" | grep -Eo '[0-9]+ passing' | grep -Eo '[0-9]+' | head -n1)
40+
tests_failed=$(echo "$out" | grep -Eo '[0-9]+ failing' | grep -Eo '[0-9]+' | head -n1)
41+
tests_skipped=$(echo "$out" | grep -Eo '[0-9]+ skipped' | grep -Eo '[0-9]+' | head -n1)
42+
tests_executed=$(echo "$out" | grep -Eo '[0-9]+ test cases' | grep -Eo '[0-9]+' | head -n1)
43+
if [[ ${build_status} -eq 0 ]]; then
44+
status_symbol=""
45+
else
46+
status_symbol=""
47+
fi
48+
49+
# Append as a markdown table row
50+
echo -e "${status_symbol}\t${tests_passed}\t${tests_failed}\t${tests_skipped}\t${tests_executed}\t${group}\t${duration}s" >> "${SUMMARY_FILE}"
51+
echo "==========================================="
52+
echo -e "\n\n"
53+
done
54+
55+
# Align the summary table columns
56+
column -t -s $'\t' "${SUMMARY_FILE}" > "${SUMMARY_FILE}.tmp" && mv "${SUMMARY_FILE}.tmp" "${SUMMARY_FILE}"

0 commit comments

Comments
 (0)