mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-10-13 00:50:45 +00:00
The repository has 19 test files and nothing was running any of them. Both workflows build with go build, which does not compile _test.go, the Makefile's test target was commented out, and there is no pre-commit hook. Every test in the tree, including the schema guards that exist precisely to catch a silent breakage, only ran when someone remembered to type go test. Enables the commented-out target and calls it from go.yml, the one workflow that fires on every push and pull request. build.yml is left alone: it skips documentation-only changes and deploys on master, so it is the wrong place for a gate that should never be skipped. Runs with -race. common/actions reuses model instances across concurrent requests, so a Generate() that returns in place rather than a copy leaks data between them, which a single-threaded run cannot see. Verified locally: the suite passes under CGO_ENABLED=0 and under -race, and make test exits non-zero when a test fails, so the step actually gates. Claude-Session: https://claude.ai/code/session_01DJhM6LvhkNPej35wy9F7Aq
75 lines
2.1 KiB
YAML
75 lines
2.1 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, dev ]
|
|
tags: [ 'v*', '[0-9]*' ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
|
|
- name: Set up Go 1.26
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version: 1.26.5
|
|
id: go
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- name: Get dependencies
|
|
run: go mod tidy
|
|
|
|
# go build does not compile _test.go, so building alone never ran a single
|
|
# test. This is the only workflow that fires on every push and pull request,
|
|
# which makes it the one place a test gate belongs.
|
|
- name: Test
|
|
run: make test
|
|
|
|
- name: Build
|
|
run: make build
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
flavor: |
|
|
latest=auto
|
|
tags: |
|
|
type=schedule
|
|
type=ref,event=tag
|
|
type=sha,prefix=,format=long,enable=true,priority=100
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
context: .
|
|
file: scripts/Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|