From beef5565563bcc1ae2025583143952c4b881a078 Mon Sep 17 00:00:00 2001 From: moilanik Date: Sun, 28 Jun 2026 09:22:30 +0300 Subject: [PATCH] raportointi muutoksia --- scripts/ci-report.sh | 9 ++++----- scripts/publish-git-pages.sh | 6 ++++++ tests/publish-git-pages.bats | 10 +++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/ci-report.sh b/scripts/ci-report.sh index 0f32046..6944420 100644 --- a/scripts/ci-report.sh +++ b/scripts/ci-report.sh @@ -81,11 +81,10 @@ generate_index() { } > "$REPORT_DIR/index.html" } -STAGED="reports/${SHA8}/${SUITE}" -mkdir -p "$STAGED" +mkdir -p "$SUITE" if [ "$TOTAL" -eq 1 ]; then - cp -a "$REPORT_DIR/." "$STAGED/" + cp -a "$REPORT_DIR/." "$SUITE/" sh .ci/scripts/publish-git-pages.sh "$SUITE" first_entry=$(echo "$ENTRIES" | head -1) @@ -102,9 +101,9 @@ if [ "$TOTAL" -eq 1 ]; then sh .ci/scripts/report-status.sh "$STATUS" "$DESCRIPTION" "$CONTEXT" "" "$URL" else generate_index - cp -a "$REPORT_DIR/." "$STAGED/" + cp -a "$REPORT_DIR/." "$SUITE/" sh .ci/scripts/publish-git-pages.sh "$SUITE" sh .ci/scripts/report-status.sh "$STATUS" "$DESCRIPTION" "$CONTEXT" "$SUITE" fi -rm -rf "$STAGED" +rm -rf "$SUITE" diff --git a/scripts/publish-git-pages.sh b/scripts/publish-git-pages.sh index ca39099..96fedee 100755 --- a/scripts/publish-git-pages.sh +++ b/scripts/publish-git-pages.sh @@ -19,6 +19,12 @@ PAGES_USER="${GIT_PAGES_PUBLISH_USER:-publish}" [ -d "$SUITE" ] || { echo "ERROR: not a directory: $SUITE" >&2; exit 1; } +EMPTY=1 +for _f in "$SUITE"/* "$SUITE"/.*; do + [ -e "$_f" ] && { EMPTY=0; break; } +done +[ "$EMPTY" -eq 0 ] || { echo "ERROR: no files to publish in $SUITE" >&2; exit 1; } + WORK=$(mktemp -d) TAR=$(mktemp) trap 'rm -rf "$WORK" "$TAR"' EXIT diff --git a/tests/publish-git-pages.bats b/tests/publish-git-pages.bats index 1a917ed..c83e256 100644 --- a/tests/publish-git-pages.bats +++ b/tests/publish-git-pages.bats @@ -15,7 +15,7 @@ setup() { teardown() { mock_stop - rm -rf "unit-tests" "sub" + rm -rf "unit-tests" "sub" "empty-suite" } @test "missing suite_path argument → exit 1" { @@ -58,6 +58,14 @@ teardown() { [[ "$output" == *"not a directory"* ]] } +@test "empty directory → exit 1" { + mkdir -p "empty-suite" + run bash scripts/publish-git-pages.sh "empty-suite" + [ "$status" -eq 1 ] + [[ "$output" == *"no files to publish"* ]] + rm -rf "empty-suite" +} + @test "valid publish returns report base URL" { mock_set_sequence '[ {"code":200,"body":"published"}