1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ name : Shell Tests CI
17
+
18
+ on :
19
+ push :
20
+ branches :
21
+ - main
22
+ pull_request :
23
+
24
+ jobs :
25
+ test-unix-shell-ubuntu :
26
+ name : Test on Ubuntu
27
+ runs-on : ubuntu-latest
28
+
29
+ steps :
30
+ - name : Checkout code
31
+ uses : actions/checkout@v4
32
+
33
+ # Note: bats-core/bats-action@3.0.0 is not allowed to be used (needs an INFRA issue)
34
+ - name : Install Bats (Testing Framework)
35
+ run : |
36
+ sudo apt-get update
37
+ sudo apt-get install -y bats
38
+
39
+ - name : Set up JDK 17
40
+ uses : actions/setup-java@v4
41
+ with :
42
+ distribution : temurin
43
+ java-version : 17
44
+
45
+ - name : Build with Maven
46
+ run : mvn -V clean install --no-transfer-progress -Pci -DskipTests=true
47
+
48
+ - name : Find and Extract OpenNLP Distribution
49
+ run : |
50
+ # Find the first non-src .tar.gz file in the target directory
51
+ TAR_FILE=$(find opennlp-distr/target -maxdepth 1 -type f -name "*.tar.gz" ! -name "*-src*.tar.gz" | head -n 1)
52
+
53
+ # Ensure we found a file
54
+ if [ -z "$TAR_FILE" ]; then
55
+ echo "Error: No matching tar.gz file found in opennlp-distr/target"
56
+ exit 1
57
+ fi
58
+
59
+ # Extract the tar.gz file
60
+ tar -xzf "$TAR_FILE" -C $HOME
61
+
62
+ # Get the directory name of the extracted content
63
+ EXTRACTED_DIR=$(tar -tf "$TAR_FILE" | head -n 1 | cut -f1 -d"/")
64
+
65
+ # Set OPENNLP_HOME dynamically
66
+ echo "OPENNLP_HOME=$HOME/$EXTRACTED_DIR" >> $GITHUB_ENV
67
+ echo "$HOME/$EXTRACTED_DIR/bin" >> $GITHUB_PATH
68
+
69
+ - name : Verify Extraction
70
+ run : |
71
+ echo "OPENNLP_HOME: $OPENNLP_HOME"
72
+ ls -l $OPENNLP_HOME/bin
73
+
74
+ - name : Run Bats Tests
75
+ run : |
76
+ bats ./opennlp-distr/src/test/sh
77
+ env :
78
+ JAVA_HOME : ${{ env.JAVA_HOME }}
79
+ OPENNLP_HOME : ${{ env.OPENNLP_HOME }}
80
+
81
+ test-unix-shell-macos :
82
+ name : Test on macOS
83
+ runs-on : macos-latest
84
+
85
+ steps :
86
+ - name : Checkout code
87
+ uses : actions/checkout@v4
88
+
89
+ - name : Install Bats (Testing Framework)
90
+ run : |
91
+ brew update
92
+ brew install bats-core
93
+
94
+ - name : Set up JDK 17
95
+ uses : actions/setup-java@v4
96
+ with :
97
+ distribution : temurin
98
+ java-version : 17
99
+
100
+ - name : Build with Maven
101
+ run : mvn -V clean install --no-transfer-progress -Pci -DskipTests=true
102
+
103
+ - name : Find and Extract OpenNLP Distribution
104
+ run : |
105
+ TAR_FILE=$(find opennlp-distr/target -maxdepth 1 -type f -name "*.tar.gz" ! -name "*-src*.tar.gz" | head -n 1)
106
+ if [ -z "$TAR_FILE" ]; then
107
+ echo "Error: No matching tar.gz file found in opennlp-distr/target"
108
+ exit 1
109
+ fi
110
+ tar -xzf "$TAR_FILE" -C $HOME
111
+ EXTRACTED_DIR=$(tar -tf "$TAR_FILE" | head -n 1 | cut -f1 -d"/")
112
+ echo "OPENNLP_HOME=$HOME/$EXTRACTED_DIR" >> $GITHUB_ENV
113
+ echo "$HOME/$EXTRACTED_DIR/bin" >> $GITHUB_PATH
114
+
115
+ - name : Verify Extraction
116
+ run : |
117
+ echo "OPENNLP_HOME: $OPENNLP_HOME"
118
+ ls -l $OPENNLP_HOME/bin
119
+
120
+ - name : Run Bats Tests
121
+ run : |
122
+ bats ./opennlp-distr/src/test/sh
123
+ env :
124
+ JAVA_HOME : ${{ env.JAVA_HOME }}
125
+ OPENNLP_HOME : ${{ env.OPENNLP_HOME }}
126
+
127
+ test-windows-shell :
128
+ name : Test on Windows
129
+ runs-on : windows-latest
130
+
131
+ steps :
132
+ - name : Checkout code
133
+ uses : actions/checkout@v4
134
+
135
+ - name : Install Pester
136
+ run : |
137
+ Install-Module -Name Pester -Force -Scope CurrentUser
138
+ Import-Module Pester
139
+ shell : pwsh
140
+
141
+ - name : Set up JDK 17
142
+ uses : actions/setup-java@v4
143
+ with :
144
+ distribution : temurin
145
+ java-version : 17
146
+
147
+ - name : Build with Maven
148
+ run : mvn -V clean install --no-transfer-progress -Pci -DskipTests=true
149
+
150
+ - name : Run Pester Tests # (one step to avoid environment issues on Windows)
151
+ run : |
152
+ # Find the first non-src .tar.gz file in the target directory
153
+ $TAR_FILE = Get-ChildItem -Path opennlp-distr/target -Filter "*.tar.gz" | Where-Object { $_.Name -notlike "*-src*" } | Select-Object -First 1
154
+
155
+ # Ensure we found a file
156
+ if (-not $TAR_FILE) {
157
+ Write-Error "Error: No matching tar.gz file found in opennlp-distr/target"
158
+ exit 1
159
+ }
160
+
161
+ # Extract the tar.gz file to the current directory
162
+ $Destination = "$(pwd)"
163
+ tar -xzf $TAR_FILE.FullName -C $Destination
164
+
165
+ # Get the directory name of the extracted content (excluding the tar path)
166
+ $EXTRACTED_DIR = (tar -tf $TAR_FILE.FullName | Select-Object -First 1).Split('/')[0]
167
+
168
+ # Set OPENNLP_HOME dynamically in the environment
169
+ $OPENNLP_HOME_PATH = "$Destination\$EXTRACTED_DIR"
170
+ Write-Host "OPENNLP_HOME=$OPENNLP_HOME_PATH" # Debugging
171
+
172
+ # Ensure OPENNLP_HOME is recognized in the current session
173
+ $env:OPENNLP_HOME = $OPENNLP_HOME_PATH
174
+ $env:PATH = "$env:OPENNLP_HOME\bin;$env:PATH"
175
+
176
+ Invoke-Pester -Script "./opennlp-distr/src/test/ps/test_opennlp.Tests.ps1" -Output Detailed
177
+ shell : pwsh
178
+ env :
179
+ JAVA_HOME : ${{ env.JAVA_HOME }}
0 commit comments