Files
GoLoom/.gitea/workflows/go-loom.yaml
hhs 1cfebd37be
All checks were successful
GoLoom CI / Lint (push) Successful in 1m21s
GoLoom CI / Test (push) Successful in 5s
GoLoom CI / Build (push) Successful in 7s
fix(ci): 移除 Docker Build 阶段,Gitea 不支持 GHA 缓存
2026-06-10 11:17:58 +08:00

113 lines
2.8 KiB
YAML

name: GoLoom CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
GO_VERSION: '1.26'
GOLANGCI_LINT_VERSION: 'v1.57.2'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Cache golangci-lint
uses: actions/cache@v4
with:
path: /usr/local/bin/golangci-lint
key: golangci-lint-${{ env.GOLANGCI_LINT_VERSION }}
- name: Install golangci-lint
run: |
if [ ! -f /usr/local/bin/golangci-lint ]; then
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin ${{ env.GOLANGCI_LINT_VERSION }}
fi
- name: Run golangci-lint
run: golangci-lint run --timeout=5m --issues-exit-code=0
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run tests
run: |
test_files=$(find . -name "*_test.go" -type f)
if [ -z "$test_files" ]; then
echo "No test files found, skipping tests"
exit 0
fi
go test -v -race -coverprofile=coverage.out ./...
- name: Upload coverage
if: success() && hashFiles('coverage.out') != ''
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage.out
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build binary
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o goloom-server ./cmd/server
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: goloom-server
path: goloom-server
# TODO: 添加 Dockerfile 后启用
# docker:
# name: Docker Build
# runs-on: ubuntu-latest
# needs: [build]
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Download binary
# uses: actions/download-artifact@v3
# with:
# name: goloom-server
# - name: Build Docker image
# run: |
# chmod +x goloom-server
# docker build -t goloom:latest -t goloom:${{ github.sha }} .