File tree 6 files changed +59
-3
lines changed
6 files changed +59
-3
lines changed Original file line number Diff line number Diff line change 12
12
steps :
13
13
- uses : denoland/setup-deno@v1
14
14
with :
15
- deno-version : v1.15.0
15
+ deno-version : v1.17.2
16
16
- uses : actions/checkout@v2
17
17
- run : deno fmt --check
18
18
- run : deno lint
71
71
env :
72
72
OPA_CASES : test/cases/
73
73
OPA_TEST_CASES : testdata
74
- - run : ./e2e.sh
74
+
75
+ examples-node :
76
+ name : NodeJS examples
77
+ runs-on : ubuntu-latest
78
+ steps :
79
+ - uses : actions/checkout@v2
80
+ - uses : infracost/setup-opa@v1
81
+
82
+ with :
83
+ node-version : " 12"
84
+ - name : nodejs
85
+ run : >
86
+ npm ci
87
+ npm run build
88
+ ./e2e.sh
89
+
90
+ examples-deno :
91
+ name : Deno examples
92
+ runs-on : ubuntu-latest
93
+ steps :
94
+ - uses : actions/checkout@v2
95
+ - uses : infracost/setup-opa@v1
96
+ - uses : denoland/setup-deno@v1
97
+ with :
98
+ deno-version : v1.17.2
99
+ - run : make
100
+ working-directory : examples/deno
Original file line number Diff line number Diff line change
1
+ test.wasm
Original file line number Diff line number Diff line change
1
+ all : build run
2
+
3
+ build : test.wasm
4
+
5
+ test.wasm : test.rego
6
+ opa build -t wasm -e test/p $<
7
+ tar zxvf bundle.tar.gz /policy.wasm
8
+ mv policy.wasm test.wasm
9
+ touch test.wasm
10
+ rm bundle.tar.gz
11
+
12
+ run :
13
+ deno run --allow-read=test.wasm main.ts
Original file line number Diff line number Diff line change
1
+ import opa from "https://unpkg.com/@open-policy-agent/[email protected] /dist/opa-wasm-browser.esm.js" ;
2
+
3
+ const file = await Deno . readFile ( "test.wasm" ) ;
4
+ const policy = await opa . loadPolicy ( file . buffer . slice ( 0 , file . length ) ) ;
5
+ const input = { "foo" : "bar" } ;
6
+
7
+ const result = policy . evaluate ( input ) ;
8
+
9
+ if ( ! result [ 0 ] ?. result ) {
10
+ Deno . exit ( 1 ) ;
11
+ }
Original file line number Diff line number Diff line change
1
+ package test
2
+
3
+ p {
4
+ input.foo == " bar"
5
+ }
Original file line number Diff line number Diff line change 1
- module . exports = require ( ' ./opa' ) ;
1
+ module . exports = require ( " ./opa" ) ;
You can’t perform that action at this time.
0 commit comments