From f16e721d019c5a2ecf6ffab9a6029502218bbcbe Mon Sep 17 00:00:00 2001 From: Li Jie Date: Sat, 8 Jun 2024 11:03:35 +0800 Subject: [PATCH] ci: comment test result on PR --- .github/workflows/go.yml | 2 +- .github/workflows/test_demo.sh | 9 ++++++--- .../run.sh => .github/workflows/test_llgo.sh | 19 +++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) rename _test/run.sh => .github/workflows/test_llgo.sh (56%) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 13c496bb..9350681e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -64,7 +64,7 @@ jobs: - name: LLGO tests run: | - echo "Test result on ${{ matrix.os }} with LLVM ${{ matrix.llvm }}" > result.txt + echo "Test result on ${{ matrix.os }} with LLVM ${{ matrix.llvm }}" > result.md LLGOROOT=$PWD bash .github/workflows/test_llgo.sh - name: Test _demo and _pydemo diff --git a/.github/workflows/test_demo.sh b/.github/workflows/test_demo.sh index c10cd020..6a4a5fb2 100644 --- a/.github/workflows/test_demo.sh +++ b/.github/workflows/test_demo.sh @@ -11,16 +11,19 @@ for d in ./_demo/* ./_pydemo/*; do if ! llgo run -v "$d"; then echo "FAIL" failed=$((failed+1)) - failed_cases="$failed_cases\n$d" + failed_cases="$failed_cases\n* :x: $d" else echo "PASS" fi fi done - echo "=== Done" echo "$((total-failed))/$total tests passed" + if [ "$failed" -ne 0 ]; then - echo -e "Failed cases:$failed_cases" + echo ":bangbang: Failed demo cases:" | tee -a result.md + echo -e "$failed_cases" | tee -a result.md exit 1 +else + echo ":white_check_mark: All demo tests passed" | tee -a result.md fi diff --git a/_test/run.sh b/.github/workflows/test_llgo.sh similarity index 56% rename from _test/run.sh rename to .github/workflows/test_llgo.sh index d048155d..e1838fa5 100644 --- a/_test/run.sh +++ b/.github/workflows/test_llgo.sh @@ -1,10 +1,15 @@ #!/bin/bash set -e + +export LLGOROOT=$PWD + testcmd=/tmp/test llgo build -o $testcmd ./_test cases=$($testcmd) total=$(echo "$cases" | wc -l | tr -d ' ') -succ=0 +failed=0 +failed_cases="" + for idx in $(seq 1 $((total))); do case=$(echo "$cases" | sed -n "${idx}p") case_name=$(echo "$case" | cut -d',' -f2) @@ -15,13 +20,19 @@ for idx in $(seq 1 $((total))); do set -e if [ "${exit_code:-0}" -ne 0 ]; then echo "failed: $out" + failed=$((failed+1)) + failed_cases="$failed_cases\n* :x: $case_name" else - succ=$((succ+1)) echo "passed" fi done echo "=== Done" -echo "$succ/$total tests passed" -if [ "$total" -ne "$succ" ]; then +echo "$((total-failed))/$total tests passed" + +if [ "$failed" -ne 0 ]; then + echo ":bangbang: Failed llgo cases:" | tee -a result.md + echo -e "$failed_cases" | tee -a result.md exit 1 +else + echo ":white_check_mark: All llgo tests passed" | tee -a result.md fi