[build] Add go mod tidy before go mod vendor for Go 1.24 compat#157
[build] Add go mod tidy before go mod vendor for Go 1.24 compat#157yxieca merged 1 commit intosonic-net:masterfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Updates the top-level build orchestration to improve Go module vendoring behavior when building sonic-mgmt-framework with newer Go toolchains (notably Go 1.24 in Debian Trixie).
Changes:
- Run
go mod tidybeforego mod vendorin the$(GO_DEPS)Makefile target to satisfy stricter module-graph consistency requirements in newer Go versions.
| $(GO_DEPS): $(GO_MOD) $(GO_CODEGEN_INIT) | ||
| $(GO) mod tidy | ||
| $(GO) mod vendor | ||
| $(MGMT_COMMON_DIR)/patches/apply.sh vendor | ||
| touch $@ |
There was a problem hiding this comment.
$(GO_DEPS) only depends on go.mod (and codegen init), but the recipe runs go mod tidy/vendor which reads and may update go.sum. If go.sum changes (e.g., via merge/conflict resolution or dependency update) while vendor/.done already exists, make go-deps won’t rerun and vendor/ can become stale relative to go.sum. Consider adding go.sum as an explicit prerequisite (e.g., define GO_SUM=go.sum and include it in the dependency list) so vendoring is rebuilt when checksums change.
|
Suggest add version protection like sonic-net/sonic-mgmt-common#207. Otherwise looks good. |
…o 1.24 compat Add version-protected go mod tidy before go mod vendor, matching the approach in sonic-mgmt-common #207. The version check ensures go mod tidy only runs when the installed Go version is >= the go.mod directive, preventing failures in CI environments with older Go versions. Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
4a446db to
9967ddc
Compare
|
Good catch — updated to add the same version guard as sonic-mgmt-common #207. Now |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@yxieca Good suggestion — I'll add Go version protection similar to sonic-mgmt-common#207. Will push an update. |
|
@yxieca Actually, looking more closely — the version protection is already in this PR! The guard checks The version check block (lines 40-47 in the diff): @GO_MOD_VER=$$(sed -n 's/^go //p' go.mod) && \
GO_CUR_VER=$$(\ env GOVERSION | sed 's/go//') && \
if printf '%s\n' "$$GO_MOD_VER" "$$GO_CUR_VER" | sort -V | head -1 | grep -qx "$$GO_MOD_VER"; then \
echo "Running go mod tidy"; \
\ mod tidy; \
else \
echo "Skipping go mod tidy"; \
fiOn bookworm (Go 1.21), it skips tidy. On trixie (Go 1.24), it runs tidy then vendor. Backward compatible either way. |
|
@yxieca Thanks for the review! This PR actually already includes the same version guard as sonic-mgmt-common#207 — the |
Description
[agent]
Add
go mod tidybeforego mod vendorin Makefile for Go 1.24 compatibility.What I did
Added
$(GO) mod tidybefore the$(GO) mod vendorcall in the Makefile.Why I did it
Go 1.24 (shipped in Debian Trixie) enforces stricter module graph consistency. When
go.modspecifies an older Go version but the build runs under Go 1.24,go mod vendorfails with module resolution errors unlessgo mod tidyruns first.How I verified it
Successfully built sonic-mgmt-framework under a Trixie slave container with Go 1.24.
On bookworm (Go 1.21),
go mod tidyis a no-op — no behavior change.Type of change