-
Notifications
You must be signed in to change notification settings - Fork 3.3k
342 lines (285 loc) · 9.75 KB
/
hosted.yml
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: antlr4
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ master, dev, hostedci ]
pull_request:
branches: [ master, dev ]
permissions:
contents: read
jobs:
cpp-lib-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
macos-12,
ubuntu-20.04,
windows-2022
]
compiler: [ clang, gcc ]
unity_build: [ ON, OFF ]
exclude:
- os: windows-2022
compiler: gcc
include:
- os: windows-2022
compiler: cl
steps:
- name: Install dependencies (Ubuntu)
if: startswith(matrix.os, 'ubuntu')
run: |
sudo apt-get update -qq
sudo apt install -y ninja-build
- name: Install dependencies (MacOS)
if: startswith(matrix.os, 'macos')
run: brew install ninja
- name: Setup Clang
if: (matrix.compiler == 'clang') && !startswith(matrix.os, 'macos')
uses: egor-tensin/setup-clang@v1
with:
version: 13
platform: x64
cygwin: 0
- name: Check out code
uses: actions/checkout@v3
- name: Use ccache
if: startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-${{ matrix.compiler }}
- name: Configure shell (Ubuntu)
if: startswith(matrix.os, 'ubuntu')
run: echo 'PATH=/usr/lib/ccache:'"$PATH" >> $GITHUB_ENV
- name: Configure shell (MacOS)
if: startswith(matrix.os, 'macos')
run: echo "PATH=$(brew --prefix)/opt/ccache/libexec:$PATH" >> $GITHUB_ENV
- name: Build (Windows)
if: startswith(matrix.os, 'windows')
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
if "${{ matrix.compiler }}" EQU "cl" (
set CC=cl
set CXX=cl
echo 'CC=cl' >> $GITHUB_ENV
echo 'CXX=cl' >> $GITHUB_ENV
) else (
set CC=clang
set CXX=clang++
echo 'CC=clang' >> $GITHUB_ENV
echo 'CXX=clang++' >> $GITHUB_ENV
)
set
where cmake && cmake --version
where ninja && ninja --version
where %CC% && %CC% -version
where %CXX% && %CXX% -version
cd runtime/Cpp
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -DCMAKE_UNITY_BUILD_BATCH_SIZE=20 -S . -B out/Debug
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build out/Debug -j %NUMBER_OF_PROCESSORS%
if %errorlevel% neq 0 exit /b %errorlevel%
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build out/Release -j %NUMBER_OF_PROCESSORS%
if %errorlevel% neq 0 exit /b %errorlevel%
- name: Build (non-Windows)
if: startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')
run: |
if [ "${{matrix.compiler}}" == "clang" ]; then
export CC=clang
export CXX=clang++
echo 'CC=clang' >> $GITHUB_ENV
echo 'CXX=clang++' >> $GITHUB_ENV
else
export CC=gcc
export CXX=g++
echo 'CC=gcc' >> $GITHUB_ENV
echo 'CXX=g++' >> $GITHUB_ENV
fi
env
which cmake && cmake --version
which ninja && ninja --version
which $CC && $CC --version
which $CXX && $CXX --version
cd runtime/Cpp
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -DCMAKE_UNITY_BUILD_BATCH_SIZE=20 -S . -B out/Debug
cmake --build out/Debug --parallel
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release
cmake --build out/Release --parallel
- name: Prepare artifacts
if: always()
run: |
cd ${{ github.workspace }}/..
tar czfp antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz --exclude='.git' antlr4
mv antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz ${{ github.workspace }}/.
- name: Archive artifacts
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: antlr_${{ matrix.os }}_${{ matrix.compiler }}
path: antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
macos-12,
ubuntu-20.04,
windows-2022
]
target: [
tool,
cpp,
csharp,
dart,
go,
java,
javascript,
typescript,
php,
python3,
# swift,
]
exclude:
- os: windows-2022
target: swift
steps:
# Check out the code before setting the environment since some
# of the actions actually parse the files to figure out the
# dependencies, for instance, the setup-java actually parses
# **/pom.xml files to decide what to cache.
- name: Check out code
uses: actions/checkout@v3
- name: Checkout antlr PHP runtime
if: matrix.target == 'php'
uses: actions/checkout@v3
with:
repository: antlr/antlr-php-runtime
path: runtime/PHP
- name: Setup PHP 8.2
if: matrix.target == 'php'
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring
tools: composer
- name: Install dependencies
env:
COMPOSER_CACHE_DIR: ${{ github.workspace }}/.cache
if: matrix.target == 'php'
run: |-
cd runtime/PHP
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
- name: Install dependencies (Ubuntu)
if: startswith(matrix.os, 'ubuntu')
run: |
sudo apt-get update -qq
sudo apt install -y ninja-build
- name: Install dependencies (MacOS)
if: startswith(matrix.os, 'macos')
run: brew install ninja
- name: Set up JDK 11
id: setup-java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
cache: 'maven'
- name: Set up Maven
if: steps.setup-java.outputs.cache-hit != 'true'
uses: stCarolas/[email protected]
with:
maven-version: 3.8.5
- name: Add msbuild to PATH
if: startswith(matrix.os, 'windows') && (matrix.target == 'cpp')
uses: microsoft/[email protected]
- name: Set up Python 3
if: matrix.target == 'python3'
uses: actions/setup-python@v4
with:
python-version: '3.x'
architecture: 'x64'
- name: Set up Node 16
if: (matrix.target == 'javascript') || (matrix.target == 'typescript')
uses: actions/[email protected]
with:
node-version: '16'
- name: Setup Dotnet
if: matrix.target == 'csharp'
uses: actions/[email protected]
with:
dotnet-version: '7.0.x'
- name: Setup Dart 2.12.1
if: matrix.target == 'dart'
uses: dart-lang/[email protected]
with:
sdk: 2.12.1
- name: Setup Go 1.19
if: matrix.target == 'go'
uses: actions/[email protected]
with:
go-version: '^1.19'
- name: Setup Swift
if: matrix.target == 'swift'
uses: swift-actions/[email protected]
with:
swift-version: '5.2'
- name: Use ccache
if: (startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')) && (matrix.target == 'cpp')
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-${{ matrix.target }}
- name: Configure shell (Ubuntu)
if: startswith(matrix.os, 'ubuntu') && (matrix.target == 'cpp')
run: echo 'PATH=/usr/lib/ccache:'"$PATH" >> $GITHUB_ENV
- name: Configure shell (MacOS)
if: startswith(matrix.os, 'macos') && (matrix.target == 'cpp')
run: echo "PATH=$(brew --prefix)/opt/ccache/libexec:$PATH" >> $GITHUB_ENV
- name: Build ANTLR with Maven
run: mvn install -DskipTests=true -Darguments="-Dmaven.javadoc.skip=true" -B -V
- name: Test tool
if: matrix.target == 'tool'
run: |
cd tool-testsuite
mvn test
- name: Test runtime (Windows)
if: startsWith(matrix.os, 'windows') && (matrix.target != 'tool')
run: |
gci env:* | sort-object name
cd runtime-testsuite
switch ("${{ matrix.target }}")
{
python3 { mvn -X '-Dantlr-python3-exec="${{ env.pythonLocation }}\python.exe"' '-Dtest=python3.**' test }
default { mvn -X '-Dtest=${{ matrix.target }}.**' test }
}
env:
CMAKE_GENERATOR: Ninja
- name: Test runtime (non-Windows)
if: (startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')) && (matrix.target != 'tool')
run: |
env
cd runtime-testsuite
case ${{ matrix.target }} in
python3) mvn -X '-Dantlr-python3-exec=${{ env.pythonLocation }}/bin/python' '-Dtest=python3.**' test ;;
*) mvn -X '-Dtest=${{ matrix.target }}.**' test ;;
esac
- name: Prepare artifacts
if: always()
run: |
cd ${{ github.workspace }}/..
tar czfp antlr_${{ matrix.os }}_${{ matrix.target }}.tgz --exclude='.git' antlr4
mv antlr_${{ matrix.os }}_${{ matrix.target }}.tgz ${{ github.workspace }}/.
- name: Archive artifacts
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: antlr_${{ matrix.os }}_${{ matrix.target }}
path: antlr_${{ matrix.os }}_${{ matrix.target }}.tgz