From a7ed032bde0faa277e5362b3b3b620bbd4c21c58 Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Mon, 14 Oct 2024 16:07:18 +0200 Subject: [PATCH] Make sure `ec` is built with network In #1188 tests were made to run without network. This works if the local golang module cache already contains the required dependencies, i.e can be built offline. When a dependency is not available from the cache, due to the offline nature of the namespace the build fails. This circumvents that by invoking the equivalent of `ec opa version` so that the `ec` command is build outside the offlined namespace. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 15051c2f..dd041762 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,13 @@ OPA=$(EC) opa CONFTEST=EC_EXPERIMENTAL=1 $(EC) TKN=go run github.com/tektoncd/cli/cmd/tkn TEST_CMD_DEFAULT=$(OPA) test $(TEST_FILES) $(TEST_FILTER) +# if unshare is available we isolate the process to run without network access, +# if it is not we run as is; building ec will require network access to download +# the dependencies, for this we run `ec version` to have it built first ifeq ($(shell command -v unshare),) TEST_CMD=$(TEST_CMD_DEFAULT) else - TEST_CMD=unshare -r -n $(TEST_CMD_DEFAULT) + TEST_CMD=$(EC) version > /dev/null && unshare -r -n $(TEST_CMD_DEFAULT) endif LICENSE_IGNORE=-ignore '.git/**'