Skip to content

Commit

Permalink
build: Fix wrong windows bundle tar files path separator (open-policy…
Browse files Browse the repository at this point in the history
  • Loading branch information
shm12 authored Dec 19, 2022
1 parent 34f6939 commit 30356a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
26 changes: 24 additions & 2 deletions build/binary-smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"
6 changes: 4 additions & 2 deletions compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"errors"
"fmt"
"io"
"path/filepath"
"regexp"
"sort"
"strings"
Expand Down Expand Up @@ -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,
})
Expand Down

0 comments on commit 30356a7

Please sign in to comment.