From cc4e5403e8eb5266b0c2936ffa30b730c1685324 Mon Sep 17 00:00:00 2001 From: Simon Baird Date: Thu, 13 Jun 2024 15:39:02 -0400 Subject: [PATCH] Support using arbitrary & specific ec version Optionally specify a git ref that will be used as the ec version for running the test suite using make. This lets me confirm that v0.1-alpha is not compatible with the current latest policies and v0.2 is compatible[1]. EC_REF=release-v0.1-alpha make ec-version quiet-test #=> fails EC_REF=release-v0.2 make ec-version quiet-test #=> passes EC_REF=release-v0.4 make ec-version quiet-test #=> passes You could use a specific git sha instead of a branch if you want to. Ref: https://issues.redhat.com/browse/EC-695 [1] ..probably. The test suite passes at least. --- Makefile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6fd828d7..ee0d18c0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,16 @@ POLICY_DIR=./policy # Use go run so we use the exact pinned versions from the mod file. # Use ec for the opa and conftest commands so that our custom rego # functions are available. -EC=go run github.com/enterprise-contract/ec-cli +ifndef EC_REF + EC_MOD=github.com/enterprise-contract/ec-cli +else + # EC_REF can be set to use ec built from a particular ref, e.g.: + # EC_REF=release-v0.2 make ec-version quiet-test + EC_MOD=github.com/enterprise-contract/ec-cli@$(EC_REF) +endif + +EC=go run $(EC_MOD) + OPA=$(EC) opa CONFTEST=EC_EXPERIMENTAL=1 $(EC) TKN=go run github.com/tektoncd/cli/cmd/tkn @@ -66,6 +75,14 @@ help: ## Display this help. ##@ Development +ec-version: + @echo $(EC_MOD) + @# To confirm that EC_REF is doing what you think it's doing + @go list -m -json $(EC_MOD) | jq -r .Version + @# Actually we get "development" as the version and "0001-01-01" + @# as the change date but let's show it anyhow + @$(EC) version + # Todo maybe: Run tests with conftest verify instead .PHONY: test test: ## Run all tests in verbose mode and check coverage