From 8ec0e127954ddfd3560d0458bade47728545df48 Mon Sep 17 00:00:00 2001 From: Yuyi-Oak <1722157266@qq.com> Date: Fri, 31 Jul 2026 12:55:43 +0800 Subject: [PATCH] =?UTF-8?q?ci(api):=20=E5=A2=9E=E5=8A=A0=20Go=20API=20?= =?UTF-8?q?=E9=97=A8=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/bat.yml | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/.gitea/workflows/bat.yml b/.gitea/workflows/bat.yml index 1a0cd35..1f6d0a9 100644 --- a/.gitea/workflows/bat.yml +++ b/.gitea/workflows/bat.yml @@ -161,3 +161,80 @@ jobs: cd .. ls -lh bat-linux-x86_64.zip + + go-api: + name: Build and test Go API + runs-on: linux + + env: + GOCACHE: /tmp/bat-go-cache + + steps: + - name: Checkout + shell: bash + run: | + set -euo pipefail + + : "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}" + : "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}" + : "${GITHUB_SHA:?GITHUB_SHA is required}" + + repo_url="${GITHUB_SERVER_URL%/}/${GITHUB_REPOSITORY}.git" + + if [ -d .git ]; then + git remote set-url origin "${repo_url}" + else + git init . + git remote add origin "${repo_url}" + fi + + ref="${GITHUB_REF:-${GITHUB_SHA}}" + + git fetch \ + --no-tags \ + --depth=1 \ + origin \ + "${ref}" \ + || git fetch \ + --no-tags \ + --depth=1 \ + origin \ + "${GITHUB_SHA}" + + git checkout --force --detach FETCH_HEAD + + git submodule update --init --recursive + + - name: Show Go tool version + shell: bash + run: | + set -euo pipefail + + source /var/lib/act_runner/env.sh + + command -v go + go version + + - name: Run Go API tests + shell: bash + run: | + set -euo pipefail + + source /var/lib/act_runner/env.sh + make test-go-api + + - name: Run Go API vet + shell: bash + run: | + set -euo pipefail + + source /var/lib/act_runner/env.sh + go vet ./internal/api/... ./internal/backendrpc/... ./cmd/bat-api/... + + - name: Build Go API + shell: bash + run: | + set -euo pipefail + + source /var/lib/act_runner/env.sh + go build -o /tmp/bat-api ./cmd/bat-api