-
Notifications
You must be signed in to change notification settings - Fork 506
249 lines (212 loc) · 8.66 KB
/
Copy pathmaven.yml
File metadata and controls
249 lines (212 loc) · 8.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Java CI
on:
# Run CI on Pushes to "main"" or on pull requests targeting "main".
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
# A new commit on a pull request makes the run in flight obsolete, so cancel it
# instead of paying for a result nobody will read. Pushes to a branch group by ref
# and are never cancelled, so every commit on main keeps a full build.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: [ 21, 25 ]
experimental: [false]
# include:
# - java: 26-ea
# os: ubuntu-latest
# experimental: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Build with Maven
run: mvn -V clean test verify --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 21) 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 == 21
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# 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 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: temurin
java-version: 21
- name: Download OpenNLP distribution
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Bats (Testing Framework)
run: |
brew update
brew install bats-core
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: temurin
java-version: 21
- name: Download OpenNLP distribution
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Pester
run: |
Install-Module -Name Pester -RequiredVersion 6.0.0 -Force -Scope CurrentUser
Import-Module Pester
shell: pwsh
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: temurin
java-version: 21
- name: Download OpenNLP distribution
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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 -Path "./opennlp-distr/src/test/ps/test_opennlp.Tests.ps1" -Output Detailed
shell: pwsh
env:
JAVA_HOME: ${{ env.JAVA_HOME }}