- Create scripts/fix/mod-tidy.sh with proper workspace module iteration
- Remove go.sum files before tidy to ensure clean state (regenerated by go mod tidy)
- Use run wrapper for consistent command execution and logging
- Update Makefile fix-mod-tidy target to use the new script
- Add ETCD_ROOT_DIR support for dynamic path resolution
- Delete module_mod_tidy_fix and mod_tidy_fix_pass functions from scripts/test.sh
(functionality moved to scripts/fix/mod-tidy.sh)
Signed-off-by: Himanshu Singh <himanshuich20@gmail.com>
* Remove iteration over packages; with the Go workspace, we don't need
to iterate.
* Replace `KEEP_GOING_TESTS` behavior by using the Go `-failfast` test
flag.
Signed-off-by: Ivan Valdes <ivan@vald.es>
The GRPC community expressed their concern about a possible breakage on
the etcd project when they switch or remove some of the experimental
APIs. The GRPC community clearly express their contract around these
APIs, however the etcd project has some features that build on that.
As a norm we must not build on these kind of APIs, so we can set a
linter to avoid this to happen again and run in each presubmit.
Signed-off-by: Antonio Ojea <aojea@google.com>
Add OS detection for sed in-place editing (BSD vs GNU) to use a
portable sed insert syntax with literal newlines.
Also, replace `dirname -z` (GNU-specific) with while-read loop
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
Signed-off-by: Chun-Hung Tseng <henrytseng@google.com>
Improvements to the update_dep.sh script:
- Add argument validation and usage instructions
- Add print_current_dep_version function to show versions before/after
- Add is_fully_indirect function with confirmation prompt for indirect deps
- Improve update_module to use go mod edit for reliable indirect dep updates
- Make version parameter optional (defaults to latest)
- Fix bash 3.2 compatibility with ${2:-} syntax
- Reduce logging noise by only logging when actually updating
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
Signed-off-by: Chun-Hung Tseng <henrytseng@google.com>
The robustness CI jobs are failing with "flag provided but not defined:
-bin-dir" because the test path includes subpackages (./tests/robustness/...)
that don't register this flag.
PR 20962 changed the test invocation to use ./tests/robustness/... which
runs tests in all subpackages. The validate/ and model/ subpackages contain
unit tests that don't import framework/e2e (which registers -bin-dir), so
they fail when this flag is passed.
PR 21039 attempted to fix the issue but only changed the test runner
function, not the package path.
This change removes the /... suffix to only run tests in the main
robustness package, restoring the original behavior.
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Remove running the tests for all the packages under ./tests/robustness.
Restore the old behavior of running only the tests from the top-level
robustness package.
Signed-off-by: Ivan Valdes <ivan@vald.es>
Introduce the new functions: run_go_tests and
run_go_test_expanding_packages, which implement (without Shellcheck
exceptions) the old behavior from go_test, simplifying the arguments
received.
Replaced the three possible values mode with:
1. keep_going: By using the KEEP_GOING_TESTS environment variable. This
mode expanded the relative modules; it can be run by using
run_go_tests_expanding_packages.
2. parallel: It worked without expanding the relative modules with the
absolute modules. Therefore, this mode can be run directly using
run_go_tests.
3. fail_fast: By adding an argument "-failfast", and not setting the
KEEP_GOING_TESTS environment variable.
The argument flags_for_package_func can be replaced by regular arguments
passed to the function.
These two changes simplify the complexity of the go test wrapper
function and allow further customization in the callers.
The JUnit XML generation works the same way, by reading the
JUNIT_REPORT_DIR or ARTIFACTS environment variable. It generates the
same reports.
Temporarily introduce the get_junit_filename_prefix function, as a
replacement for junitFilenamePrefix. The latter will be removed once all
test targets are using the new functions.
Finally, update the unit tests function to make use of the new
functions, and allow running the tests by using the workspace (i.e.,
there's no need to change directories anymore).
Signed-off-by: Ivan Valdes <ivan@vald.es>
Remove the custom environment variable GOLANG_TEST_SHORT.
It is currently used by Main tests (TestMain), as we can't skip tests
because testing.M doesn't implement testing.TB. It is possible to do a
clean os.Exit(0) (current behavior), but calling testing.Short() fails
because this function expects flags to be parsed before.
So, it is possible to remove the custom behavior (GOLANG_TEST_SHORT) by
parsing flags (if required) before calling testing.Short(), then
immediately exit if the result is true (-short flag is set).
Signed-off-by: Ivan Valdes <ivan@vald.es>
Follow the approach of a script per Makefile target. Rename it to
shell_ws for consistency with the verify target.
Signed-off-by: Ivan Valdes <ivan@vald.es>
We're already calling golangci-lint --fix. We require the gofmt
formatter, and it supports autofix. Therefore, running go fmt manually
after golangci-lint --fix runs doesn't have any effect.
Signed-off-by: Ivan Valdes <ivan@vald.es>
Use the new workspace helper functions.
By moving it to a test.sh pass, we can chain it in the fix Makefile
target prerequisites, and it can be called before update-go-workspace.
Signed-off-by: Ivan Valdes <ivan@vald.es>
Use a new function for commands that need to change directories to the
Go workspace module sub directory. For example, go mod doesn't receive
arguments, it needs to run from the directory that has the go.mod file.
Signed-off-by: Ivan Valdes <ivan@vald.es>
Currently, we need to force word splitting, as we need to pass multiple
arguments, not a single one, to the command that will run using the
workspace modules.
To properly remove this exception, we need to use an array. The problem
with Bash arrays is that you can't return them in a function. So, the
way to build an array is by reference. Otherwise, we'll end up
rebuilding the arrays every time we need to call these functions.
Signed-off-by: Ivan Valdes <ivan@vald.es>
This is now replaced by the golangci-lint goheader linter.
Deletes the bash helper go_srcs_in_module, as it is not used anymore by
any other static check functions.
Signed-off-by: Ivan Valdes <ivan@vald.es>
The gofmt static check is already part of golangci-lint's gofmt
formatter. Therefore, it's a duplicate check. We can simplify and let
golangci-lint do the heavy lifting.
Signed-off-by: Ivan Valdes <ivan@vald.es>
The tool github.com/appscodelabs/license-bill-of-materials fails during
the first run in a recently cloned/fresh repository. Because it captures
the output, and the first run shows the download of dependencies. In
8b02416301, we intentionally added a new
execution before evaluating whether the BOM is up to date. However, this
is polluting the logs as it has the expected failure. Redirecting the
output to /dev/null alleviates the issue.
Signed-off-by: Ivan Valdes <ivan@vald.es>
Using shadow from golangci-lint doesn't lint generated files
(protobufs), so it's safe to include all the files.
Signed-off-by: Ivan Valdes <ivan@vald.es>
Adds workspace_relative_modules, and run_for_all_workspace_modules which
runs a given function for all the workspace module from the top-level of
the repository, without iterating by module/directory.
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>