[chore] Use crosslink tidylist
in make gotidy
#37142
Open
+332
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The
make gotidy
command currently runsgo mod tidy
on every module in the repository once, in alphabetical order. Under some circumstances, this turns out to not converge in one run, leaving modules in a "updates to go.mod needed" state, which has caused issues in CI such as core#11795.To solve this problem, I recently added a
tidylist
subcommand tocrosslink
, which analyzes the dependency graph of the repo and generates a list of modules in topological order, which should eliminate most (if not all) of these non-convergence cases.Description
This PR adds a
make tidylist
and a corresponding CI check to maintain aninternal/tidylist/tidylist.txt
file, which is then used in the modifiedmake gotidy
command to tidy all modules in the repo in order.Since the
otelcontribcol
andoteltestbedcol
are not gitted and may or may not exist in a local copy of the repo, inmake tidylist
I manually remove them from the list generated bycrosslink
to avoid a discrepancy that might fail the CI check.For dependency graphs that contain cycles, such as the modules in Contrib, the tool uses an extension of topological sorting. However, because circular dependencies are hard to work with for multiple reasons, the tool will check the list of modules that have them against an allowlist (
internal/tidylist/allow-circular.txt
), which will have to be updated manually if dependency cycles are added or removed.Link to tracking issue
Updates core#11795 (the next step will be to unrevert core#11670)
Testing
Testing this is a bit difficult as the errors this solves are quite rare. But the tool implements the same algorithm as the Python script I tried in #36723, which I successfully tested against the release process that failed in core#11795, so I have reason to believe the algorithm is correct. I expect any potential issues arising from this PR to be related to the integration of the tool rather than the logic in itself.