ci(api): 增加 Go API 门禁

This commit is contained in:
2026-07-31 12:55:43 +08:00
parent 03021ad649
commit 8ec0e12795
+77
View File
@@ -161,3 +161,80 @@ jobs:
cd .. cd ..
ls -lh bat-linux-x86_64.zip 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