File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 7272 if : success() || failure() # always run even if the previous step fails
7373 with :
7474 report_paths : ' **/target/surefire-reports/TEST-*.xml'
75+
76+ readme-ci :
77+ runs-on : ubuntu-latest
78+ name : CI - Readme
79+ steps :
80+ - name : checkout
81+ uses : actions/checkout@v4
82+ - name : Set up Java
83+ uses : actions/setup-java@v4
84+ with :
85+ distribution : ' temurin'
86+ java-version : ' 17'
87+ cache : maven
88+ - name : Build Opa Java Wasm
89+ run : mvn clean install -DskipTests
90+ env :
91+ MAVEN_OPTS : " -Dmaven.repo.local=${{ github.workspace }}/repository"
92+ # Test root Readme
93+ - name : jbang
94+ uses : jbangdev/jbang-action@9f8c55e0a2b6b297711162b20c209c5e07076e59 # tag=v0.117.1
95+ with :
96+ script : Readme.md
97+ env :
98+ JBANG_REPO : " ${{ github.workspace }}/repository"
99+ - name : compare results
100+ run : diff -r Readme.result TestReadme.result
Original file line number Diff line number Diff line change 11target
22.idea
33testcases.tar.gz
4+ policy.wasm
5+ TestReadme.result
Original file line number Diff line number Diff line change @@ -29,14 +29,26 @@ With Maven add the core module dependency:
2929</dependency >
3030```
3131
32+ <!--
33+ ```java
34+ //DEPS com.styra.opa:opa-java-wasm:999-SNAPSHOT
35+
36+ var policyPath = Path.of("core/src/main/resources/demo-policy.wasm");
37+ var targetPath = Path.of("policy.wasm");
38+ Files.copy(policyPath, targetPath, StandardCopyOption.REPLACE_EXISTING);
39+
40+ var policyWasm = new File("policy.wasm");
41+ ```
42+ -->
43+
3244## Usage
3345
3446There are only a couple of steps required to start evaluating the policy.
3547
3648### Import the module
3749
3850``` java
39- import com.styra.opa.wasm.Opa ;
51+ import com.styra.opa.wasm.OpaPolicy ;
4052```
4153
4254### Load the policy
@@ -71,13 +83,19 @@ APIs for policy evaluation:
7183Example:
7284
7385``` java
74- input = ' { "path": "/ ", "role": "admin"} ' ;
86+ var input = " { \ " path\ " : \" / \ " , \ " role\ " : \ " admin\" } " ;
7587
7688var policy = OpaPolicy . builder(). withPolicy(policyWasm). build();
7789var result = policy. evaluate(input);
7890System . out. println(" Result is: " + result);
7991```
8092
93+ <!--
94+ ```java
95+ Files.write(Paths.get("TestReadme.result"), (result + "\n").getBytes());
96+ ```
97+ -->
98+
8199> For any ` opa build ` created WASM binaries the result set, when defined, will
82100> contain a ` result ` key with the value of the compiled entrypoint. See
83101> [ https://www.openpolicyagent.org/docs/latest/wasm/ ] ( https://www.openpolicyagent.org/docs/latest/wasm/ )
Original file line number Diff line number Diff line change 1+ [{"result":false}]
You can’t perform that action at this time.
0 commit comments