This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Shell Script with Bats | |
on: | |
push: | |
# branches: | |
# - main | |
pull_request: | |
jobs: | |
test-unix-shell: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Bats and bats libs | |
id: setup-bats | |
uses: bats-core/[email protected] | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
- name: Build with Maven | |
run: mvn -V clean install --no-transfer-progress -Pci -DskipTests=true | |
- name: Find and Extract OpenNLP Distribution | |
run: | | |
# Find the first non-src .tar.gz file in the target directory | |
TAR_FILE=$(find opennlp-distr/target -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 opennlp-distr/target" | |
exit 1 | |
fi | |
# Extract the tar.gz file | |
tar -xzvf "$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 | |
shell: bash | |
env: | |
JAVA_HOME: ${{ env.JAVA_HOME }} | |
OPENNLP_HOME: ${{ env.OPENNLP_HOME }} | |
BATS_LIB_PATH: ${{ steps.setup-bats.outputs.lib-path }} | |
TERM: xterm |