name: CI 测试 on: push: branches: [main] tags: ["v*"] pull_request: workflow_dispatch: # 镜像发布不再走 CI:GoReleaser Pro(本地 goreleaser release --clean) # 负责多平台归档 + Gitea Release + ACR 双架构镜像(见 .goreleaser.yaml)。 # 本工作流只做推送/PR 前置测试门禁。 jobs: test: name: go vet + go test runs-on: ubuntu-latest container: image: golang:1.27.1-alpine timeout-minutes: 30 steps: - name: 安装工具并检出 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories apk add --no-cache git curl bash >/dev/null SCHEME="${GITHUB_SERVER_URL%%://*}" SRV="${GITHUB_SERVER_URL#*://}" echo "clone from ${SCHEME}://${SRV}" git clone --depth=1 --branch "$GITHUB_REF_NAME" \ "${SCHEME}://oauth2:${GITHUB_TOKEN}@${SRV}/${GITHUB_REPOSITORY}.git" . - name: go vet + go test working-directory: server env: GOCACHE: /tmp/.gocache GOMODCACHE: /tmp/.gomodcache CGO_ENABLED: "0" run: | go vet ./... go test ./... -count=1