Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .ci/ci-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ show_help() {
Usage: $SCRIPT_NAME <command> [options]

Commands:
collect-data <toolchain> <test_output> [functional_output]
collect-data <toolchain> <commit_sha> <commit_short> <github_repo> <test_output> [functional_output]
Extract and store test data from CI outputs

aggregate <results_dir> <output_file>
Expand All @@ -27,7 +27,7 @@ Commands:
Print clean TOML report

Examples:
$SCRIPT_NAME collect-data gnu "\$test_output" "\$functional_output"
$SCRIPT_NAME collect-data gnu "\$COMMIT_SHA" "\$COMMIT_SHORT" "\$GITHUB_REPO" "\$test_output" "\$functional_output"
$SCRIPT_NAME aggregate all-test-results test-summary.toml
$SCRIPT_NAME format-comment test-summary.toml
$SCRIPT_NAME post-comment test-summary.toml 123
Expand All @@ -38,8 +38,11 @@ EOF
# Data collection function
collect_data() {
local toolchain=${1:-unknown}
local test_output=${2:-}
local functional_output=${3:-}
local commit_sha=${2:-}
local commit_short=${3:-}
local github_repo=${4:-}
local test_output=${5:-}
local functional_output=${6:-}

if [ -z "$test_output" ]; then
echo "Error: test_output required"
Expand All @@ -48,6 +51,9 @@ collect_data() {

mkdir -p test-results
echo "$toolchain" > test-results/toolchain
echo "$commit_sha" > test-results/commit_sha
echo "$commit_short" > test-results/commit_short
echo "$github_repo" > test-results/github_repo

# Extract app data
echo "$test_output" | grep "APP_STATUS:" | sed 's/APP_STATUS://' > test-results/apps_data || touch test-results/apps_data
Expand Down Expand Up @@ -103,6 +109,7 @@ aggregate_results() {
llvm_build="failed" llvm_crash="failed" llvm_functional="failed"
overall="failed"
apps_data="" functional_data="" functional_criteria_data=""
commit_sha="" commit_short="" github_repo=""

# Process artifacts
for artifact_dir in "$results_dir"/test-results-*; do
Expand All @@ -112,6 +119,13 @@ aggregate_results() {
crash_exit=$(cat "$artifact_dir/crash_exit_code" 2> /dev/null || echo "1")
functional_exit=$(cat "$artifact_dir/functional_exit_code" 2> /dev/null || echo "1")

# Read commit info from first artifact (same across all toolchains)
if [ -z "$commit_sha" ]; then
commit_sha=$(cat "$artifact_dir/commit_sha" 2> /dev/null || echo "")
commit_short=$(cat "$artifact_dir/commit_short" 2> /dev/null || echo "")
github_repo=$(cat "$artifact_dir/github_repo" 2> /dev/null || echo "")
fi

build_status="passed"
# Handle skipped tests
if [ "$crash_exit" = "skipped" ]; then
Expand Down Expand Up @@ -174,6 +188,9 @@ aggregate_results() {
[summary]
status = "$overall"
timestamp = "$(date -Iseconds)"
commit_sha = "$commit_sha"
commit_short = "$commit_short"
github_repo = "$github_repo"

[info]
architecture = "riscv32"
Expand Down Expand Up @@ -275,6 +292,9 @@ format_comment() {
# Extract basic info
overall_status=$(get_value "summary" "status" "$toml_file")
timestamp=$(get_value "summary" "timestamp" "$toml_file")
commit_sha=$(get_value "summary" "commit_sha" "$toml_file")
commit_short=$(get_value "summary" "commit_short" "$toml_file")
github_repo=$(get_value "summary" "github_repo" "$toml_file")
gnu_build=$(get_value "gnu" "build" "$toml_file")
gnu_crash=$(get_value "gnu" "crash" "$toml_file")
gnu_functional=$(get_value "gnu" "functional" "$toml_file")
Expand All @@ -283,11 +303,21 @@ format_comment() {
llvm_functional=$(get_value "llvm" "functional" "$toml_file")

# Generate comment
# Build commit link if we have repo and SHA
commit_info=""
if [ -n "$github_repo" ] && [ -n "$commit_sha" ] && [ -n "$commit_short" ]; then
commit_url="https://github.com/$github_repo/commit/$commit_sha"
commit_info="**Commit:** [\`$commit_short\`]($commit_url)"
else
commit_info="**Commit:** (not available)"
fi

cat << EOF
## Linmo CI Test Results

**Overall Status:** $(get_symbol "$overall_status") $overall_status
**Timestamp:** $timestamp
$commit_info

### Toolchain Results

Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ jobs:
if: always()
run: |
set -euo pipefail
COMMIT_SHA="${{ github.sha }}"
COMMIT_SHORT=$(git rev-parse --short HEAD 2>/dev/null || echo "${{ github.sha }}" | cut -c1-7)
GITHUB_REPO="${{ github.repository }}"

if [ "${{ matrix.toolchain }}" = "llvm" ]; then
# LLVM: Build-only validation, skip tests
mkdir -p test-results
echo "${{ matrix.toolchain }}" > test-results/toolchain
echo "$COMMIT_SHA" > test-results/commit_sha
echo "$COMMIT_SHORT" > test-results/commit_short
echo "$GITHUB_REPO" > test-results/github_repo
echo "skipped" > test-results/crash_exit_code
echo "skipped" > test-results/functional_exit_code

Expand All @@ -163,7 +170,7 @@ jobs:
echo "LLVM toolchain: Build validation only (tests skipped)"
else
# GNU: Full test suite
.ci/ci-tools.sh collect-data "${{ matrix.toolchain }}" "${{ steps.test.outputs.TEST_OUTPUT }}" "${{ steps.functional_test.outputs.FUNCTIONAL_TEST_OUTPUT }}"
.ci/ci-tools.sh collect-data "${{ matrix.toolchain }}" "$COMMIT_SHA" "$COMMIT_SHORT" "$GITHUB_REPO" "${{ steps.test.outputs.TEST_OUTPUT }}" "${{ steps.functional_test.outputs.FUNCTIONAL_TEST_OUTPUT }}"
fi

- name: Upload Test Results
Expand Down