Skip to content

Commit 6910135

Browse files
brokkoli71Bisaloo
andauthored
Add cli wrapper (#45)
* add cli wrapper * Add pull request trigger to conformance workflow * fix pom dependencies * print array * use fork for debugging * add zstd to v2 * update zarr-cli version to 0.0.10 in conformance tests * update zarr-cli path in conformance tests * set dynamic JAR path for conformance tests * Improve JAR path handling in conformance workflow - Use GITHUB_ENV instead of GITHUB_OUTPUT for better compatibility - Add verification step to ensure JAR exists before running tests - Add human-readable confirmation message * set conformance tests back to Bisaloo/zarr-conformance-tests@main * Revert "set conformance tests back to Bisaloo/zarr-conformance-tests@main" This reverts commit 592731e. * remove debug statements * Update conformance test action to not use fork * fix version v0.0.2 of Bisaloo/zarr-conformance-tests Co-authored-by: Hugo Gruson <hugo.gruson@protonmail.com> * fix imports --------- Co-authored-by: Hugo Gruson <hugo.gruson@protonmail.com>
1 parent bd25743 commit 6910135

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

.github/workflows/conformance.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Zarr Conformance Tests
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '17 3 * * 0'
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
jobs:
11+
conformance-tests:
12+
runs-on: ubuntu-latest
13+
env:
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- name: Set up JDK
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '11'
22+
distribution: 'temurin'
23+
cache: maven
24+
25+
- name: Build
26+
run: mvn package -DskipTests
27+
28+
- name: Prepare JAR for testing
29+
run: |
30+
# Find the JAR
31+
JAR_PATH=$(ls target/zarr-java-*.jar | grep -v original | grep -v javadoc | grep -v sources | head -1)
32+
FULL_JAR_PATH="${GITHUB_WORKSPACE}/${JAR_PATH}"
33+
echo "JAR_PATH=${FULL_JAR_PATH}" >> $GITHUB_ENV
34+
echo "Found JAR at: ${FULL_JAR_PATH}"
35+
36+
- name: Run Conformance Tests
37+
uses: Bisaloo/zarr-conformance-tests@v0.0.2
38+
with:
39+
zarr-cli: "java -jar ${{ env.JAR_PATH }}"

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@
132132
<artifactId>commons-compress</artifactId>
133133
<version>1.28.0</version>
134134
</dependency>
135+
136+
<dependency>
137+
<groupId>info.picocli</groupId>
138+
<artifactId>picocli</artifactId>
139+
<version>4.7.6</version>
140+
</dependency>
135141
</dependencies>
136142

137143
<repositories>
@@ -246,6 +252,26 @@
246252
<tokenAuth>true</tokenAuth>
247253
</configuration>
248254
</plugin>
255+
<plugin>
256+
<groupId>org.apache.maven.plugins</groupId>
257+
<artifactId>maven-shade-plugin</artifactId>
258+
<version>3.5.0</version>
259+
<executions>
260+
<execution>
261+
<phase>package</phase>
262+
<goals>
263+
<goal>shade</goal>
264+
</goals>
265+
<configuration>
266+
<transformers>
267+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
268+
<mainClass>dev.zarr.zarrjava.cli.Main</mainClass>
269+
</transformer>
270+
</transformers>
271+
</configuration>
272+
</execution>
273+
</executions>
274+
</plugin>
249275
</plugins>
250276
</build>
251277
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 array = Array.open(path);
25+
26+
// Read the entire array
27+
ucar.ma2.Array data = array.read();
28+
29+
// Print the array values using ucar.ma2.Array's string representation.
30+
System.out.println(data.toString());
31+
32+
return 0;
33+
} catch (Exception e) {
34+
System.err.println("Failed to open array at " + arrayPath);
35+
e.printStackTrace();
36+
return 1;
37+
}
38+
}
39+
40+
public static void main(String[] args) {
41+
int exitCode = new CommandLine(new Main()).execute(args);
42+
System.exit(exitCode);
43+
}
44+
}

0 commit comments

Comments
 (0)