linting added to CI + bypass tags
Some checks failed
ci/woodpecker/push/fx_oracle Pipeline is pending
ci/woodpecker/push/gateway_mntx Pipeline is pending
ci/woodpecker/push/gateway_tron Pipeline is pending
ci/woodpecker/push/ledger Pipeline is pending
ci/woodpecker/push/payments_methods Pipeline is pending
ci/woodpecker/push/payments_orchestrator Pipeline is pending
ci/woodpecker/push/payments_quotation Pipeline is pending
ci/woodpecker/push/gateway_chain Pipeline is pending
ci/woodpecker/push/gateway_tgsettle Pipeline is pending
ci/woodpecker/push/notification Pipeline is pending
ci/woodpecker/push/billing_documents Pipeline failed
ci/woodpecker/push/callbacks Pipeline failed
ci/woodpecker/push/discovery Pipeline failed
ci/woodpecker/push/bff Pipeline failed
ci/woodpecker/push/frontend Pipeline failed
ci/woodpecker/push/billing_fees Pipeline failed
ci/woodpecker/push/fx_ingestor Pipeline failed

This commit is contained in:
Stephan D
2026-03-10 12:39:30 +01:00
parent 6cc0340ba3
commit 918dbe8bb5
21 changed files with 455 additions and 126 deletions

View File

@@ -0,0 +1,111 @@
#!/usr/bin/env sh
backend_service_modules() {
service="${1:-}"
case "${service}" in
bff)
cat <<'EOF'
api/pkg
api/edge/bff
EOF
;;
callbacks)
cat <<'EOF'
api/pkg
api/edge/callbacks
EOF
;;
billing_documents)
cat <<'EOF'
api/pkg
api/billing/documents
EOF
;;
billing_fees)
cat <<'EOF'
api/pkg
api/billing/fees
EOF
;;
discovery)
cat <<'EOF'
api/pkg
api/discovery
EOF
;;
fx_ingestor)
cat <<'EOF'
api/pkg
api/fx/storage
api/fx/ingestor
EOF
;;
fx_oracle)
cat <<'EOF'
api/pkg
api/fx/storage
api/fx/oracle
EOF
;;
gateway_chain)
cat <<'EOF'
api/pkg
api/gateway/chain
EOF
;;
gateway_mntx)
cat <<'EOF'
api/pkg
api/gateway/mntx
EOF
;;
gateway_tgsettle)
cat <<'EOF'
api/pkg
api/gateway/tgsettle
EOF
;;
gateway_tron)
cat <<'EOF'
api/pkg
api/gateway/tron
EOF
;;
ledger)
cat <<'EOF'
api/pkg
api/ledger
EOF
;;
notification)
cat <<'EOF'
api/pkg
api/notification
EOF
;;
payments_methods)
cat <<'EOF'
api/pkg
api/payments/storage
api/payments/methods
EOF
;;
payments_orchestrator)
cat <<'EOF'
api/pkg
api/payments/storage
api/payments/orchestrator
EOF
;;
payments_quotation)
cat <<'EOF'
api/pkg
api/payments/storage
api/payments/quotation
EOF
;;
*)
return 1
;;
esac
}

View File

