poc
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 23s
unit-tests Bats test report
CI Feature / Bats tests (push) Failing after 1m34s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Failing after 1m35s
CI Feature / Report Summary (push) Successful in 5s
POC GitOps E2E / e2e (push) Failing after 35s
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 23s
unit-tests Bats test report
CI Feature / Bats tests (push) Failing after 1m34s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Failing after 1m35s
CI Feature / Report Summary (push) Successful in 5s
POC GitOps E2E / e2e (push) Failing after 35s
This commit is contained in:
@@ -17,6 +17,11 @@ POLL_INTERVAL="${DISPATCH_POLL_INTERVAL:-10}"
|
||||
[ -z "$GITEA_API_URL" ] && echo "ERROR: gitea_api_url argument is required" >&2 && exit 1
|
||||
[ -z "$GITEA_TOKEN" ] && echo "ERROR: gitea_token argument is required" >&2 && exit 1
|
||||
|
||||
# Generate unique dispatch_id for display_title matching
|
||||
# Can be overridden via DISPATCH_ID env var (for tests)
|
||||
DISPATCH_ID="${DISPATCH_ID:-$(xxd -l 4 -p /dev/urandom 2>/dev/null || openssl rand -hex 4 2>/dev/null || date +%s | md5sum | head -c 8)}"
|
||||
INPUTS_JSON=$(echo "$INPUTS_JSON" | jq --arg id "$DISPATCH_ID" '. + {dispatch_id: $id}')
|
||||
|
||||
DISPATCH_URL="$GITEA_API_URL/api/v1/repos/$TARGET_REPO/actions/workflows/$WORKFLOW_FILE/dispatches"
|
||||
DISPATCH_BODY=$(jq -nc --arg ref "$REF" --argjson inputs "$INPUTS_JSON" '{ref: $ref, inputs: $inputs}')
|
||||
|
||||
@@ -32,19 +37,30 @@ if [ "$DISPATCH_CODE" != "201" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RUNS_URL="$GITEA_API_URL/api/v1/repos/$TARGET_REPO/actions/runs?status=running"
|
||||
RUNS_RESP=$(curl -s --connect-timeout 5 --max-time 10 \
|
||||
-H "Authorization: token $GITEA_TOKEN" "$RUNS_URL")
|
||||
|
||||
RUN_ID=$(echo "$RUNS_RESP" | jq -r '.workflow_runs[0].id // empty')
|
||||
if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then
|
||||
echo "ERROR: Could not find dispatched workflow run" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Poll: find dispatched run by display_title matching
|
||||
RUN_ID=""
|
||||
TIMEOUT_SECONDS=$(awk "BEGIN {printf \"%.3f\", $TIMEOUT_MINUTES * 60}")
|
||||
START_TIME=$(date +%s)
|
||||
|
||||
while [ -z "$RUN_ID" ]; do
|
||||
NOW=$(date +%s)
|
||||
ELAPSED=$((NOW - START_TIME))
|
||||
if awk -v e="$ELAPSED" -v t="$TIMEOUT_SECONDS" 'BEGIN { exit !(e >= t) }'; then
|
||||
echo "ERROR: Timeout after ${TIMEOUT_MINUTES} minutes — run not found" >&2
|
||||
exit 124
|
||||
fi
|
||||
|
||||
RUNS_RESP=$(curl -s --connect-timeout 5 --max-time 10 \
|
||||
"$GITEA_API_URL/api/v1/repos/$TARGET_REPO/actions/runs?event=workflow_dispatch&limit=10" \
|
||||
-H "Authorization: token $GITEA_TOKEN")
|
||||
|
||||
RUN_ID=$(echo "$RUNS_RESP" | jq -r --arg id "$DISPATCH_ID" \
|
||||
'[.workflow_runs[] | select(.display_title | contains($id))] | .[0].id // empty')
|
||||
|
||||
[ -z "$RUN_ID" ] && sleep "$POLL_INTERVAL"
|
||||
done
|
||||
|
||||
# Poll: wait for run to complete
|
||||
while true; do
|
||||
NOW=$(date +%s)
|
||||
ELAPSED=$((NOW - START_TIME))
|
||||
|
||||
@@ -7,21 +7,14 @@ _gitops_fail() {
|
||||
local MSG="${1:-GitOps update failed}"
|
||||
echo "[ERROR] ${MSG}" >&2
|
||||
|
||||
if [ -n "${SOURCE_REPO:-}" ] && [ -n "${SOURCE_COMMIT:-}" ] && \
|
||||
if [ -n "${GITOPS_REPO:-}" ] && [ -n "${GITOPS_SHA:-}" ] && \
|
||||
[ -n "${SOURCE_REPO:-}" ] && [ -n "${SOURCE_COMMIT:-}" ] && \
|
||||
[ -n "${GITEA_API_URL:-}" ] && [ -n "${GITEA_TOKEN:-}" ]; then
|
||||
local GITOPS_URL="${GITEA_API_URL}/${GITOPS_REPO:-unknown}/commits/${GITOPS_SHA:-unknown}"
|
||||
ROOT_REPO="${SOURCE_REPO}" ROOT_COMMIT="${SOURCE_COMMIT}" \
|
||||
local SOURCE_URL="${GITEA_API_URL}/${SOURCE_REPO}/commits/${SOURCE_COMMIT}"
|
||||
ROOT_REPO="${GITOPS_REPO}" ROOT_COMMIT="${GITOPS_SHA}" \
|
||||
GITEA_API_URL="${GITEA_API_URL}" GITEA_TOKEN="${GITEA_TOKEN}" \
|
||||
bash "${SCRIPT_DIR}/report-status.sh" failure "${MSG}" \
|
||||
"gitops/${SOURCE_REPO}" "" "${GITOPS_URL}" 2>/dev/null || true
|
||||
|
||||
if [ -n "${GITOPS_REPO:-}" ] && [ -n "${GITOPS_SHA:-}" ]; then
|
||||
local SOURCE_URL="${GITEA_API_URL}/${SOURCE_REPO}/commits/${SOURCE_COMMIT}"
|
||||
ROOT_REPO="${GITOPS_REPO}" ROOT_COMMIT="${GITOPS_SHA}" \
|
||||
GITEA_API_URL="${GITEA_API_URL}" GITEA_TOKEN="${GITEA_TOKEN}" \
|
||||
bash "${SCRIPT_DIR}/report-status.sh" failure "${MSG}" \
|
||||
"source/${SOURCE_REPO}" "" "${SOURCE_URL}" 2>/dev/null || true
|
||||
fi
|
||||
"source/${SOURCE_REPO}" "" "${SOURCE_URL}" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
exit 1
|
||||
@@ -39,14 +32,8 @@ _gitops_validate() {
|
||||
}
|
||||
|
||||
_gitops_success() {
|
||||
local GITOPS_URL="${GITEA_API_URL}/${GITOPS_REPO}/commits/${GITOPS_SHA}"
|
||||
local SOURCE_URL="${GITEA_API_URL}/${SOURCE_REPO}/commits/${SOURCE_COMMIT}"
|
||||
|
||||
ROOT_REPO="${SOURCE_REPO}" ROOT_COMMIT="${SOURCE_COMMIT}" \
|
||||
GITEA_API_URL="${GITEA_API_URL}" GITEA_TOKEN="${GITEA_TOKEN}" \
|
||||
bash "${SCRIPT_DIR}/report-status.sh" success "GitOps updated to ${VERSION}" \
|
||||
"gitops/${SOURCE_REPO}" "" "${GITOPS_URL}"
|
||||
|
||||
ROOT_REPO="${GITOPS_REPO}" ROOT_COMMIT="${GITOPS_SHA}" \
|
||||
GITEA_API_URL="${GITEA_API_URL}" GITEA_TOKEN="${GITEA_TOKEN}" \
|
||||
bash "${SCRIPT_DIR}/report-status.sh" success "Source build" \
|
||||
|
||||
Reference in New Issue
Block a user