mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 07:24:55 +08:00
47 lines
1.7 KiB
Bash
47 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "${repo_root}"
|
|
|
|
: "${GOCACHE:=/tmp/bat-go-cache}"
|
|
export GOCACHE
|
|
: "${XDG_CACHE_HOME:=/tmp/bat-xdg-cache}"
|
|
export XDG_CACHE_HOME
|
|
|
|
source "${repo_root}/scripts/ci-versions.sh"
|
|
export GOLANGCI_LINT_VERSION
|
|
|
|
run_required() {
|
|
local name="$1"
|
|
shift
|
|
printf 'RUN required: %s\n' "${name}"
|
|
"$@"
|
|
printf 'PASS required: %s\n' "${name}"
|
|
}
|
|
|
|
run_required "Rust formatting" cargo fmt --all -- --check
|
|
run_required "Go formatting" make check-go-format
|
|
run_required "Rust check" cargo check --workspace --locked
|
|
run_required "Rust release build" cargo build --workspace --release --locked
|
|
run_required "Rust clippy" cargo clippy --workspace --all-targets --locked -- -D warnings
|
|
run_required "Rust tests" cargo test --workspace --locked
|
|
run_required "Go API tests" go test ./internal/api/... ./internal/backendrpc/... ./cmd/bat-api/...
|
|
run_required "Go API vet" go vet ./internal/api/... ./internal/backendrpc/... ./cmd/bat-api/...
|
|
run_required "Go API build" go build -o /tmp/bat-api ./cmd/bat-api
|
|
run_required "Go lint version" bash -c '
|
|
source scripts/ci-versions.sh
|
|
command -v golangci-lint >/dev/null 2>&1 ||
|
|
{ printf "golangci-lint %s is required but not installed\n" "${GOLANGCI_LINT_VERSION}" >&2; exit 1; }
|
|
actual="$(golangci_lint_actual_version)"
|
|
if [[ "${actual}" != "${GOLANGCI_LINT_VERSION}" ]]; then
|
|
printf "golangci-lint version mismatch: required=%s actual=%s\n" \
|
|
"${GOLANGCI_LINT_VERSION}" "${actual:-unknown}" >&2
|
|
exit 1
|
|
fi
|
|
'
|
|
run_required "Go lint" golangci-lint run ./...
|
|
run_required "Documentation, OpenAPI, and contract checks" make check-docs
|
|
|
|
printf 'all required check-only gates passed\n'
|