Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,186 @@ jobs:
run: mvn -V clean test install --show-version --batch-mode --no-transfer-progress -Pjacoco -Pci
- name: Jacoco
run: mvn jacoco:report
# The binary distribution is pure-Java and platform-independent, so we build it
# once here (Linux/JDK 17) and reuse it for the shell tests below instead of
# rebuilding it on every OS.
- name: Upload OpenNLP distribution
if: matrix.os == 'ubuntu-latest' && matrix.java == 17
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: opennlp-distribution
path: |
opennlp-distr/target/*.tar.gz
!opennlp-distr/target/*-src*.tar.gz
if-no-files-found: error
retention-days: 1

# Shell tests run against the binary distribution produced by the "build" job
# above, so they no longer rebuild OpenNLP themselves.
test-unix-shell-ubuntu:
name: Shell Tests on Ubuntu
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

# Note: bats-core/bats-action@3.0.0 is not allowed to be used (needs an INFRA issue)
- name: Install Bats (Testing Framework)
run: |
sudo apt-get update
sudo apt-get install -y bats

- name: Set up JDK 17
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: temurin
java-version: 17

- name: Download OpenNLP distribution
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: opennlp-distribution
path: dist

- name: Find and Extract OpenNLP Distribution
run: |
# Find the first non-src .tar.gz file in the downloaded artifact
TAR_FILE=$(find dist -maxdepth 1 -type f -name "*.tar.gz" ! -name "*-src*.tar.gz" | head -n 1)

# Ensure we found a file
if [ -z "$TAR_FILE" ]; then
echo "Error: No matching tar.gz file found in dist"
exit 1
fi

# Extract the tar.gz file
tar -xzf "$TAR_FILE" -C $HOME

# Get the directory name of the extracted content
EXTRACTED_DIR=$(tar -tf "$TAR_FILE" | head -n 1 | cut -f1 -d"/")

# Set OPENNLP_HOME dynamically
echo "OPENNLP_HOME=$HOME/$EXTRACTED_DIR" >> $GITHUB_ENV
echo "$HOME/$EXTRACTED_DIR/bin" >> $GITHUB_PATH

- name: Verify Extraction
run: |
echo "OPENNLP_HOME: $OPENNLP_HOME"
ls -l $OPENNLP_HOME/bin

- name: Run Bats Tests
run: |
bats ./opennlp-distr/src/test/sh
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
OPENNLP_HOME: ${{ env.OPENNLP_HOME }}

test-unix-shell-macos:
name: Shell Tests on macOS
needs: build
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install Bats (Testing Framework)
run: |
brew update
brew install bats-core

- name: Set up JDK 17
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: temurin
java-version: 17

- name: Download OpenNLP distribution
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: opennlp-distribution
path: dist

- name: Find and Extract OpenNLP Distribution
run: |
TAR_FILE=$(find dist -maxdepth 1 -type f -name "*.tar.gz" ! -name "*-src*.tar.gz" | head -n 1)
if [ -z "$TAR_FILE" ]; then
echo "Error: No matching tar.gz file found in dist"
exit 1
fi
tar -xzf "$TAR_FILE" -C $HOME
EXTRACTED_DIR=$(tar -tf "$TAR_FILE" | head -n 1 | cut -f1 -d"/")
echo "OPENNLP_HOME=$HOME/$EXTRACTED_DIR" >> $GITHUB_ENV
echo "$HOME/$EXTRACTED_DIR/bin" >> $GITHUB_PATH

- name: Verify Extraction
run: |
echo "OPENNLP_HOME: $OPENNLP_HOME"
ls -l $OPENNLP_HOME/bin

- name: Run Bats Tests
run: |
bats ./opennlp-distr/src/test/sh
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
OPENNLP_HOME: ${{ env.OPENNLP_HOME }}

test-windows-shell:
name: Shell Tests on Windows
needs: build
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install Pester
run: |
Install-Module -Name Pester -Force -Scope CurrentUser
Import-Module Pester
shell: pwsh

- name: Set up JDK 17
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: temurin
java-version: 17

- name: Download OpenNLP distribution
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: opennlp-distribution
path: dist

- name: Run Pester Tests # (one step to avoid environment issues on Windows)
run: |
# Find the first non-src .tar.gz file in the downloaded artifact
$TAR_FILE = Get-ChildItem -Path dist -Filter "*.tar.gz" | Where-Object { $_.Name -notlike "*-src*" } | Select-Object -First 1

# Ensure we found a file
if (-not $TAR_FILE) {
Write-Error "Error: No matching tar.gz file found in dist"
exit 1
}

# Extract the tar.gz file to the current directory
$Destination = "$(pwd)"
tar -xzf $TAR_FILE.FullName -C $Destination

# Get the directory name of the extracted content (excluding the tar path)
$EXTRACTED_DIR = (tar -tf $TAR_FILE.FullName | Select-Object -First 1).Split('/')[0]

# Set OPENNLP_HOME dynamically in the environment
$OPENNLP_HOME_PATH = "$Destination\$EXTRACTED_DIR"
Write-Host "OPENNLP_HOME=$OPENNLP_HOME_PATH" # Debugging

# Ensure OPENNLP_HOME is recognized in the current session
$env:OPENNLP_HOME = $OPENNLP_HOME_PATH
$env:PATH = "$env:OPENNLP_HOME\bin;$env:PATH"

Invoke-Pester -Script "./opennlp-distr/src/test/ps/test_opennlp.Tests.ps1" -Output Detailed
shell: pwsh
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
179 changes: 0 additions & 179 deletions .github/workflows/shell-tests.yml

This file was deleted.

Loading