You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by rz...@apache.org on 2026/10/08 12:30:09 UTC
(opennlp) branch main updated: GH-1393: Cache the downloaded test models between CI runs (#1444)
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opennlp.git
The following commit(s) were added to refs/heads/main by this push:
new e039a7fb7 GH-1393: Cache the downloaded test models between CI runs (#1444)
e039a7fb7 is described below
commit e039a7fb7dc76ca6fd67c33cc1303e59816f0243
Author: Richard Zowalla <13...@users.noreply.github.com>
AuthorDate: Thu Oct 8 14:30:02 2026 +0200
GH-1393: Cache the downloaded test models between CI runs (#1444)
* GH-1393: Cache the downloaded test models between CI runs
* GH-1393: Create missing parent directories of the test model download home
The test download helpers used File#mkdir, which fails silently when the
configured download home itself does not exist yet, e.g. a fresh
~/.opennlp-ci on a CI cache miss. Use Files#createDirectories instead.
---------
Co-authored-by: Kristian Rickert <kr...@apache.org>
---
.github/workflows/maven.yml | 8 +++++++-
.../src/test/java/opennlp/tools/AbstractModelLoaderTest.java | 4 +---
.../src/test/java/opennlp/tools/AbstractModelLoaderTest.java | 4 +---
.../opennlp-uima/src/test/java/opennlp/uima/AbstractIT.java | 4 +---
.../test/java/opennlp/tools/namefind/AbstractNameFinderTest.java | 4 +---
5 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 2661a63f2..30376ae6f 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -73,13 +73,19 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
+ # Test models are downloaded once and reused, so the build does not depend on the
+ # model host on every run. Change the key when the tests move to other models.
+ - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ~/.opennlp-ci
+ key: ${{ runner.os }}-opennlp-models-ud-1.3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Build with Maven
- run: mvn -V clean verify --show-version --batch-mode --no-transfer-progress -Pjacoco -Pci
+ run: mvn -V clean verify --show-version --batch-mode --no-transfer-progress -Pjacoco -Pci "-Dopennlp.download.home=$HOME/.opennlp-ci"
- name: Jacoco
run: mvn jacoco:report
# The binary distribution is pure-Java and platform-independent, so we build it
diff --git a/opennlp-core/opennlp-cli/src/test/java/opennlp/tools/AbstractModelLoaderTest.java b/opennlp-core/opennlp-cli/src/test/java/opennlp/tools/AbstractModelLoaderTest.java
index 8da157432..242aba9b9 100644
--- a/opennlp-core/opennlp-cli/src/test/java/opennlp/tools/AbstractModelLoaderTest.java
+++ b/opennlp-core/opennlp-cli/src/test/java/opennlp/tools/AbstractModelLoaderTest.java
@@ -65,9 +65,7 @@ public abstract class AbstractModelLoaderTest {
}
private static void downloadModel(URL url) throws IOException {
- if (!Files.isDirectory(OPENNLP_DIR)) {
- OPENNLP_DIR.toFile().mkdir();
- }
+ Files.createDirectories(OPENNLP_DIR);
final String filename = url.toString().substring(url.toString().lastIndexOf("/") + 1);
final Path localFile = Paths.get(OPENNLP_DIR.toString(), filename);
diff --git a/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/AbstractModelLoaderTest.java b/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/AbstractModelLoaderTest.java
index 8da157432..242aba9b9 100644
--- a/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/AbstractModelLoaderTest.java
+++ b/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/AbstractModelLoaderTest.java
@@ -65,9 +65,7 @@ public abstract class AbstractModelLoaderTest {
}
private static void downloadModel(URL url) throws IOException {
- if (!Files.isDirectory(OPENNLP_DIR)) {
- OPENNLP_DIR.toFile().mkdir();
- }
+ Files.createDirectories(OPENNLP_DIR);
final String filename = url.toString().substring(url.toString().lastIndexOf("/") + 1);
final Path localFile = Paths.get(OPENNLP_DIR.toString(), filename);
diff --git a/opennlp-extensions/opennlp-uima/src/test/java/opennlp/uima/AbstractIT.java b/opennlp-extensions/opennlp-uima/src/test/java/opennlp/uima/AbstractIT.java
index 9d5633dd0..af7615e22 100644
--- a/opennlp-extensions/opennlp-uima/src/test/java/opennlp/uima/AbstractIT.java
+++ b/opennlp-extensions/opennlp-uima/src/test/java/opennlp/uima/AbstractIT.java
@@ -85,9 +85,7 @@ abstract class AbstractIT extends AbstractUimaTest {
}
private static void downloadModel(URL url) throws IOException {
- if (!Files.isDirectory(OPENNLP_DIR)) {
- OPENNLP_DIR.toFile().mkdir();
- }
+ Files.createDirectories(OPENNLP_DIR);
final String filename = url.toString().substring(url.toString().lastIndexOf("/") + 1);
final Path localFile = Paths.get(OPENNLP_DIR.toString(), filename);
diff --git a/opennlp-tools/src/test/java/opennlp/tools/namefind/AbstractNameFinderTest.java b/opennlp-tools/src/test/java/opennlp/tools/namefind/AbstractNameFinderTest.java
index 3a0cca4a1..d1a590bd0 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/namefind/AbstractNameFinderTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/namefind/AbstractNameFinderTest.java
@@ -126,9 +126,7 @@ abstract class AbstractNameFinderTest {
}
private static void downloadModel(URL url) throws IOException {
- if (!Files.isDirectory(OPENNLP_DIR)) {
- OPENNLP_DIR.toFile().mkdir();
- }
+ Files.createDirectories(OPENNLP_DIR);
final String filename = url.toString().substring(url.toString().lastIndexOf("/") + 1);
final Path localFile = Paths.get(OPENNLP_DIR.toString(), filename);