Skip to content
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

Minimal changes to enable a Go workspace #19423

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ivanvc
Copy link
Member

@ivanvc ivanvc commented Feb 15, 2025

This pull request is a follow-up on #19314.

It introduces minimal changes to enable a workspace in the project. We can iterate on it later to remove the script nuances of looping over the modules to execute commands, as they can now be executed from the top level of the repository.

Part of #18409.

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ivanvc
Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

codecov bot commented Feb 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.87%. Comparing base (d0b8863) to head (d3c2c0b).

Additional details and impacted files

see 24 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #19423      +/-   ##
==========================================
+ Coverage   68.81%   68.87%   +0.05%     
==========================================
  Files         421      421              
  Lines       35901    35901              
==========================================
+ Hits        24705    24726      +21     
+ Misses       9770     9745      -25     
- Partials     1426     1430       +4     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0b8863...d3c2c0b. Read the comment docs.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ivanvc
Copy link
Member Author

ivanvc commented Feb 15, 2025

/test all

@ivanvc ivanvc force-pushed the introduce-a-min-workspace branch 2 times, most recently from d555146 to b7e86a4 Compare February 18, 2025 06:03
@ivanvc ivanvc changed the title [do not review] Go workspace Minimal changes to enable a Go workspace Feb 18, 2025
@ivanvc ivanvc force-pushed the introduce-a-min-workspace branch from b7e86a4 to eb81e5b Compare February 18, 2025 06:26
@ivanvc ivanvc marked this pull request as ready for review February 18, 2025 06:45
@ivanvc
Copy link
Member Author

ivanvc commented Feb 18, 2025

/cc @ahrtr @serathius

@@ -14,7 +14,7 @@ function bom_fixlet {
# shellcheck disable=SC2207
modules=($(modules_for_bom))

if GOFLAGS=-mod=mod run_go_tool "github.com/appscodelabs/license-bill-of-materials" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GOFLAGS=-mod=mod is this even a correct flag? Could we remove it regardless of workspace migration?

Copy link
Member Author

@ivanvc ivanvc Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so. This should predate Go 1.1113.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, never mind. Actually, I believe, due to the note in bom_pass, we may need to leave the -mod=mod flag in the tests. But you're right. There's no need for it to be here, as test_lib.sh doesn't define a GOFLAGS=-mod that we need to override. I'll open a pull request for this change.

@ahrtr
Copy link
Member

ahrtr commented Feb 21, 2025

I will review this PR after we officially release v3.6.0, thx

ivanvc and others added 2 commits March 7, 2025 22:31
Introduce a new Go workspace that references all the current submodules.
To preserve the current behavior, point all of the current
FORBIDDEN_DEPENCENCY virtual dependencies to the same path.

Add scripts/update_go_workspace.sh that generates the Go workspace
file (go.work) based on the submodules found in the project and creates
the go.work.sum file after running go mod download. Added this script to
the fix Makefile target. Even though, the number of modules in the etcd
repository is small, by adding an automated way of updating the go.work
modules future proofs the project in case there are new modules or
removal of them.

Point all forbidden dependencies to a common virtual place (top-level
FORBIDDEN_DEPENDENCY). For the workspace to function we need all
dependencies to be consistent across the repository. That means that the
current approach with FORBIDDEN_DEPENDENCY doesn't work, because they
are pointing to different directories. Set the fictional v3.999.999
version for these dependencies, so they are consitent, and they don't
clash with the actual depdendencies references in other modules.

Co-authored-by: Tim Hockin <thockin@google.com>
Signed-off-by: Ivan Valdes <ivan@vald.es>
Introduce a new `verify-go-workspace` make target executed by the
`verify` target. The pull-etcd-verify presubmit prow job will execute
it. It ensures that the Go workspace (`go.work` and `go.work.sum`) is in
sync.

Signed-off-by: Ivan Valdes <ivan@vald.es>
Add checking for the Go toolchain directive in the go.work file too.

Signed-off-by: Ivan Valdes <ivan@vald.es>
@ivanvc ivanvc force-pushed the introduce-a-min-workspace branch from eb81e5b to 9ed8ecc Compare March 8, 2025 06:32
Remove `GOFLAGS=-mod=mod` from the execution of
license-bill-of-materials.

Signed-off-by: Ivan Valdes <ivan@vald.es>
@ivanvc ivanvc force-pushed the introduce-a-min-workspace branch from 9ed8ecc to d3c2c0b Compare March 8, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants