ruleset

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ruleset 渲染并分发框架规则集:.golangci.yml、.go-arch-lint.yml 与域仓库的 CI 引用文件。模板由 appkit sync 物化进各仓库,CI 做漂移检查 (见 docs/DESIGN.md §7:物化解决 IDE 集成与 golangci-lint 无配置继承的问题)。

Index

Constants

View Source
const (
	GolangciLintVersion = "v2.13.2"
	ArchLintVersion     = "v1.18.0"
)

域仓库 lint 工具链的钉版本。域仓库的 Makefile(lint 目标)与 appkit 的 .github/workflows/domain-ci.yml 必须跑同一个版本——版本不一致就会出现 「本地绿、CI 红」,而这正是规则集物化要消灭的那类事故。 两处一致由 ruleset 的 TestLinterVersionsMatchCI 守住;升级改这里。

Variables

This section is empty.

Functions

func Check

func Check(dir, version string) error

Check 比对渲染结果与磁盘内容,漂移则报错并列出文件。

func CheckPinned added in v0.9.0

func CheckPinned(dir, version, workflowRef string) error

CheckPinned 使用指定完整 commit 比对规则集。

func NormalizeWorkflowRef added in v0.9.0

func NormalizeWorkflowRef(ref string) (string, error)

NormalizeWorkflowRef validates and normalizes an explicit immutable reference without running commands or accessing the filesystem/network.

func Render

func Render(cfg Config) (map[string][]byte, error)

Render 渲染全部规则集文件;key 是相对仓库根的落盘路径, 每个文件均以生成头开始(含 appkit 版本,CI 借此发现版本漂移)。

func ResolveWorkflowRef added in v0.9.0

func ResolveWorkflowRef(version string) (string, error)

ResolveWorkflowRef 把 appkit 版本解析为其源码 commit。生成的 reusable workflow 只写完整 SHA;版本仅作为审计注释,绝不作为可执行引用。

func ResolveWorkflowRefContext added in v0.9.0

func ResolveWorkflowRefContext(ctx context.Context, version string) (string, error)

ResolveWorkflowRefContext resolves before rendering or taking workspace locks. Downloads use an isolated scratch directory, never the caller's go.mod/go.sum.

func Sync

func Sync(dir, version string) ([]string, error)

Sync 按 .appkit.yml 渲染规则集并写入 dir,返回写入的相对路径(有序)。

func SyncPinned added in v0.9.0

func SyncPinned(dir, version, workflowRef string) ([]string, error)

SyncPinned 与 Sync 相同,但使用调用者已解析并校验的完整 workflow commit。 它供脚手架在一次运行中复用解析结果,也让离线测试无需访问模块代理。

Types

type AppConfig

type AppConfig struct {
	Version       int      `yaml:"version"`
	Kind          string   `yaml:"kind"` // domain(默认)或 system
	Domain        string   `yaml:"domain"`
	Module        string   `yaml:"module"`
	Contracts     string   `yaml:"contracts"`
	AllowRequires []string `yaml:"allowRequires"`
	// Partitioned 是「分区域域」标记(appkit new domain -partitioned 写入)。
	// ruleset 不消费它,这里收下只为与 archcheck.Config 共用一份配置文件。
	Partitioned bool `yaml:"partitioned"`
}

AppConfig 对应 .appkit.yml(版本恒为 1)。

func LoadAppConfig

func LoadAppConfig(dir string) (AppConfig, error)

LoadAppConfig 读取并校验 dir 下的 .appkit.yml。

func ParseAppConfig added in v0.9.0

func ParseAppConfig(data []byte) (AppConfig, error)

ParseAppConfig 解析并校验已经读入内存的 .appkit.yml,规则与 LoadAppConfig 相同。它不读取文件,供需要将校验结果绑定到同一份配置快照的调用方使用。 错误中的来源名为 .appkit.yml;文件路径信息由调用方补充。

type Config

type Config struct {
	Domain      string // 业务包名 = Postgres schema,须匹配 ^[a-z][a-z0-9]*$
	Module      string // 域仓库 module path
	Contracts   string // 合约 module path,可空
	Version     string // appkit CLI 版本,写入生成头;空则记为 (devel)
	WorkflowRef string // domain-ci.yml 的完整 40 位 commit SHA
}

Config 是渲染规则集所需的域仓库信息。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL