From 9141f5b7588baed0315cf09473529419541f8d88 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Tue, 28 May 2024 09:51:36 +0200 Subject: [PATCH 1/2] tests: utils: assert_directories_equal: Convert ignore_files to a tuple Making an empty list a default argument is dangerous because lists are mutable. Luckily for us the argument isn't being updated in the function. Still, a tuple is the suggested approach here. While at it, add a doc string entry for the argument in question. Signed-off-by: Erik Skultety --- tests/helper_utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/helper_utils/__init__.py b/tests/helper_utils/__init__.py index 47ea5ba77..4152b40ac 100644 --- a/tests/helper_utils/__init__.py +++ b/tests/helper_utils/__init__.py @@ -4,12 +4,13 @@ from typing import Union -def assert_directories_equal(dir_a, dir_b, ignore_files=[]): +def assert_directories_equal(dir_a, dir_b, ignore_files=()): """ Check recursively directories have equal content. :param dir_a: first directory to check :param dir_b: second directory to check + :param ignore_files: a sequence of file names to be ignored in the comparisons """ ignore_files = list(set(filecmp.DEFAULT_IGNORES).union(ignore_files)) dirs_cmp = filecmp.dircmp(dir_a, dir_b, ignore=ignore_files) From a3540cf7cdcee00cc62f4640ae1014fb590044c0 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Wed, 29 May 2024 10:26:11 +0200 Subject: [PATCH 2/2] workers: Drop explicit GOSUMDB=off setting occurrences We should only really need to set GOSUMDB explicitly with the module fetch so that we can verify e.g. a toolchain that was downloaded as a result of using GOTOOLCHAIN=auto in resolve_gomod. Every other occurrence where we explicitly disable GOSUMDB is redundant. As for hermetic (i.e. network isolated) builds, as long GOMODCACHE is provided, the sum database should not be needed. As far as additional toolchains are concerned with regards to checking the sum database during offline project builds, setting the GOPROXY variable to point to the correct location on disk within GOMODCACHE should be enough to pass any kind of verification. Signed-off-by: Erik Skultety --- cachito/web/static/api_v1.yaml | 3 --- cachito/workers/config.py | 4 ---- cachito/workers/pkg_managers/gomod.py | 1 + tests/test_workers/test_tasks/test_gomod.py | 1 - 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/cachito/web/static/api_v1.yaml b/cachito/web/static/api_v1.yaml index 2019bfebb..ce25ef27e 100644 --- a/cachito/web/static/api_v1.yaml +++ b/cachito/web/static/api_v1.yaml @@ -1219,9 +1219,6 @@ components: GOPATH: value: deps/gomod kind: path - GOSUMDB: - value: off - kind: literal GOTOOLCHAIN: value: local kind: literal diff --git a/cachito/workers/config.py b/cachito/workers/config.py index 435bf9556..e894d45d8 100644 --- a/cachito/workers/config.py +++ b/cachito/workers/config.py @@ -29,9 +29,6 @@ class Config(object): cachito_archives_minimum_age_days = 365 cachito_auth_type: Optional[str] = None cachito_default_environment_variables = { - "gomod": { - "GOSUMDB": {"value": "off", "kind": "literal"}, - }, "npm": { "CHROMEDRIVER_SKIP_DOWNLOAD": {"value": "true", "kind": "literal"}, "CYPRESS_INSTALL_BINARY": {"value": "0", "kind": "literal"}, @@ -162,7 +159,6 @@ class TestingConfig(DevelopmentConfig): cachito_default_environment_variables = { "gomod": { "GO111MODULE": {"value": "on", "kind": "literal"}, - "GOSUMDB": {"value": "off", "kind": "literal"}, }, "npm": { "CHROMEDRIVER_SKIP_DOWNLOAD": {"value": "true", "kind": "literal"}, diff --git a/cachito/workers/pkg_managers/gomod.py b/cachito/workers/pkg_managers/gomod.py index ff41dff3e..459830e91 100644 --- a/cachito/workers/pkg_managers/gomod.py +++ b/cachito/workers/pkg_managers/gomod.py @@ -313,6 +313,7 @@ def resolve_gomod(app_source_path, request, dep_replacements=None, git_dir_path= "PATH": os.environ.get("PATH", ""), "GOMODCACHE": "{}/pkg/mod".format(temp_dir), "GOTOOLCHAIN": "auto", + "GOSUMDB": "sum.golang.org", } if "cgo-disable" in request.get("flags", []): env["CGO_ENABLED"] = "0" diff --git a/tests/test_workers/test_tasks/test_gomod.py b/tests/test_workers/test_tasks/test_gomod.py index 162fd58d4..089a48fbd 100644 --- a/tests/test_workers/test_tasks/test_gomod.py +++ b/tests/test_workers/test_tasks/test_gomod.py @@ -113,7 +113,6 @@ def directory_present(*args, **kwargs): # Add the default environment variables from the configuration env_vars = { "GO111MODULE": {"value": "on", "kind": "literal"}, - "GOSUMDB": {"value": "off", "kind": "literal"}, } sample_env_vars.update(env_vars)