Skip to content

Commit f83254a

Browse files
ygalblumclaude
andauthored
Add CLI framework, CI workflows, and linting (Topic 1) (#2)
Implement the foundational DCM CLI structure: - Cobra-based root command with global flags (api-gateway-url, output, timeout, config) - Subcommand group stubs for policy, catalog service-type, catalog item, and catalog instance - Version command with build-time ldflags injection - Makefile with build, test, fmt, vet, lint, and clean targets - .gitignore and .gitattributes for project hygiene Add CI and code quality tooling: - GitHub CI workflows for linting, testing, and commit checks using shared workflows - golangci-lint configuration aligned with other dcm repos Include Ginkgo tests covering TC-U019 through TC-U023. Signed-off-by: Ygal Blum <ygal.blum@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f00d283 commit f83254a

22 files changed

Lines changed: 940 additions & 0 deletions

.ai/checkpoints/topic-1-cli-framework.md

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Mark generated files so GitHub collapses them in PRs
2+
*.gen.go linguist-generated=true
3+
.ai/checkpoints/** linguist-generated=true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Check Clean Commits
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
check-clean-commits:
9+
uses: dcm-project/shared-workflows/.github/workflows/check-clean-commits.yaml@main

.github/workflows/ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ci:
11+
uses: dcm-project/shared-workflows/.github/workflows/go-ci.yaml@main

.github/workflows/lint.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
uses: dcm-project/shared-workflows/.github/workflows/go-lint.yaml@main

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
bin/
11+
12+
# Test binary, built with `go test -c`
13+
*.test
14+
15+
# Code coverage profiles and other test artifacts
16+
*.out
17+
coverage.*
18+
*.coverprofile
19+
profile.cov
20+
21+
# Dependency directories (remove the comment below to include it)
22+
vendor/
23+
24+
# Go workspace file
25+
go.work
26+
go.work.sum
27+
28+
# env file
29+
.env
30+
31+
# Editor/IDE
32+
# .idea/
33+
# .vscode/
34+
35+
# E2E test artifacts
36+
test/e2e/*.test

.golangci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: "2"
2+
run:
3+
modules-download-mode: readonly
4+
5+
formatters:
6+
enable:
7+
- gofumpt
8+
- goimports
9+
exclusions:
10+
generated: disable
11+
12+
linters:
13+
enable:
14+
- asasalint
15+
- asciicheck
16+
- bidichk
17+
- bodyclose
18+
- copyloopvar
19+
- decorder
20+
- dogsled
21+
- durationcheck
22+
- errchkjson
23+
- exptostd
24+
- fatcontext
25+
- ginkgolinter
26+
- gocheckcompilerdirectives
27+
- gochecksumtype
28+
- gocritic
29+
- goprintffuncname
30+
- grouper
31+
- iface
32+
- inamedparam
33+
- interfacebloat
34+
- makezero
35+
- mirror
36+
- misspell
37+
- nilerr
38+
- nilnesserr
39+
- nolintlint
40+
- nosprintfhostport
41+
- prealloc
42+
- protogetter
43+
- reassign
44+
- recvcheck
45+
- revive
46+
- rowserrcheck
47+
- sqlclosecheck
48+
- staticcheck
49+
- testableexamples
50+
- unconvert
51+
- unparam
52+
- usestdlibvars
53+
- usetesting
54+
- wastedassign
55+
- whitespace
56+
settings:
57+
staticcheck:
58+
checks:
59+
- all
60+
- -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
61+
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
62+
nolintlint:
63+
require-specific: true
64+
revive:
65+
rules:
66+
- name: unused-parameter
67+
68+
issues:
69+
max-issues-per-linter: 0
70+
max-same-issues: 0

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
VERSION ?= $(shell git describe --tags --always --dirty)
2+
COMMIT ?= $(shell git rev-parse --short HEAD)
3+
BUILD_TIME ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
4+
5+
LDFLAGS = -X github.com/dcm-project/cli/internal/version.Version=$(VERSION) \
6+
-X github.com/dcm-project/cli/internal/version.Commit=$(COMMIT) \
7+
-X github.com/dcm-project/cli/internal/version.BuildTime=$(BUILD_TIME)
8+
9+
.PHONY: build test test-e2e fmt vet lint clean tidy
10+
11+
build: tidy
12+
go build -ldflags "$(LDFLAGS)" -o bin/dcm ./cmd/dcm
13+
14+
test: tidy
15+
go run github.com/onsi/ginkgo/v2/ginkgo -r --randomize-all --randomize-suites --fail-on-pending --keep-going --race --trace ./internal/...
16+
17+
test-e2e: tidy
18+
go run github.com/onsi/ginkgo/v2/ginkgo -r --randomize-all --randomize-suites --fail-on-pending --keep-going --race --trace --tags=e2e ./test/e2e/...
19+
20+
fmt:
21+
go fmt ./...
22+
23+
vet: tidy
24+
go vet ./...
25+
26+
lint:
27+
golangci-lint run ./...
28+
29+
clean:
30+
rm -rf bin/
31+
32+
tidy:
33+
go mod tidy

cmd/dcm/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
3+
import (
4+
"github.com/dcm-project/cli/internal/commands"
5+
)
6+
7+
func main() {
8+
commands.Execute()
9+
}

go.mod

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module github.com/dcm-project/cli
2+
3+
go 1.25.4
4+
5+
require (
6+
github.com/onsi/ginkgo/v2 v2.28.1
7+
github.com/onsi/gomega v1.39.1
8+
github.com/spf13/cobra v1.10.2
9+
)
10+
11+
require (
12+
github.com/Masterminds/semver/v3 v3.4.0 // indirect
13+
github.com/go-logr/logr v1.4.3 // indirect
14+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
15+
github.com/google/go-cmp v0.7.0 // indirect
16+
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
17+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
18+
github.com/spf13/pflag v1.0.9 // indirect
19+
go.yaml.in/yaml/v3 v3.0.4 // indirect
20+
golang.org/x/mod v0.32.0 // indirect
21+
golang.org/x/net v0.49.0 // indirect
22+
golang.org/x/sync v0.19.0 // indirect
23+
golang.org/x/sys v0.40.0 // indirect
24+
golang.org/x/text v0.33.0 // indirect
25+
golang.org/x/tools v0.41.0 // indirect
26+
)

0 commit comments

Comments
 (0)