Skip to content

Split the repo into one module per package - #65

Merged
duynhne merged 15 commits into
mainfrom
refactor/multi-module
Aug 7, 2026
Merged

Split the repo into one module per package#65
duynhne merged 15 commits into
mainfrom
refactor/multi-module

Conversation

@duynhne

@duynhne duynhne commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

PR: Split the repo into one module per package

What

  • 13 independent Go modules, one go.mod per package (logger splits into zapx/zerolog/clog), tagged separately as <module>/vX.Y.Z starting at v0.36.0. Import paths are unchanged; dependency versions stay pinned to the previous root go.mod.
  • grpcx no longer imports obsx — the only internal edge, replaced by a trace-API-only helper with a new test pinning the log↔trace correlation contract.
  • Makefile orchestrates the fleet: dynamic module discovery, make test-<module> gate (tidy+fmt+vet+lint+race tests), make release-<module> VER=x.y.z with semver/clean-tree/on-main guards, coverage merge for SonarCloud.
  • depguard layering: terminal modules (obsx, dbx, migratex, temporalx) and the OTel SDK outside obsx are deny-listed; goimports local-prefixes typo fixed.
  • CI: go gate back on the shared go-check.yml (needs go-check: Support multi-module monorepos gha-workflows#103 merged, then pin the SHA — currently @main); CodeQL (go + actions) added; labels synced declaratively from .github/labels.yaml; release workflow matches <module>/vX.Y.Z tags.
  • Docs: AGENTS.md rewritten for the multi-module architecture and AI-contribution conventions; README module/layer table; docs/MIGRATION.md for moving the 10 services off pkg@v0.35.0 (go.mod-only, no code changes).

Why

A service importing only httpx currently drags the full tree (testcontainers/moby, temporal, pyroscope, OTel SDK) into its go.sum, and every change bumps one shared version. Per-module tagging isolates dependencies and lets modules version independently.

Verification

  • make modules = 13; make test green for all modules (race + lint, 0 issues); integration tests run in CI (Docker).
  • buf lint + buf generate with the pinned codegen versions → zero stub diff.
  • Consumer simulation (require pkg/httpx + pkg/logger/zapx via replace) builds; its go.sum carries no heavy transitive deps.
  • Old tags (v0.35.0 and earlier) keep resolving — tags are immutable snapshots.
  • Independent adversarial review: 0 critical; both required findings fixed (migration-doc ambiguous-import correction + tombstone root, history made bisect-safe), all optional findings addressed.

After merge

  1. Merge go-check: Support multi-module monorepos gha-workflows#103, then pin its SHA in check.yml/build.yml (TODO comments mark the spots).
  2. make release-<module> VER=0.36.0 for all 13 modules.
  3. Migrate services one PR at a time per docs/MIGRATION.md.

🤖 Generated with Claude Code

duynhne added 9 commits August 7, 2026 15:05
Inline a trace-API-only helper so grpcx no longer imports obsx.
The access log keeps stamping the active span's trace_id; a new
test pins the correlation contract before the module split makes
obsx a separate, heavier module that grpcx must not require.
Give each of the 13 packages its own module (logger splits into
zapx/zerolog/clog). Dependency versions stay pinned to the previous
root go.mod; each module's go.sum now carries only what that module
uses, so a service importing httpx no longer drags testcontainers,
temporal, or the OTel SDK.
Discovers modules by go.mod, encodes / as : in target names, and
fans out tidy/fmt/vet/lint/test via $(MAKE) so -j parallelises
across modules. release-<module> VER=x.y.z validates semver,
refuses commits not on origin/main, and tags <module>/vx.y.z;
coverage merges per-module profiles for SonarCloud.
Deny imports of the terminal modules (obsx, dbx, migratex,
temporalx) everywhere except each module's own tree, and the OTel
SDK outside obsx (tests exempt). Also fix the goimports
local-prefixes typo (duynhne) that kept local import grouping from
ever applying.
go-check.yml assumes a single root go.mod the packages live in;
check/build now run make test TAGS=integration natively, merge the
per-module coverage profiles into the coverage.out artifact the
sonarqube.yml reusable workflow already expects, and fail if tidy
or fmt left uncommitted changes. release.yml also matches
<module>/vX.Y.Z tags. .gitignore unanchors coverage.out for the
per-module profiles.
AGENTS.md documents the 13-module architecture, the three-layer
dependency rules with depguard enforcement, the Makefile targets,
per-module tagging, the tombstone root module, and the
contribution conventions (module-prefixed
subjects, rebase-only). README gains the module/layer table and
per-module install lines; docs/MIGRATION.md walks services off the
frozen single-module v0.35.0 line, go.mod-only, including the
ambiguous-import remedy via the vacated root v0.36.0.
gha-workflows' go-check.yml now takes cache-dependency-path and
disables Ryuk in the unit-test job, so the multi-module gate no
longer needs a bespoke job: command-test drives make test
TAGS=integration, verifies tidy/fmt left no diff, and merges
coverage for the sonarqube.yml artifact contract. Reusable lint
stays off — lint runs per module inside make test. Referenced
@main until the gha-workflows change merges and can be pinned.
Run the shared codeql.yml once per language: go with
build-mode none (a multi-module monorepo has no root module to
autobuild; CodeQL scans Go source without a build) and actions for
the workflow files. Weekly cron catches newly added queries.
Labels live in .github/labels.yaml and EndBug/label-sync applies
them with delete-other-labels, so the file is the whole set: a
triage tier plus one area/* label per module, colored by layer.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

duynhne added 2 commits August 7, 2026 15:36
gha-workflows now ships the cache-dependency-path input and the
Ryuk-disabled unit-test step; pin the merged commit in place of
the temporary @main reference.
@duynhne
duynhne force-pushed the refactor/multi-module branch from 54cf3b7 to 30cd5b2 Compare August 7, 2026 08:38
duynhne added 2 commits August 7, 2026 15:44
The single-module line github.com/duynhlab/pkg is frozen at
v0.35.0 and will never publish another version. A dependency graph
mixing the old require with a new per-module require fails with
ambiguous import; consumers must drop the old require (see
docs/MIGRATION.md). Nothing lives at the repo root anymore.
The runner's CodeQL CLI rejects build-mode none for Go, and
autobuild cannot see a multi-module monorepo with no root module.
Switch the go analysis to build-mode manual driving the new
make build target, which compiles every module under the tracer.
@duynhne
duynhne force-pushed the refactor/multi-module branch from 30cd5b2 to 2520053 Compare August 7, 2026 08:45
duynhne added 2 commits August 7, 2026 15:49
Platform, DBA and SRE teams plus @duyhenryer own the whole repo.
Owners share one * line: with duplicate patterns GitHub honors only
the last matching line, so separate lines would drop the teams.
Weekly grouped updates for workflow actions, labeled area/ci and
dependencies to match .github/labels.yaml.
@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@duynhne
duynhne merged commit 9f29472 into main Aug 7, 2026
12 checks passed
@duynhne
duynhne deleted the refactor/multi-module branch August 7, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants