@@ -13,11 +13,16 @@ linters:
1313 go tool cover -func=coverage.out | sed ' s/%$$//' | awk ' $$2 == "isCedarType" { next } $$2 == "Entity" && $$1 ~ /entity\.go/ { next } $$2 == "typeOfExtensionCall" { next } { if ($$3 < 100.0) { printf "Insufficient code coverage for %s\n", $$0; failed=1 } } END { exit failed }'
1414
1515# Download the latest corpus tests tarball and overwrite corpus-tests.tar.gz if changed
16- .PHONY : check-upstream-corpus
1716check-upstream-corpus :
18- @tmp=" $$ (mktemp)" && \
19- curl -fL -o " $$ tmp" https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz && \
20- if cmp -s " $$ tmp" corpus-tests.tar.gz; then echo " corpus-tests.tar.gz is up to date." ; rm -f " $$ tmp" ; else mv " $$ tmp" corpus-tests.tar.gz; echo " corpus-tests.tar.gz updated." ; fi
17+ @tmpdir=" $$ (mktemp -d)" && \
18+ trap ' rm -rf "$$tmpdir"' EXIT && \
19+ curl -fL -o " $$ tmpdir/corpus-tests.tar.gz" https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz && \
20+ if cmp -s " $$ tmpdir/corpus-tests.tar.gz" corpus-tests.tar.gz; then \
21+ echo " corpus-tests.tar.gz is up to date." ; \
22+ else \
23+ mv " $$ tmpdir/corpus-tests.tar.gz" corpus-tests.tar.gz; \
24+ echo " corpus-tests.tar.gz updated." ; \
25+ fi
2126
2227# Use an order-only prerequisite to check for changes. This allows other targets to
2328# reference corpus-tests.tar.gz as a dependency so that they'll only be re-created
@@ -27,45 +32,46 @@ corpus-tests.tar.gz: | check-upstream-corpus
2732# Convert Cedar schemas to JSON schemas
2833corpus-tests-json-schemas.tar.gz : corpus-tests.tar.gz
2934 @echo " Generating JSON schemas from Cedar schemas..."
30- @rm -rf /tmp/corpus-tests /tmp/corpus-tests-json-schemas
31- @mkdir -p /tmp/corpus-tests-json-schemas
32- @tar -xzf corpus-tests.tar.gz -C /tmp/
33- @for schema in /tmp/corpus-tests/* .cedarschema; do \
34- basename=$$(basename $$schema .cedarschema) ; \
35- echo " Converting $$ basename.cedarschema..." ; \
36- cedar translate-schema --direction cedar-to-json --schema " $$ schema" > " /tmp/corpus-tests-json-schemas/$$ basename.cedarschema.json" 2>&1 ; \
37- done
38- @tar -czf corpus-tests-json-schemas.tar.gz -C /tmp corpus-tests-json-schemas
39- @rm -rf /tmp/corpus-tests /tmp/corpus-tests-json-schemas
40- @echo " Done! Created corpus-tests-json-schemas.tar.gz"
35+ @tmpdir=" $$ (mktemp -d)" && \
36+ trap ' rm -rf "$$tmpdir"' EXIT && \
37+ tar -xzf corpus-tests.tar.gz -C " $$ tmpdir" && \
38+ mkdir -p " $$ tmpdir/corpus-tests-json-schemas" && \
39+ for schema in " $$ tmpdir" /corpus-tests/* .cedarschema; do \
40+ basename=$$(basename "$$schema" .cedarschema) ; \
41+ echo " Converting $$ basename.cedarschema..." ; \
42+ cedar translate-schema --direction cedar-to-json --schema " $$ schema" \
43+ > " $$ tmpdir/corpus-tests-json-schemas/$$ basename.cedarschema.json" 2>&1 ; \
44+ done && \
45+ tar -czf corpus-tests-json-schemas.tar.gz -C " $$ tmpdir" corpus-tests-json-schemas && \
46+ echo " Done! Created corpus-tests-json-schemas.tar.gz"
4147
42- # Build cedar-validation-tool and generate validation results
48+ # Build cedar-validation-tool
4349test/cedar-validation-tool/target/release/cedar-validation-tool : test/cedar-validation-tool/src/main.rs test/cedar-validation-tool/Cargo.toml
4450 @echo " Building cedar-validation-tool..."
4551 @cd test/cedar-validation-tool && cargo build --release
4652
53+ # Generate validation results from Rust Cedar
4754corpus-tests-validation.tar.gz : corpus-tests.tar.gz test/cedar-validation-tool/target/release/cedar-validation-tool
4855 @echo " Generating validation results from Rust Cedar..."
49- @rm -rf /tmp/corpus-tests /tmp/corpus-tests-validation
50- @mkdir -p /tmp/corpus-tests-validation
51- @tar -xzf corpus-tests.tar.gz -C /tmp/
52- @for testjson in /tmp/corpus-tests/* .json; do \
56+ @tmpdir=" $$ (mktemp -d)" && \
57+ trap ' rm -rf "$$tmpdir"' EXIT && \
58+ tar -xzf corpus-tests.tar.gz -C " $$ tmpdir" && \
59+ mkdir -p " $$ tmpdir/corpus-tests-validation" && \
60+ for testjson in " $$ tmpdir" /corpus-tests/* .json; do \
5361 case " $$ testjson" in * .entities.json) continue ;; esac ; \
54- basename=$$(basename $$testjson .json) ; \
62+ basename=$$(basename " $$testjson" .json) ; \
5563 test/cedar-validation-tool/target/release/cedar-validation-tool \
56- " $$ testjson" " /tmp/corpus-tests-validation/$$ {basename}.validation.json" ; \
57- done
58- @cd /tmp && tar -czf corpus-tests-validation.tar.gz corpus-tests-validation/
59- @mv /tmp/corpus-tests-validation.tar.gz .
60- @rm -rf /tmp/corpus-tests /tmp/corpus-tests-validation
61- @echo " Done! Created corpus-tests-validation.tar.gz"
64+ " $$ testjson" " $$ tmpdir/corpus-tests-validation/$$ {basename}.validation.json" ; \
65+ done && \
66+ tar -czf corpus-tests-validation.tar.gz -C " $$ tmpdir" corpus-tests-validation && \
67+ echo " Done! Created corpus-tests-validation.tar.gz"
6268
6369# Regenerate validation data for x/exp/schema/validate/testdata
6470testdata-validation : test/cedar-validation-tool/target/release/cedar-validation-tool
6571 @echo " Regenerating testdata validation files..."
6672 @for testjson in x/exp/schema/validate/testdata/* .json; do \
6773 case " $$ testjson" in * .entities.json|* .validation.json) continue ;; esac ; \
68- basename=$$(basename $$testjson .json) ; \
74+ basename=$$(basename " $$testjson" .json) ; \
6975 echo " Validating $$ basename..." ; \
7076 test/cedar-validation-tool/target/release/cedar-validation-tool \
7177 " $$ testjson" " x/exp/schema/validate/testdata/$$ {basename}.validation.json" ; \
0 commit comments