@@ -0,0 +1,56 @@
#!/usr/bin/env sh
set -eu
if ! set -o pipefail 2>/dev/null; then
:
fi
SERVICE="${1:-}"
if [ -z "${SERVICE}" ]; then
echo "usage: $0 <service-key>" >&2
exit 2
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
cd "${REPO_ROOT}"
if bypass_reason="$(sh "${SCRIPT_DIR}/should_bypass_backend_check.sh" "${SERVICE}" lint)"; then
echo "[backend-lint] ${bypass_reason}"
exit 0
fi
if ! command -v golangci-lint >/dev/null 2>&1; then
echo "[backend-lint] golangci-lint is required in PATH" >&2
exit 1
fi
# shellcheck source=ci/scripts/common/backend_modules.sh
. "${SCRIPT_DIR}/backend_modules.sh"
if ! modules="$(backend_service_modules "${SERVICE}")"; then
echo "[backend-lint] unknown service key: ${SERVICE}" >&2
exit 2
fi
run_go_lint() {
module="$1"
if [ ! -f "${module}/go.mod" ]; then
echo "[backend-lint] missing go.mod for module: ${module}" >&2
exit 1
fi
if [ ! -f "${module}/.golangci.yml" ]; then
echo "[backend-lint] missing .golangci.yml for module: ${module}" >&2
exit 1
fi
echo "[backend-lint] running golangci-lint in ${module}"
(
cd "${module}"
golangci-lint run --timeout=10m ./...
)
}
for module in ${modules}; do
run_go_lint "${module}"
done

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
set -eu
if ! set -o pipefail 2>/dev/null; then
@@ -11,9 +11,23 @@ if [ -z "${SERVICE}" ]; then
exit 2
fi
REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
cd "${REPO_ROOT}"
if bypass_reason="$(sh "${SCRIPT_DIR}/should_bypass_backend_check.sh" "${SERVICE}" tests)"; then
echo "[backend-tests] ${bypass_reason}"
exit 0
fi
# shellcheck source=ci/scripts/common/backend_modules.sh
. "${SCRIPT_DIR}/backend_modules.sh"
if ! modules="$(backend_service_modules "${SERVICE}")"; then
echo "[backend-tests] unknown service key: ${SERVICE}" >&2
exit 2
fi
run_go_tests() {
module="$1"
if [ ! -f "${module}/go.mod" ]; then
@@ -28,114 +42,6 @@ run_go_tests() {
)
}
case "${SERVICE}" in
bff)
modules="
api/pkg
api/edge/bff
"
;;
callbacks)
modules="
api/pkg
api/edge/callbacks
"
;;
billing_documents)
modules="
api/pkg
api/billing/documents
"
;;
billing_fees)
modules="
api/pkg
api/billing/fees
"
;;
discovery)
modules="
api/pkg
api/discovery
"
;;
fx_ingestor)
modules="
api/pkg
api/fx/storage
api/fx/ingestor
"
;;
fx_oracle)
modules="
api/pkg
api/fx/storage
api/fx/oracle
"
;;
gateway_chain)
modules="
api/pkg
api/gateway/chain
"
;;
gateway_mntx)
modules="
api/pkg
api/gateway/mntx
"
;;
gateway_tgsettle)
modules="
api/pkg
api/gateway/tgsettle
"
;;
gateway_tron)
modules="
api/pkg
api/gateway/tron
"
;;
ledger)
modules="
api/pkg
api/ledger
"
;;
notification)
modules="
api/pkg
api/notification
"
;;
payments_methods)
modules="
api/pkg
api/payments/storage
api/payments/methods
"
;;
payments_orchestrator)
modules="
api/pkg
api/payments/storage
api/payments/orchestrator
"
;;
payments_quotation)
modules="
api/pkg
api/payments/storage
api/payments/quotation
"
;;
*)
echo "[backend-tests] unknown service key: ${SERVICE}" >&2
exit 2
;;
esac
for module in ${modules}; do
run_go_tests "${module}"
done

View File

@@ -0,0 +1,77 @@
#!/usr/bin/env sh
set -eu
SERVICE="${1:-}"
CHECK="${2:-}"
if [ -z "${SERVICE}" ] || [ -z "${CHECK}" ]; then
echo "usage: $0 <service-key> <lint|tests>" >&2
exit 2
fi
COMMIT_MESSAGE="${WOODPECKER_COMMIT_MESSAGE:-${CI_COMMIT_MESSAGE:-${GIT_COMMIT_MESSAGE:-}}}"
if [ -z "${COMMIT_MESSAGE}" ]; then
exit 1
fi
contains_token() {
token="$1"
printf '%s' "${COMMIT_MESSAGE}" | grep -Fq -- "${token}"
}
emit_skip() {
token="$1"
scope="$2"
printf 'bypass enabled by token %s (%s scope)' "${token}" "${scope}"
exit 0
}
if contains_token "[skip-checks]"; then
emit_skip "[skip-checks]" "all-modules"
fi
if contains_token "[skip-checks:all]"; then
emit_skip "[skip-checks:all]" "all-modules"
fi
if contains_token "[skip-checks:${SERVICE}]"; then
emit_skip "[skip-checks:${SERVICE}]" "service"
fi
case "${CHECK}" in
lint)
if contains_token "[skip-lint]"; then
emit_skip "[skip-lint]" "all-modules"
fi
if contains_token "[skip-lint:all]"; then
emit_skip "[skip-lint:all]" "all-modules"
fi
if contains_token "[skip-lint:${SERVICE}]"; then
emit_skip "[skip-lint:${SERVICE}]" "service"
fi
;;
tests)
if contains_token "[skip-tests]"; then
emit_skip "[skip-tests]" "all-modules"
fi
if contains_token "[skip-tests:all]"; then
emit_skip "[skip-tests:all]" "all-modules"
fi
if contains_token "[skip-tests:${SERVICE}]"; then
emit_skip "[skip-tests:${SERVICE}]" "service"
fi
if contains_token "[skip-autotests]"; then
emit_skip "[skip-autotests]" "all-modules"
fi
if contains_token "[skip-autotests:all]"; then
emit_skip "[skip-autotests:all]" "all-modules"
fi
if contains_token "[skip-autotests:${SERVICE}]"; then
emit_skip "[skip-autotests:${SERVICE}]" "service"
fi
;;
*)
echo "unsupported check: ${CHECK}" >&2
exit 2
;;
esac
exit 1