SKILL·FDE4BF

go-ci

eduardo-sl
更新于 8 days ago
64
9
64
在 GitHub 上查看
testingdesign

关于

This Claude Skill helps developers set up and optimize continuous integration pipelines for Go projects using GitHub Actions. It provides configurations for caching, golangci-lint, test coverage gates, vulnerability scanning with govulncheck, build matrices, and Makefile targets. Use it when you need to implement or improve CI workflows but not for writing tests, commit conventions, or dependency audits.

快速安装

Claude Code

推荐
主要方式
npx skills add eduardo-sl/go-agent-skills -a claude-code
插件命令备选方式
/plugin add https://github.com/eduardo-sl/go-agent-skills
Git 克隆备选方式
git clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-ci

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Go CI

A Go pipeline has exactly four gates: build, vet/lint, test with race detector, vulnerability scan. Everything else is optimization.

1. Baseline GitHub Actions Workflow

name: ci
on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod   # single source of truth
          cache: true               # caches module + build cache
      - run: go build ./...
      - run: go vet ./...
      - run: go test -race -shuffle=on -coverprofile=coverage.out ./...

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - uses: golangci/golangci-lint-action@v6
        with:
          version: latest

  vuln:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...

Key decisions baked in:

  • go-version-file: go.mod — never hardcode the Go version in two places.
  • cache: true on setup-go handles module and build caches; do not add manual actions/cache steps for Go on top of it.
  • -race -shuffle=on — races and order-dependent tests fail in CI, not production.
  • permissions: contents: read — least privilege by default.
  • Lint in a separate job — it fails fast and parallelizes with tests.

2. golangci-lint Configuration

Commit a .golangci.yml; an unconfigured linter is noise:

linters:
  enable:
    - errcheck      # unchecked errors
    - govet
    - staticcheck
    - errorlint     # %w misuse, == on errors
    - gosec         # security patterns
    - revive        # style, replaces golint
    - misspell
issues:
  exclude-rules:
    - path: _test\.go
      linters: [gosec]  # test code may use weak randomness etc.

Start from this small set and add linters deliberately. Enabling everything produces hundreds of findings nobody triages. nolint directives require a reason: //nolint:gosec // G404: jitter, not crypto.

3. Build Matrix — Only When You Ship It

strategy:
  matrix:
    go: ['1.23', '1.24']         # only versions you support
    os: [ubuntu-latest, macos-latest, windows-latest]

Libraries: test the two newest Go versions (the Go team supports two). Services deployed on Linux: skip the OS matrix — it doubles cost for platforms you never ship. Cross-compilation is cheaper than emulation: GOOS=windows go build ./... catches most portability breaks.

4. Coverage Gate

- run: go test -race -coverprofile=coverage.out ./...
- name: enforce coverage floor
  run: |
    total=$(go tool cover -func=coverage.out | awk '/^total:/ {sub(/%/,"",$3); print $3}')
    echo "coverage: ${total}%"
    awk -v t="$total" 'BEGIN { exit (t < 70.0) }'

Gate on a floor that ratchets up, not a target that gets gamed. Exclude generated code via //go:generated files' build tags or grep filters, not by lowering the floor.

5. Makefile — Local Mirror of CI

CI must run what developers run. One definition, two callers:

.PHONY: build lint test vuln ci

build:
	go build ./...

lint:
	golangci-lint run

test:
	go test -race -shuffle=on -coverprofile=coverage.out ./...

vuln:
	go run golang.org/x/vuln/cmd/govulncheck@latest ./...

ci: build lint test vuln

If CI does anything make ci doesn't, developers discover failures only after pushing. Keep them identical.

6. Speed Rules

  • Split lint / test / vuln into parallel jobs (as in §1).
  • go test ./... already parallelizes across packages; don't shard a small repo.
  • Integration tests behind a build tag run in a separate job or on a schedule, not on every push: go test -tags=integration ./....
  • If the build cache misses constantly, check that go.sum is the cache key input (setup-go does this) and that jobs don't mutate it.

Verification Checklist

  1. Pipeline has all four gates: build, vet+lint, test -race, govulncheck
  2. Go version sourced from go.mod (go-version-file), not duplicated
  3. permissions: contents: read set at workflow level
  4. Tests run with -race -shuffle=on
  5. .golangci.yml committed with a curated linter set
  6. Every nolint carries a linter name and a reason
  7. Matrix limited to versions/platforms actually supported
  8. Coverage floor enforced, generated code excluded
  9. make ci reproduces the pipeline locally, byte-for-byte
  10. Integration tests isolated behind tags, not slowing every push

GitHub 仓库

eduardo-sl/go-agent-skills
路径: skills/(workflow)/go-ci
0
FAQ

常见问题

什么是 go-ci Skill?

go-ci 是一个 Claude Skill,作者为 eduardo-sl。Skill 将 Claude 按需加载的说明和资源打包,让 Claude 无需额外提示即可执行与 go-ci 相关的任务。

如何安装 go-ci?

使用本页的安装命令:将 go-ci 作为插件添加到 Claude Code,或将其仓库克隆到 skills 目录,然后重启 Claude 以加载该 Skill。

go-ci 属于哪个分类?

go-ci 属于元分类。

go-ci 可以免费使用吗?

可以。go-ci 已收录在 AIMCP,可免费安装。

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能
polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能
creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能
sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能