https://github.com/lex00/wetwire-gitlab-go
https://github.com/lex00/wetwire-gitlab-go
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lex00/wetwire-gitlab-go
- Owner: lex00
- License: mit
- Created: 2026-01-05T05:12:00.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-12T02:39:14.000Z (5 months ago)
- Last Synced: 2026-01-12T02:44:45.767Z (5 months ago)
- Language: Go
- Size: 2.25 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Roadmap: docs/ROADMAP.md
- Notice: NOTICE
Awesome Lists containing this project
README
# wetwire-gitlab (Go)
[](https://github.com/lex00/wetwire-gitlab-go/actions/workflows/ci.yml)
[](https://codecov.io/gh/lex00/wetwire-gitlab-go)
[](https://pkg.go.dev/github.com/lex00/wetwire-gitlab-go)
[](https://goreportcard.com/report/github.com/lex00/wetwire-gitlab-go)
[](https://opensource.org/licenses/MIT)
Generate GitLab CI/CD configuration from Go pipeline declarations using a declarative, type-safe syntax.
## Status
**v0.0.0 - In Development**
See [Implementation Roadmap](https://github.com/lex00/wetwire-gitlab-go/issues/2) for progress.
For the wetwire pattern, see the [Wetwire Specification](https://github.com/lex00/wetwire/blob/main/docs/WETWIRE_SPEC.md).
## The No-Parens Principle
Wetwire uses **flat struct declarations** with **direct variable references** — no wrapper functions, no registration calls, no constructors:
```go
// References are variable names, not function calls
Needs: []any{BuildJob} // NOT: Needs(BuildJob)
// Nested configs are separate variables
Artifacts: BuildArtifacts // NOT: Artifacts(&Artifacts{...})
// Predefined variables via field access
If: CI.DefaultBranch // NOT: If("$CI_DEFAULT_BRANCH")
```
## Quick Start
```go
package ci
import (
. "github.com/lex00/wetwire-gitlab-go/intrinsics" // Dot-import for helpers
"github.com/lex00/wetwire-gitlab-go/pipeline" // Core types
"github.com/lex00/wetwire-gitlab-go/components/sast"
)
// Stages as flat declaration
var Stages = List("build", "test", "deploy")
// Nested config extracted to separate variable
var BuildArtifacts = pipeline.Artifacts{
Paths: List("bin/"),
ExpireIn: "1 week",
}
// Image config extracted
var GolangImage = pipeline.Image{
Name: "golang:1.23",
}
// Job with direct references — no function calls
var BuildJob = pipeline.Job{
Name: "build",
Stage: "build",
Image: GolangImage,
Script: List("go build -v ./..."),
Artifacts: BuildArtifacts,
}
// Use pre-defined rules from intrinsics (dot-imported)
var TestJob = pipeline.Job{
Name: "test",
Stage: "test",
Image: GolangImage,
Script: List("go test -v ./..."),
Needs: []any{BuildJob},
Rules: List(OnDefaultBranch),
}
// Typed component wrapper
var SecurityScan = sast.SAST{
Stage: "test",
}
// Deploy with environment
var DeployEnv = pipeline.Environment{
Name: "production",
URL: "https://example.com",
}
// Rule extracted to separate variable
var OnTagRule = pipeline.Rule{
If: CI.CommitTag,
When: Always,
}
var DeployJob = pipeline.Job{
Name: "deploy",
Stage: "deploy",
Script: List("./deploy.sh"),
Environment: DeployEnv,
Needs: []any{TestJob, SecurityScan},
Rules: List(OnTagRule),
}
```
Generate configuration:
```bash
wetwire-gitlab build ./ci > .gitlab-ci.yml
```
Output:
```yaml
stages:
- build
- test
- deploy
build:
stage: build
image: golang:1.23
script:
- go build -v ./...
artifacts:
paths:
- bin/
expire_in: 1 week
test:
stage: test
image: golang:1.23
script:
- go test -v ./...
needs:
- build
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
deploy:
stage: deploy
script:
- ./deploy.sh
environment:
name: production
url: https://example.com
needs:
- test
- sast
rules:
- if: $CI_COMMIT_TAG
when: always
```
## Installation
```bash
go install github.com/lex00/wetwire-gitlab-go/cmd/wetwire-gitlab@latest
```
## AI-Assisted Design (Kiro CLI)
Use Kiro CLI for AI-assisted pipeline design:
```bash
# Install Kiro CLI
curl -fsSL https://cli.kiro.dev/install | bash
# Start AI-assisted design session
wetwire-gitlab design --provider kiro "Create a CI/CD pipeline for a Go microservice"
```
The `design` command automatically configures the Kiro agent and launches an interactive session where Claude can use MCP tools (`wetwire_init`, `wetwire_lint`, `wetwire_build`) to help design your pipeline.
See [GITLAB-KIRO-CLI.md](docs/GITLAB-KIRO-CLI.md) for complete setup and usage guide.
## CLI Commands
| Command | Status | Description |
|---------|--------|-------------|
| `build` | ✅ Done | Generate `.gitlab-ci.yml` from Go definitions |
| `validate` | ✅ Done | Validate via `glab ci lint` |
| `list` | ✅ Done | List discovered pipelines/jobs |
| `lint` | ✅ Done | Check Go code for quality issues (27 rules) |
| `import` | ✅ Done | Import existing `.gitlab-ci.yml` to Go |
| `graph` | ✅ Done | Generate DAG visualization (DOT/Mermaid) |
| `design` | ✅ Done | AI-assisted pipeline design |
| `test` | ✅ Done | Persona-based testing |
| `init` | ✅ Done | Initialize new project |
| `version` | ✅ Done | Print version information |
## Core Concepts
### Flat Declarations
Every job/config is a top-level `var` with a struct literal:
```go
var MyJob = pipeline.Job{
Name: "my-job",
Script: List("echo hello"),
}
```
### Direct References
Job dependencies use variable names directly:
```go
var TestJob = pipeline.Job{
Needs: []any{BuildJob, LintJob}, // Variable references
}
```
### Extracted Nested Config
Complex nested structures become separate variables:
```go
// Instead of inline nesting
var CacheConfig = pipeline.Cache{
Key: "deps-${CI_COMMIT_REF_SLUG}",
Paths: List("vendor/", ".cache/"),
}
var MyJob = pipeline.Job{
Cache: CacheConfig, // Reference extracted config
}
```
### Predefined Variables
Type-safe access via `intrinsics` package (dot-imported):
```go
var DeployRule = pipeline.Rule{
If: CI.CommitTag, // $CI_COMMIT_TAG
}
var NotifyRule = pipeline.Rule{
If: CI.PipelineSource.Eq("merge_request_event"),
}
// Pre-defined rules for common patterns
var TestJob = pipeline.Job{
Rules: List(OnDefaultBranch), // if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
}
```
## Package Structure
```
wetwire-gitlab-go/
├── cmd/wetwire-gitlab/ # CLI application
├── internal/
│ ├── agent/ # Tool definitions for orchestrator integration
│ ├── discover/ # AST-based pipeline discovery
│ ├── importer/ # YAML to Go code conversion
│ ├── linter/ # Go code lint rules (WGL001-WGL012)
│ ├── reference/ # Round-trip testing utilities
│ ├── runner/ # Runtime value extraction
│ ├── serialize/ # YAML serialization
│ ├── template/ # Pipeline builder with topological sort
│ └── validation/ # glab ci lint integration
├── pipeline/ # Core pipeline types (Job, Rule, Artifacts...)
├── intrinsics/ # Helpers for dot-import (CI.*, OnDefaultBranch...)
├── components/ # Generated component wrappers (SAST, DAST, etc.)
├── templates/ # Auto DevOps template wrappers
├── runner/ # GitLab Runner config.toml types
├── codegen/ # Schema fetching, parsing, code generation
├── testdata/ # Sample pipelines for testing
├── contracts.go # Core interfaces
└── scripts/
├── ci.sh # Local CI script
└── import_samples.sh # Fetch gitlab-org samples
```
### Package Design
The importer/init commands generate packages with strategic imports for clean syntax:
```go
import (
. "github.com/lex00/wetwire-gitlab-go/intrinsics" // Dot-import: CI.*, OnDefaultBranch, etc.
"github.com/lex00/wetwire-gitlab-go/pipeline" // Prefixed: pipeline.Job, pipeline.Rule
)
```
**intrinsics/** (dot-imported for clean syntax):
- `Json` — type alias for `map[string]any`
- `List[T]()` — create any typed slice (use for all slices except `[]any`)
- `CI`, `GitLab`, `MR` — predefined variable namespaces
- `OnDefaultBranch`, `OnTag`, `ManualOnly` — pre-defined rules
- `Always`, `Never`, `OnSuccess`, `OnFailure`, `Manual` — when values
**pipeline/** (explicit namespace):
- `pipeline.Job`, `pipeline.Rule`, `pipeline.Artifacts` — core types
- Explicit prefix prevents collisions with user-defined variables
## Development
```bash
# Run tests
go test -v ./...
# Run CI checks
./scripts/ci.sh
# Build CLI
go build -o wetwire-gitlab ./cmd/wetwire-gitlab
```
## Documentation
- [Quick Start Guide](docs/QUICK_START.md) - Get started in 5 minutes
- [CLI Reference](docs/CLI.md) - Complete command documentation
- [Pre-Commit Hook Integration](docs/PRE_COMMIT.md) - Automate validation with Git hooks
- [Templates Guide](docs/TEMPLATES.md) - Auto DevOps and job template wrappers
- [Components Guide](docs/COMPONENTS.md) - Security component wrappers (SAST, DAST, etc.)
- [Lint Rules Reference](docs/LINT_RULES.md) - Detailed lint rule documentation
- [Developer Guide](docs/DEVELOPERS.md) - Contributing and architecture
- [Adoption Guide](docs/ADOPTION.md) - Migration strategies for teams
- [Import Workflow](docs/IMPORT_WORKFLOW.md) - Converting existing pipelines
- [Internals](docs/INTERNALS.md) - Internal architecture details
- [Code Generation](docs/CODEGEN.md) - Component code generation pipeline
- [Examples Reference](docs/EXAMPLES.md) - Example catalog with patterns
- [Versioning](docs/VERSIONING.md) - Version management
- [FAQ](docs/FAQ.md) - Frequently asked questions
- [Contributing](CONTRIBUTING.md) - How to contribute
## Related Packages
- [wetwire-aws-go](https://github.com/lex00/wetwire-aws-go) - AWS CloudFormation synthesis
- [wetwire-github-go](https://github.com/lex00/wetwire-github-go) - GitHub Actions synthesis
- [wetwire-core-go](https://github.com/lex00/wetwire-core-go) - Agent infrastructure
## License
MIT - See [LICENSE](LICENSE) for details.