Skip to content

Commit 88b8e76

Browse files
hs-apotellparrt
authored andcommitted
Issue #3783: CI Check Builds
Adding workflow for Github hosted CI check builds. Supports all three supported platforms with all runtime languages except swift. Also, includes cpp native builds across all supported platforms i.e. independent on the test run builds. Every congiguration build generates an artifact (archive of the entire repository) and is uploaded as a result of the build (regardless of success or failure). Signed-off-by: HS <[email protected]>
1 parent f6c29b6 commit 88b8e76

File tree

1 file changed

+290
-0
lines changed

1 file changed

+290
-0
lines changed

.github/workflows/hosted.yml

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
name: antlr4
2+
3+
on:
4+
push:
5+
branches: [ master, dev, hostedci ]
6+
pull_request:
7+
branches: [ master, dev ]
8+
9+
jobs:
10+
cpp-builds:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [
17+
macos-latest,
18+
ubuntu-latest,
19+
windows-latest
20+
]
21+
compiler: [ clang, gcc ]
22+
exclude:
23+
- os: windows-latest
24+
compiler: gcc
25+
include:
26+
- os: windows-latest
27+
compiler: cl
28+
29+
steps:
30+
- name: Install dependencies (Ubuntu)
31+
if: startswith(matrix.os, 'ubuntu')
32+
run: |
33+
sudo apt-get update -qq
34+
sudo apt install -y ninja-build
35+
36+
- name: Install dependencies (MacOS)
37+
if: startswith(matrix.os, 'macos')
38+
run: brew install ninja
39+
40+
- name: Setup Clang
41+
if: (matrix.compiler == 'clang') && !startswith(matrix.os, 'macos')
42+
uses: egor-tensin/setup-clang@v1
43+
with:
44+
version: 13
45+
platform: x64
46+
cygwin: 0
47+
48+
- name: Check out code
49+
uses: actions/checkout@v2
50+
51+
- name: Use ccache
52+
if: startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')
53+
uses: hendrikmuhs/ccache-action@v1
54+
with:
55+
key: ${{ matrix.os }}-${{ matrix.compiler }}
56+
57+
- name: Configure shell (Ubuntu)
58+
if: startswith(matrix.os, 'ubuntu')
59+
run: echo 'PATH=/usr/lib/ccache:'"$PATH" >> $GITHUB_ENV
60+
61+
- name: Configure shell (MacOS)
62+
if: startswith(matrix.os, 'macos')
63+
run: echo "PATH=$(brew --prefix)/opt/ccache/libexec:$PATH" >> $GITHUB_ENV
64+
65+
- name: Build (Windows)
66+
if: startswith(matrix.os, 'windows')
67+
shell: cmd
68+
run: |
69+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
70+
71+
if "${{ matrix.compiler }}" EQU "cl" (
72+
echo 'CC=cl' >> $GITHUB_ENV
73+
echo 'CXX=cl' >> $GITHUB_ENV
74+
) else (
75+
echo 'CC=clang' >> $GITHUB_ENV
76+
echo 'CXX=clang++' >> $GITHUB_ENV
77+
)
78+
79+
set
80+
where cmake && cmake --version
81+
where ninja && ninja --version
82+
where %CC% && %CC% -version
83+
where %CXX% && %CXX% -version
84+
85+
cd runtime/Cpp
86+
87+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Debug
88+
if %errorlevel% neq 0 exit /b %errorlevel%
89+
90+
cmake --build out/Debug -j %NUMBER_OF_PROCESSORS%
91+
if %errorlevel% neq 0 exit /b %errorlevel%
92+
93+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release
94+
if %errorlevel% neq 0 exit /b %errorlevel%
95+
96+
cmake --build out/Release -j %NUMBER_OF_PROCESSORS%
97+
if %errorlevel% neq 0 exit /b %errorlevel%
98+
99+
- name: Build (non-Windows)
100+
if: startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')
101+
run: |
102+
if [ "${{matrix.compiler}}" == "clang" ]; then
103+
export CC=clang
104+
export CXX=clang++
105+
echo 'CC=clang' >> $GITHUB_ENV
106+
echo 'CXX=clang++' >> $GITHUB_ENV
107+
else
108+
export CC=gcc-9
109+
export CXX=g++-9
110+
echo 'CC=gcc-9' >> $GITHUB_ENV
111+
echo 'CXX=g++-9' >> $GITHUB_ENV
112+
fi
113+
114+
env
115+
which cmake && cmake --version
116+
which ninja && ninja --version
117+
which $CC && $CC --version
118+
which $CXX && $CXX --version
119+
120+
cd runtime/Cpp
121+
122+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Debug
123+
cmake --build out/Debug --parallel
124+
125+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANTLR_BUILD_CPP_TESTS=OFF -S . -B out/Release
126+
cmake --build out/Release --parallel
127+
128+
- name: Prepare artifacts
129+
if: always()
130+
run: |
131+
cd ${{ github.workspace }}/..
132+
tar czfp antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz antlr4
133+
mv antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz ${{ github.workspace }}/.
134+
135+
- name: Archive artifacts
136+
if: always()
137+
uses: actions/upload-artifact@v2
138+
with:
139+
name: antlr_${{ matrix.os }}_${{ matrix.compiler }}
140+
path: antlr_${{ matrix.os }}_${{ matrix.compiler }}.tgz
141+
142+
143+
build:
144+
runs-on: ${{ matrix.os }}
145+
146+
strategy:
147+
fail-fast: false
148+
matrix:
149+
os: [
150+
macos-latest,
151+
ubuntu-latest,
152+
windows-latest
153+
]
154+
target: [
155+
cpp,
156+
csharp,
157+
dart,
158+
go,
159+
java,
160+
javascript,
161+
python2,
162+
python3,
163+
php,
164+
]
165+
166+
steps:
167+
- name: Install dependencies (Ubuntu)
168+
if: startswith(matrix.os, 'ubuntu')
169+
run: |
170+
sudo apt-get update -qq
171+
sudo apt install -y ninja-build
172+
173+
- name: Install dependencies (MacOS)
174+
if: startswith(matrix.os, 'macos')
175+
run: brew install ninja
176+
177+
- name: Set up JDK 11
178+
uses: actions/setup-java@v3
179+
with:
180+
distribution: 'zulu'
181+
java-version: 11
182+
183+
- name: Set up Maven
184+
uses: stCarolas/[email protected]
185+
with:
186+
maven-version: 3.5.4
187+
188+
- name: Add msbuild to PATH
189+
if: startswith(matrix.os, 'windows') && (matrix.target == 'cpp')
190+
uses: microsoft/[email protected]
191+
192+
- name: Set up Python 2
193+
if: matrix.target == 'python2'
194+
uses: actions/setup-python@v4
195+
with:
196+
python-version: '2.x'
197+
architecture: 'x64'
198+
199+
- name: Set up Python 3
200+
if: matrix.target == 'python3'
201+
uses: actions/setup-python@v4
202+
with:
203+
python-version: '3.x'
204+
architecture: 'x64'
205+
206+
- name: Set up Node 14
207+
if: matrix.target == 'javascript'
208+
uses: actions/setup-node@v3
209+
with:
210+
node-version: '14'
211+
212+
- name: Setup Dotnet
213+
if: matrix.target == 'csharp'
214+
uses: actions/setup-dotnet@v2
215+
with:
216+
dotnet-version: '6.0.x'
217+
218+
- name: Setup Dart 2.12.1
219+
if: matrix.target == 'dart'
220+
uses: dart-lang/[email protected]
221+
with:
222+
sdk: 2.12.1
223+
224+
- name: Setup Go 1.13.1
225+
if: matrix.target == 'go'
226+
uses: actions/setup-go@v3
227+
with:
228+
go-version: '^1.13.1'
229+
230+
- name: Setup PHP 8.2
231+
if: matrix.target == 'php'
232+
uses: shivammathur/setup-php@v2
233+
with:
234+
php-version: '8.2'
235+
extensions: mbstring
236+
tools: composer
237+
238+
- name: Check out code
239+
uses: actions/checkout@v2
240+
241+
- name: Checkout antlr PHP runtime
242+
uses: actions/checkout@v2
243+
with:
244+
repository: antlr/antlr-php-runtime
245+
path: runtime/PHP
246+
247+
- name: Build tool with Maven
248+
run: mvn install -DskipTests=true -Darguments="-Dmaven.javadoc.skip=true" -B -V
249+
250+
- name: Test with Maven (Windows)
251+
if: startsWith(matrix.os, 'windows')
252+
run: |
253+
gci env:* | sort-object name
254+
255+
cd runtime-testsuite
256+
switch ("${{ matrix.target }}")
257+
{
258+
python2 { mvn -X '-Dantlr-python2-exec="${{ env.pythonLocation }}\python.exe"' '-Dtest=python2.**' test }
259+
python3 { mvn -X '-Dantlr-python3-exec="${{ env.pythonLocation }}\python.exe"' '-Dtest=python3.**' test }
260+
default { mvn -X '-Dtest=${{ matrix.target }}.**' test }
261+
}
262+
263+
env:
264+
CMAKE_GENERATOR: Ninja
265+
266+
- name: Test with Maven (non-Windows)
267+
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
268+
run: |
269+
env
270+
271+
cd runtime-testsuite
272+
case ${{ matrix.target }} in
273+
python2) mvn -X '-Dantlr-python2-exec=${{ env.pythonLocation }}/bin/python' '-Dtest=python2.**' test ;;
274+
python3) mvn -X '-Dantlr-python3-exec=${{ env.pythonLocation }}/bin/python' '-Dtest=python3.**' test ;;
275+
*) mvn -X '-Dtest=${{ matrix.target }}.**' test ;;
276+
esac
277+
278+
- name: Prepare artifacts
279+
if: always()
280+
run: |
281+
cd ${{ github.workspace }}/..
282+
tar czfp antlr_${{ matrix.os }}_${{ matrix.target }}.tgz antlr4
283+
mv antlr_${{ matrix.os }}_${{ matrix.target }}.tgz ${{ github.workspace }}/.
284+
285+
- name: Archive artifacts
286+
if: always()
287+
uses: actions/upload-artifact@v2
288+
with:
289+
name: antlr_${{ matrix.os }}_${{ matrix.target }}
290+
path: antlr_${{ matrix.os }}_${{ matrix.target }}.tgz

0 commit comments

Comments
 (0)