Skip to content

Commit 9493eb8

Browse files
committed
add cli wrapper
1 parent 93b10bb commit 9493eb8

3 files changed

Lines changed: 92 additions & 0 deletions

File tree

.github/workflows/conformance.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Zarr Conformance Tests
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '17 3 * * 0'
7+
8+
jobs:
9+
conformance-tests:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Set up JDK
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '11'
20+
distribution: 'temurin'
21+
cache: maven
22+
23+
- name: Build
24+
run: mvn package -DskipTests
25+
26+
- name: Run Conformance Tests
27+
uses: Bisaloo/zarr-conformance-tests@v0.0.1
28+
with:
29+
zarr-cli: "java -jar target/zarr-java-0.0.9.jar"

pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@
121121
<version>4.13.1</version>
122122
<scope>test</scope>
123123
</dependency>
124+
<dependency>
125+
<groupId>info.picocli</groupId>
126+
<artifactId>picocli</artifactId>
127+
<version>4.7.6</version>
128+
</dependency>
124129
</dependencies>
125130

126131
<repositories>
@@ -231,6 +236,26 @@
231236
<tokenAuth>true</tokenAuth>
232237
</configuration>
233238
</plugin>
239+
<plugin>
240+
<groupId>org.apache.maven.plugins</groupId>
241+
<artifactId>maven-shade-plugin</artifactId>
242+
<version>3.5.0</version>
243+
<executions>
244+
<execution>
245+
<phase>package</phase>
246+
<goals>
247+
<goal>shade</goal>
248+
</goals>
249+
<configuration>
250+
<transformers>
251+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
252+
<mainClass>dev.zarr.zarrjava.cli.Main</mainClass>
253+
</transformer>
254+
</transformers>
255+
</configuration>
256+
</execution>
257+
</executions>
258+
</plugin>
234259
</plugins>
235260
</build>
236261
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package dev.zarr.zarrjava.cli;
2+
3+
import dev.zarr.zarrjava.core.Array;
4+
import picocli.CommandLine;
5+
import picocli.CommandLine.Command;
6+
import picocli.CommandLine.Option;
7+
8+
import java.nio.file.Path;
9+
import java.nio.file.Paths;
10+
import java.util.concurrent.Callable;
11+
12+
@Command(name = "zarr-java-cli", mixinStandardHelpOptions = true, version = "1.0", description = "CLI wrapper for zarr-java conformance tests.")
13+
public class Main implements Callable<Integer> {
14+
15+
@Option(names = { "--array_path" }, description = "Path to the Zarr array", required = true)
16+
private String arrayPath;
17+
18+
@Override
19+
public Integer call() throws Exception {
20+
try {
21+
Path path = Paths.get(arrayPath);
22+
// Attempt to open the array. This should throw if the array is invalid or
23+
// cannot be opened.
24+
Array.open(path);
25+
// If we get here, it means we successfully opened the array.
26+
return 0;
27+
} catch (Exception e) {
28+
System.err.println("Failed to open array at " + arrayPath);
29+
e.printStackTrace();
30+
return 1;
31+
}
32+
}
33+
34+
public static void main(String[] args) {
35+
int exitCode = new CommandLine(new Main()).execute(args);
36+
System.exit(exitCode);
37+
}
38+
}

0 commit comments

Comments
 (0)