-
Notifications
You must be signed in to change notification settings - Fork 482
Introduce Shared YAML Dependency File To Manage Replace Directives #4862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
4095548 to
4eed3b6
Compare
92c493d to
903bfcc
Compare
a28eeea to
2fd651c
Compare
4691655 to
843ea22
Compare
🔍 Dependency ReviewBelow are the dependency changes detected in go.mod. For each, I evaluated whether code changes are required to adopt the updated state, based on version deltas and public changelogs/release notes. Collapsible details include relevant references or rationale. github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awss3receiver v0.139.0 -> v0.139.0 — ✅ Safe
Evidence
No code changes required. Notes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a centralized YAML-based system to manage Go module replace directives across the repository. The tool reads from dependency-replacements.yaml, generates formatted replace directives, and automatically injects them into target go.mod files between generated markers. This streamlines dependency management and ensures consistency across modules.
Key Changes
- Centralized dependency configuration: All replace directives are now defined in
dependency-replacements.yamlat the project root - Automated generation pipeline: A multi-step Go generate pipeline (generate → apply → tidy → cleanup) processes the YAML and updates target files
- CI validation workflow: GitHub Actions workflow ensures go.mod files stay synchronized with the YAML source
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
dependency-replacements.yaml |
New centralized YAML file defining all replace directives with comments |
tools/sync-module-dependencies/internal/types/types.go |
Type definitions for YAML parsing and module configuration |
tools/sync-module-dependencies/internal/helpers/files.go |
File path resolution and YAML loading utilities |
tools/sync-module-dependencies/internal/generate-replaces.go |
Template-based generation of replace directive text files |
tools/sync-module-dependencies/internal/apply-replaces.go |
Logic to inject generated blocks into target files using markers |
tools/sync-module-dependencies/internal/tidy-modules.go |
Runs go mod tidy on affected modules |
tools/sync-module-dependencies/internal/cleanup.go |
Removes temporary .txt files after generation |
tools/sync-module-dependencies/replaces-mod.tpl |
Template for formatting go.mod replace directives |
tools/sync-module-dependencies/generate.go |
Orchestrates the generation pipeline via go generate |
tools/sync-module-dependencies/e2e_test.go |
E2E tests covering new block insertion and existing block updates |
tools/sync-module-dependencies/go.mod |
Module definition for the sync tool |
tools/sync-module-dependencies/go.sum |
Dependency checksums for the sync tool |
tools/sync-module-dependencies/README.md |
Documentation explaining usage, configuration, and troubleshooting |
go.mod |
Updated with generated replace directives between markers |
Makefile |
Adds sync-module-dependencies target and integrates it into local build workflow |
.gitignore |
Excludes temporary .txt files from version control |
.github/workflows/check-sync-module-dependencies.yml |
CI workflow validating go.mod synchronization |
tools/sync-module-dependencies/resources/flow_diagram.png |
Visual diagram of the generation pipeline (binary file) |
6f7b5e5 to
6a7310e
Compare
thampiotr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking solid! Got a few comments on how we could maybe simplify it if possible to make it leaner.
| return "\n" | ||
| } | ||
|
|
||
| func main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have several main functions declared in one package, could we avoid this? most IDEs will complain and some go commands that operate on entire package will fail I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One good alternative could be to use Cobra to create a tool with a few subcommands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also create a testdata/... folder and put there an example project that we can check into the repo. Might be easier to read and get a feel for the tool this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I quite like that, i'll do some exploration there
8b1d3bb to
d784448
Compare
Co-authored-by: Piotr <[email protected]>
d784448 to
5f4d6e4
Compare
5f4d6e4 to
31c7d2b
Compare
Part of #4719
This is an initial implementation taken from the PoC for Proposal 2 from this design doc
What is included
sync-module-dependenciestool in the Alloy project that can be run withmake sync-module-dependencies. The steps are broken down in agenerate.gofile, so each step can also be run individuallydependency-replacements.yamlfile located at the root of the project, transform the data, and apply it to the maingo.modfile for Alloy. Note that for the time being this YAML file should not contain local replacements (e.g. we are not including thesyntaxmodule in that file in this PR)go.mod, but it is formatting them a bit due to the generation template being structuredmake sync-module-dependenciesand check that nothing is changed in thego.modfile in pipelines, this is to ensure that the state between the YAML replacements andgo.modfile(s) are alignedWhat is the intention
What will be done as follow ups
go.modfile generation, notocbyaml files - the latter will be introduced in a follow up PR. I've tried to keep things as "simple" as possible for nowNotes to Reviewers
The changes are broken down incrementally in the commits in order to make it a bit easier to understand what has been added