bash -> sh
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 27s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Successful in 1m19s
unit-tests Bats test report
CI Feature / Bats tests (push) Failing after 2m0s
CI Feature / Report Summary (push) Successful in 5s

This commit is contained in:
moilanik
2026-06-20 13:06:02 +03:00
parent 4f20f5ae2f
commit bfd0428a78
3 changed files with 109 additions and 68 deletions
+64 -41
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
DESCRIPTION="${1:-}" DESCRIPTION="${1:-}"
CONTEXT="${2:-}" CONTEXT="${2:-}"
@@ -14,53 +14,71 @@ REPORT_DIR="reports/${SUITE}"
if [ ! -d "$REPORT_DIR" ]; then if [ ! -d "$REPORT_DIR" ]; then
echo "ERROR: $REPORT_DIR not found" >&2 echo "ERROR: $REPORT_DIR not found" >&2
bash .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT" sh .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT"
exit 1 exit 1
fi fi
FILES=() FILE_COUNT=0
while IFS= read -r -d '' f; do SUBDIR_COUNT=0
FILES+=("$(basename "$f")") ENTRIES=""
done < <(find "$REPORT_DIR" -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true)
SUBDIRS=() for f in "$REPORT_DIR"/*; do
while IFS= read -r -d '' d; do [ -f "$f" ] || continue
name="${d#$REPORT_DIR/}" base=$(basename "$f")
[ -f "$d/index.html" ] && SUBDIRS+=("$name") [ "$base" = "index.html" ] && continue
done < <(find "$REPORT_DIR" -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true) FILE_COUNT=$((FILE_COUNT + 1))
ENTRIES="${ENTRIES}file:${base}
"
done
TOTAL=$(( ${#FILES[@]} + ${#SUBDIRS[@]} )) for d in "$REPORT_DIR"/*/; do
[ -d "$d" ] || continue
base=$(basename "$d")
[ -f "$d/index.html" ] || continue
SUBDIR_COUNT=$((SUBDIR_COUNT + 1))
ENTRIES="${ENTRIES}dir:${base}
"
done
TOTAL=$((FILE_COUNT + SUBDIR_COUNT))
if [ "$TOTAL" -eq 0 ]; then if [ "$TOTAL" -eq 0 ]; then
echo "ERROR: no reportable items in $REPORT_DIR" >&2 echo "ERROR: no reportable items in $REPORT_DIR" >&2
bash .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT" sh .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT"
exit 1 exit 1
fi fi
SHA8="${GITHUB_SHA:0:8}" SHA8=$(echo "${GITHUB_SHA:-xxxxxxxx}" | cut -c1-8)
humanize() { humanize() {
local name="$1" name="$1"
name="${name%.*}" name=$(echo "$name" | sed -e 's/\.[^.]*$//' -e 's/[-_]/ /g')
name="${name//-/ }" first=$(echo "$name" | cut -c1 | tr '[:lower:]' '[:upper:]')
name="${name//_/ }" rest=$(echo "$name" | cut -c2-)
echo "${name^}" echo "${first}${rest}"
} }
generate_index() { generate_index() {
local html {
html='<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">' echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
html+="<title>$DESCRIPTION</title>" echo "<title>$DESCRIPTION</title>"
html+='<style>body{font-family:sans-serif;margin:2em;max-width:960px}h1{color:#1e293b}ul{list-style:none;padding:0}li{margin:.5em 0;padding:.5em;background:#f8fafc;border-radius:6px}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}</style>' echo '<style>body{font-family:sans-serif;margin:2em;max-width:960px}h1{color:#1e293b}ul{list-style:none;padding:0}li{margin:.5em 0;padding:.5em;background:#f8fafc;border-radius:6px}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}</style>'
html+="</head><body><h1>$DESCRIPTION</h1><ul>" echo "</head><body><h1>$DESCRIPTION</h1><ul>"
for f in "${FILES[@]}"; do
html+="<li><a href=\"$f\">$(humanize "$f")</a></li>" echo "$ENTRIES" | while IFS= read -r entry; do
done [ -z "$entry" ] && continue
for d in "${SUBDIRS[@]}"; do entry_type=$(echo "$entry" | cut -d: -f1)
html+="<li><a href=\"$d/index.html\">${d^}</a></li>" entry_name=$(echo "$entry" | cut -d: -f2-)
done if [ "$entry_type" = "file" ]; then
html+='</ul></body></html>' echo "<li><a href=\"$entry_name\">$(humanize "$entry_name")</a></li>"
printf '%s' "$html" > "$REPORT_DIR/index.html" else
cap=$(echo "$entry_name" | sed 's/\(.\).*/\1/' | tr '[:lower:]' '[:upper:]')$(echo "$entry_name" | sed 's/.//')
echo "<li><a href=\"$entry_name/index.html\">${cap}</a></li>"
fi
done
echo '</ul></body></html>'
} > "$REPORT_DIR/index.html"
} }
STAGED="reports/${SHA8}/${SUITE}" STAGED="reports/${SHA8}/${SUITE}"
@@ -68,20 +86,25 @@ mkdir -p "$STAGED"
if [ "$TOTAL" -eq 1 ]; then if [ "$TOTAL" -eq 1 ]; then
cp -a "$REPORT_DIR/." "$STAGED/" cp -a "$REPORT_DIR/." "$STAGED/"
bash .ci/scripts/publish-git-pages.sh "$SUITE" sh .ci/scripts/publish-git-pages.sh "$SUITE"
if [ ${#FILES[@]} -eq 1 ]; then first_entry=$(echo "$ENTRIES" | head -1)
ENTRY="${FILES[0]}" first_type=$(echo "$first_entry" | cut -d: -f1)
first_name=$(echo "$first_entry" | cut -d: -f2-)
if [ "$first_type" = "file" ]; then
SINGLE_ENTRY="$first_name"
else else
ENTRY="${SUBDIRS[0]}/index.html" SINGLE_ENTRY="${first_name}/index.html"
fi fi
URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${SHA8}/${SUITE}/${ENTRY}"
bash .ci/scripts/report-status.sh "$STATUS" "$DESCRIPTION" "$CONTEXT" "" "$URL" URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${SHA8}/${SUITE}/${SINGLE_ENTRY}"
sh .ci/scripts/report-status.sh "$STATUS" "$DESCRIPTION" "$CONTEXT" "" "$URL"
else else
generate_index generate_index
cp -a "$REPORT_DIR/." "$STAGED/" cp -a "$REPORT_DIR/." "$STAGED/"
bash .ci/scripts/publish-git-pages.sh "$SUITE" sh .ci/scripts/publish-git-pages.sh "$SUITE"
bash .ci/scripts/report-status.sh "$STATUS" "$DESCRIPTION" "$CONTEXT" "$SUITE" sh .ci/scripts/report-status.sh "$STATUS" "$DESCRIPTION" "$CONTEXT" "$SUITE"
fi fi
rm -rf "$STAGED" rm -rf "$STAGED"
+39 -21
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
SUITE_PATH="${1:-}" SUITE_PATH="${1:-}"
@@ -12,7 +12,7 @@ SUITE_PATH="${1:-}"
OWNER="${GITHUB_REPOSITORY%%/*}" OWNER="${GITHUB_REPOSITORY%%/*}"
REPO="${GITHUB_REPOSITORY##*/}" REPO="${GITHUB_REPOSITORY##*/}"
SHA8="${GITHUB_SHA:0:8}" SHA8=$(echo "$GITHUB_SHA" | cut -c1-8)
PAGES_USER="${GIT_PAGES_PUBLISH_USER:-publish}" PAGES_USER="${GIT_PAGES_PUBLISH_USER:-publish}"
REPORT_DIR="reports/${SHA8}/${SUITE_PATH%/}" REPORT_DIR="reports/${SHA8}/${SUITE_PATH%/}"
REPORT_BASE="${GIT_PAGES_URL}/${OWNER}/${REPO}/reports/${SHA8}" REPORT_BASE="${GIT_PAGES_URL}/${OWNER}/${REPO}/reports/${SHA8}"
@@ -33,17 +33,30 @@ else
fi fi
mkdir -p "$TARGET" mkdir -p "$TARGET"
cp -a "$REPORT_DIR/." "$TARGET/" cp -a "$REPORT_DIR/." "$TARGET/"
if [ ! -f "$TARGET/index.html" ]; then
items=()
while IFS= read -r -d '' f; do
items+=("$(basename "$f")")
done < <(find "$TARGET" -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true)
while IFS= read -r -d '' d; do
name=$(basename "$d")
[ -f "$d/index.html" ] && items+=("$name")
done < <(find "$TARGET" -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true)
if [ ${#items[@]} -gt 1 ]; then if [ ! -f "$TARGET/index.html" ]; then
ITEM_LIST=""
ITEM_COUNT=0
for f in "$TARGET"/*; do
[ -f "$f" ] || continue
base=$(basename "$f")
[ "$base" = "index.html" ] && continue
ITEM_LIST="${ITEM_LIST}file:${base}
"
ITEM_COUNT=$((ITEM_COUNT + 1))
done
for d in "$TARGET"/*/; do
[ -d "$d" ] || continue
base=$(basename "$d")
[ -f "$d/index.html" ] || continue
ITEM_LIST="${ITEM_LIST}dir:${base}
"
ITEM_COUNT=$((ITEM_COUNT + 1))
done
if [ "$ITEM_COUNT" -gt 1 ]; then
{ {
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">' echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
echo "<title>Test report ${SHA8}</title>" echo "<title>Test report ${SHA8}</title>"
@@ -53,16 +66,21 @@ if [ ! -f "$TARGET/index.html" ]; then
echo 'a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}' echo 'a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}'
echo '</style></head><body>' echo '</style></head><body>'
echo "<h1>Test report <code>${SHA8}</code></h1><ul>" echo "<h1>Test report <code>${SHA8}</code></h1><ul>"
for item in "${items[@]}"; do
label="${item%.*}" echo "$ITEM_LIST" | while IFS= read -r item; do
label="${label//-/ }" [ -z "$item" ] && continue
label="${label//_/ }" item_type=$(echo "$item" | cut -d: -f1)
if [ -f "$TARGET/$item" ]; then item_name=$(echo "$item" | cut -d: -f2-)
echo "<li><a href=\"$item\">${label^}</a></li>" label=$(echo "$item_name" | sed -e 's/\.[^.]*$//' -e 's/[-_]/ /g')
first=$(echo "$label" | cut -c1 | tr '[:lower:]' '[:upper:]')
rest=$(echo "$label" | cut -c2-)
if [ "$item_type" = "file" ]; then
echo "<li><a href=\"$item_name\">${first}${rest}</a></li>"
else else
echo "<li><a href=\"$item/index.html\">${label^}</a></li>" echo "<li><a href=\"$item_name/index.html\">${first}${rest}</a></li>"
fi fi
done done
echo '</ul></body></html>' echo '</ul></body></html>'
} > "$TARGET/index.html" } > "$TARGET/index.html"
fi fi
@@ -74,7 +92,7 @@ EOF
find "$WORK/$OWNER" \( -type f -o -type l \) -print | sed "s|^${WORK}/||" | tar -cf "$TAR" -C "$WORK" -T - find "$WORK/$OWNER" \( -type f -o -type l \) -print | sed "s|^${WORK}/||" | tar -cf "$TAR" -C "$WORK" -T -
publish() { publish() {
local method="$1" method="$1"
curl -sS -X "$method" "$PUBLISH_SITE_URL" \ curl -sS -X "$method" "$PUBLISH_SITE_URL" \
-u "${PAGES_USER}:${GIT_PAGES_PUBLISH_TOKEN}" \ -u "${PAGES_USER}:${GIT_PAGES_PUBLISH_TOKEN}" \
-H "Content-Type: application/x-tar" \ -H "Content-Type: application/x-tar" \
+6 -6
View File
@@ -1,11 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env sh
set -euo pipefail set -eu
# https://docs.gitea.com/api/next/#tag/repository/operation/repoCreateStatus
STATE="${1:-}" STATE="${1:-}"
DESCRIPTION="${2:-}" DESCRIPTION="${2:-}"
KEY="${3:-commit-${GITHUB_SHA:0:8}}" SHA8=$(echo "${GITHUB_SHA:-}" | cut -c1-8)
KEY="${3:-commit-${SHA8}}"
SUITE="${4:-}" SUITE="${4:-}"
CUSTOM_URL="${5:-}" CUSTOM_URL="${5:-}"
@@ -18,7 +17,8 @@ if [ -n "$CUSTOM_URL" ]; then
URL="$CUSTOM_URL" URL="$CUSTOM_URL"
elif [ -n "$SUITE" ]; then elif [ -n "$SUITE" ]; then
SUITE="${SUITE%/}/" SUITE="${SUITE%/}/"
URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${GITHUB_SHA:0:8}/${SUITE}" SHA8_CUT=$(echo "$GITHUB_SHA" | cut -c1-8)
URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${SHA8_CUT}/${SUITE}"
else else
URL="${GITEA_API_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" URL="${GITEA_API_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
fi fi