Documentation
¶
Overview ¶
Package generate produces CI platform configuration from cidx.toml.
Index ¶
Constants ¶
const DefaultGitHubWorkflowPath = ".github/workflows/cidx.yml"
DefaultGitHubWorkflowPath is where `cidx generate github` writes when no -o is given, and the path its regeneration hint names by default.
const DefaultGitLabPath = ".gitlab-ci.yml"
DefaultGitLabPath is where `cidx generate gitlab` writes when no -o is given, and the path its regeneration hint names by default.
Variables ¶
var Version = "dev"
Version is the cidx build version, propagated from main at startup (same pattern as executor.Version). Release builds inject it via ldflags (`-X main.Version=1.7.0`); dev builds keep the "dev" default.
It determines the bootstrap pin in generated workflows: a workflow generated by a released cidx installs that exact release in CI, so local and CI runs use the same presets (issue #163).
Functions ¶
func BootstrapVersion ¶
func BootstrapVersion() string
BootstrapVersion returns the `go install` version suffix used by generated workflows: "v<X.Y.Z>" when the running cidx is a release build, "latest" otherwise (dev or nightly builds, which have no installable tag).
func GitHub ¶
GitHub generates a GitHub Actions workflow YAML from the CIDX config.
This entrypoint targets external projects: the bootstrap installs cidx via `go install`, pinned to the generating cidx's release version when known (see BootstrapVersion). Callers that need the cidx-repo bootstrap should use GitHubWithOptions with SelfBuild=true.
func GitHubWithOptions ¶
func GitHubWithOptions(cfg *config.Config, opts GitHubOptions) (string, error)
GitHubWithOptions generates a GitHub Actions workflow YAML with explicit generation options. Use this when you need to control the bootstrap mode (self-build vs. go-install) directly.
func GitLab ¶
GitLab generates a GitLab CI configuration YAML from the CIDX config.
outputPath is the file the caller will write this configuration to. It only feeds the "Regenerate with" header, so the hint names the file being read instead of always .gitlab-ci.yml -- the same defect issue #229 fixed on the GitHub side. Empty means DefaultGitLabPath.
func IsCidxRepo ¶
IsCidxRepo reports whether dir is the cidx repository itself.
The check has two prongs to avoid false positives from any project that happens to have a cmd/cidx/ directory:
- cmd/cidx/main.go must exist
- go.mod's module declaration must equal the canonical cidx module path
Returns false on any I/O error or missing marker — external project semantics are the safe default.
Types ¶
type GitHubOptions ¶
type GitHubOptions struct {
// SelfBuild emits the cidx-repo bootstrap (`go build -o bin/cidx ./cmd/cidx`).
// When false (the default for external projects), the bootstrap installs
// cidx via `go install <module>/cmd/cidx@<BootstrapVersion()>`.
SelfBuild bool
// OutputPath is the file the caller will write this workflow to. It only
// feeds the "Regenerate with" header, so the hint names the file being
// read: it used to always say .github/workflows/cidx.yml, and following it
// from a workflow generated with -o ci.yml silently created a second
// workflow (issue #229). Empty means DefaultGitHubWorkflowPath.
OutputPath string
}
GitHubOptions controls how the GitHub Actions workflow is generated.