foascli is the Go CLI that generates the Federated OpenAPI specification and the API changelog.
See README.md for what it does and CONTRIBUTING.md for the
project-wide rules. This file covers the development loop.
cmd/: thefoasclientry point.internal/cli/: one package per command (merge,split,slice,filter,versions,changelog,breakingchanges,sunset, ...). Command wiring lives ininternal/cli/root.test/e2e/: end-to-end tests that run the built binary. Fixtures are intest/data/.- Most OpenAPI logic lives in the sibling module
../foas(github.com/mongodb/openapi/tools/foas), which this module consumes throughreplace ... => ../foas. Both modules belong to the Go workspace in../go.work. A change infoascan breakfoascli, so after changingfoas, also run the loop below here.
Run all commands from tools/cli.
make setup # go mod download + go mod tidy, then install mockgen, oasdiff and golangci-lintThe tools are installed to $(go env GOPATH)/bin, which must be on your PATH.
- Make the change.
make fmt: rungolangci-lint fmt, which applies the formatters configured in.golangci.yml(gci,gofmt,goimports).make lintalso reports unformatted files.make fix-lint: apply the automatic fixes. It runsmake go-fix(go fix ./..., which modernizes code to the Go version ingo.mod), then golangci-lint with--fix(config in.golangci.yml). Fix whatever remains by hand.make lintruns the same lint checks without changing files.make unit-test: rungo test -race -cover ./internal....make e2e-test: build the binary into./bin/foascliand run./test/e2e...against it. Run this when you change command behavior or output.make check-tidy: fail ifgo.modorgo.sumis not tidy. Run it after changing dependencies.make check-fix: fail ifgo fixwould change any file.make go-fixormake fix-lintapplies the fixes.
make pre-commit runs steps 2 to 4. The repository's git pre-commit hook runs it for staged Go files.
CI (.github/workflows/code-health-foascli.yml) runs the build, unit tests, golangci-lint, make check-tidy,
make check-fix, actionlint and the e2e tests.
- Run e2e tests with
make e2e-test, notgo test ./.... The tests find the binary throughCLI_E2E_BINARY, which the Makefile sets. Without it they fail withfork/exec ...: permission denied. - After editing
tools/spectral/ipa/rulesets/functions/utils/legacyLroOperationIds.js, rungo generate ./...to regenerate the Go copy. A unit test fails if it is out of date. make gen-mocksregenerates mocks withgo generate ./internal....- Dependabot bumps each module separately. A bump in
foascan leave this module'sgo.moduntidy.make check-tidycatches that, andgo mod tidyfixes it. - Running Go commands in the workspace can add lines to
../go.work.sum. Don't commit those unless the change needs them. - The Go version is pinned only by the
goandtoolchaindirectives ingo.mod(and../go.work). With the defaultGOTOOLCHAIN=auto, Go downloads that toolchain for you. To update it, follow docs/update-go.md. - To bump golangci-lint, follow docs/update-golangci-lint.md.
- Tests are table-driven and use
testify(assert/require). New tests callt.Parallel()in the test and in each subtest, unless they share state. - When you must suppress a linter, scope
//nolint:<linter> // <reason>to the line. - Use conventional commits in PR titles.
- Always open PRs as drafts (
gh pr create --draft). Mark them ready for review once CI passes. - Releases are covered in RELEASING.md.