diff --git a/build/binary-smoke-test.sh b/build/binary-smoke-test.sh index 83f00016b8..5d8f9b03f3 100755 --- a/build/binary-smoke-test.sh +++ b/build/binary-smoke-test.sh @@ -3,13 +3,31 @@ set -eo pipefail OPA_EXEC="$1" TARGET="$2" -opa() { +github_actions_group() { local args="$*" echo "::group::$args" - $OPA_EXEC $args + $args echo "::endgroup::" } +opa() { + local args="$*" + github_actions_group $OPA_EXEC $args +} + +# assert_contains checks if the actual string contains the expected string. +assert_contains() { + local expected="$1" + local actual="$2" + if [[ "$actual" != *"$expected"* ]]; then + echo "Expected '$expected' but got '$actual'" + exit 1 + fi +} + + + + opa version opa eval -t $TARGET 'time.now_ns()' opa eval --format pretty --bundle test/cli/smoke/golden-bundle.tar.gz --input test/cli/smoke/input.json data.test.result --fail @@ -20,3 +38,7 @@ opa build --optimize 1 --output o1.tar.gz test/cli/smoke/data.yaml test/cli/smok echo '{"yay": "bar"}' | opa eval --format pretty --bundle o1.tar.gz -I data.test.result --fail opa build --optimize 2 --output o2.tar.gz test/cli/smoke/data.yaml test/cli/smoke/test.rego echo '{"yay": "bar"}' | opa eval --format pretty --bundle o2.tar.gz -I data.test.result --fail + +# Tar paths +opa build --output o3.tar.gz test/cli/smoke +github_actions_group assert_contains '/test/cli/smoke/test.rego' "$(tar -tf o3.tar.gz /test/cli/smoke/test.rego)" diff --git a/compile/compile.go b/compile/compile.go index 6484a2b014..ff71d3f77f 100644 --- a/compile/compile.go +++ b/compile/compile.go @@ -12,6 +12,7 @@ import ( "errors" "fmt" "io" + "path/filepath" "regexp" "sort" "strings" @@ -453,9 +454,10 @@ func (c *Compiler) initBundle() error { sort.Strings(modules) for _, module := range modules { + path := filepath.ToSlash(load.Files.Modules[module].Name) result.Modules = append(result.Modules, bundle.ModuleFile{ - URL: load.Files.Modules[module].Name, - Path: load.Files.Modules[module].Name, + URL: path, + Path: path, Parsed: load.Files.Modules[module].Parsed, Raw: load.Files.Modules[module].Raw, })