diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index c900f19..0bff015 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -30,6 +30,8 @@ env: BUILDKIT_PROGRESS: quiet DOCKER_BUILDKIT: 1 REGISTRY: git.sabilin.com/eventhub + CI_REPORTS_BASE_URL: https://ci-reports.dev.eventhub.local + RUNNER_STAND: dev jobs: test: diff --git a/scripts/publish-ci-report.sh b/scripts/publish-ci-report.sh index c39b4c6..a88c511 100644 --- a/scripts/publish-ci-report.sh +++ b/scripts/publish-ci-report.sh @@ -16,26 +16,12 @@ REPORTS_DIR="${CI_REPORTS_DIR:-/var/eventhub/ci-reports}" STAND="${RUNNER_STAND:-}" detect_stand() { - if [[ -n "${CI_REPORTS_BASE_URL:-}" ]]; then - echo "" - return 0 - fi - if [[ -n "${STAND}" ]]; then - echo "${STAND}" - return 0 - fi - if getent hosts ci-reports.ift.eventhub.local >/dev/null 2>&1 \ - || getent ahostsv4 ci-reports.ift.eventhub.local >/dev/null 2>&1; then - # Prefer ift if this host resolves ift reports (IFT runner DNS) - if [[ -f /opt/eventhub-ift/.env ]] || [[ -d /opt/eventhub-ift ]]; then - echo "ift" - return 0 - fi - fi - if [[ -d /opt/eventhub-ift ]]; then - echo "ift" + if [[ -n "${RUNNER_STAND:-}" ]]; then + echo "${RUNNER_STAND}" return 0 fi + # Gitea runner на dev-машине: отчёты в /var/eventhub/ci-reports локально. + # Наличие /opt/eventhub-ift (SSH deploy) не означает, что HTML лежит на IFT-сервере. echo "dev" } @@ -68,6 +54,19 @@ ensure_ci_reports_dir() { } ensure_ci_reports_dir +ensure_ci_reports_nginx() { + command -v docker >/dev/null 2>&1 || return 0 + local svc replicas + svc=$(docker service ls --format '{{.Name}}' 2>/dev/null | grep -E '^eventhub_ci-reports$' | head -n 1 || true) + [[ -n "${svc}" ]] || return 0 + replicas=$(docker service ls --format '{{.Name}} {{.Replicas}}' 2>/dev/null | awk '$1=="eventhub_ci-reports"{print $2; exit}') + if [[ "${replicas}" == 0/* ]] || [[ -z "${replicas}" ]]; then + echo "Starting ${svc}=1 (dev ci-reports nginx)..." + docker service scale "${svc}=1" 2>/dev/null || true + fi +} +ensure_ci_reports_nginx + DEST="${REPORTS_DIR}/${REPO}/${RUN_ID}/${KIND}" mkdir -p "${REPORTS_DIR}/${REPO}/${RUN_ID}" rm -rf "${DEST}" @@ -117,6 +116,7 @@ URL="${BASE_URL}/${REPO}/${RUN_ID}/${KIND}/" INDEX_URL="${BASE_URL}/${REPO}/${RUN_ID}/" echo "Report: ${URL}" echo "Report index: ${INDEX_URL}" +echo "Report path: ${DEST}" if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then { echo "### Test report"