-
Notifications
You must be signed in to change notification settings - Fork 1k
484 lines (409 loc) · 15.7 KB
/
build_XSTools.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# workflow syntax https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# runs-on https://github.com/actions/virtual-environments
# actions checkout https://github.com/actions/checkout
# actions setup-python https://github.com/actions/setup-python
# actions setup-perl https://github.com/marketplace/actions/setup-perl-environment
# strawberry Perl 5.12.3.0 https://strawberryperl.com/download/5.12.3.0/strawberry-perl-5.12.3.0-portable.zip
# strawberry Perl 5.32.1.1 https://strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-32bit-portable.zip
# actions upload-artifact https://github.com/actions/upload-artifact
# actions download-artifact https://github.com/actions/download-artifact
# actions cache https://github.com/actions/cache
name: Build XSTools
on:
push:
branches:
- master
tags-ignore:
- '*'
pull_request:
jobs:
#####################
## Windows Actions ##
#####################
build_XSTools_Windows:
name: XSTools ${{ matrix.os }} (python ${{ matrix.python }}, perl ${{ matrix.perl }}) ${{ matrix.architecture }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
python: 2.7.18
architecture: x86
python_distr: 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.msi'
perl: 5.12
strawberry_distr: 'https://strawberryperl.com/download/5.12.3.0/strawberry-perl-5.12.3.0-portable.zip'
- os: windows-2022
python: 3
architecture: x86
perl: 5.32
strawberry_distr: 'https://strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-32bit-portable.zip'
steps:
- name: GIT checkout
uses: actions/checkout@v3
# setup matrix:
# - windows-2019 + python 2.7.18 x86 + strawberry perl 5.12 x86 + strawberry g++ x86
# - windows-2022 + python 3 x86 + strawberry perl 5.32 x86 + strawberry g++ x86
########################
# preparing Windows OS #
########################
- name: (Windows 2022) Setup python ${{ matrix.python }} ${{ matrix.architecture }}
if: matrix.os == 'windows-2022'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.architecture }}
- name: (Windows 2019) Check the Python2 cache
if: matrix.os == 'windows-2019'
id: cache-python2
uses: actions/cache@v3
with:
path: c:\python27
key: ${{ runner.os }}-python-${{ matrix.python }}
- name: (Windows 2019) Replace python to ${{ matrix.python }} ${{ matrix.architecture }}
if: matrix.os == 'windows-2019' && steps.cache-python2.outputs.cache-hit != 'true'
run: |
echo "::warning ::cache '${{ runner.os }}-python-${{ matrix.python }}' was NOT found, download the Python2"
echo "== python version check:"
python -V
if ( Test-Path "C:/hostedtoolcache/windows/Python/" ) {
echo '== Remove default Python 3:'
echo 'rm -r "C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe"'
rm -r "C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe"
}
echo "================================"
echo "== download python ${{ matrix.python }} (${{ matrix.architecture }})"
Invoke-WebRequest ${{ matrix.python_distr }} -OutFile python-2.7.18.msi
echo "== install python-2.7.18.msi"
cmd /c start /wait msiexec.exe /passive /i python-2.7.18.msi /norestart /L*V "python_install.log" ADDLOCAL=ALL ALLUSERS=1 TARGETDIR=c:\python27
echo "== add the path to python27 to the PATH variable"
echo "c:\python27" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Remove default Strawberry perl and g++
run: |
if ( "${{ matrix.os }}" -eq "windows-2022" ) {
echo "== add the path to strawberry to the PATH variable"
echo "C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
}
if ( Test-Path "c:/Strawberry/" ) {
echo "== remove c:/Strawberry/"
echo 'mv c:/Strawberry/ c:/Strawberry_old'
mv c:/Strawberry/ c:/Strawberry_old
}
echo "== remove g++ x64"
echo 'rm c:/ProgramData/Chocolatey/bin/g++.exe'
rm c:/ProgramData/Chocolatey/bin/g++.exe
- name: Check the Strawberry cache
id: cache-strawberry
uses: actions/cache@v3
with:
path: c:\Strawberry
key: ${{ runner.os }}-strawberry-${{ matrix.perl }}
- name: (Windows) Replace perl to Strawberry ${{ matrix.perl }} ${{ matrix.architecture }}
if: steps.cache-strawberry.outputs.cache-hit != 'true'
run: |
echo "::warning ::cache '${{ runner.os }}-strawberry-${{ matrix.perl }}' was NOT found, download the Strawberry perl"
echo "===================================="
echo "== previous version of Perl:"
perl --version
echo "===================================="
echo "== download Strawberry perl ${{ matrix.perl }} ${{ matrix.architecture }}"
Invoke-WebRequest ${{ matrix.strawberry_distr }} -OutFile strawberry.zip
echo "===================================="
echo "== unpack strawberry-perl ${{ matrix.perl }}"
7z.exe x strawberry.zip -o"C:/Strawberry"
###############################
# final check of all versions #
###############################
- name: Environment check
run: |
echo "== python version check (should be '${{ matrix.python }}'):"
python -V
echo "======================"
echo "== perl version check (should be '${{ matrix.perl }}'):"
perl --version
echo "======================"
echo "== Time::HiRes module:"
perl -e "use Time::HiRes;"
echo "========================="
echo "== Compress::Zlib module:"
perl -e "use Compress::Zlib;"
echo "====================="
echo "== g++ version check:"
g++ --version
####################
# building XSTools #
####################
- name: make XSTools.dll and NetRedirect.dll
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
PERL: ${{ matrix.perl }}
ARCHITECTURE: ${{ matrix.architecture }}
run: |
gmake all
echo "================================================================="
echo "DONE:"
dir src\auto\XSTools\ | findstr "dll"
echo "These XSTools.dll and NetRedirect.dll are built using: $env:OS + python $env:PYTHON $env:ARCHITECTURE + strawberry perl $env:PERL $env:ARCHITECTURE + strawberry g++ x86" > src\auto\XSTools\XSTools_notes.txt
####################
# making artifacts #
####################
- name: Making artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_perl-${{ matrix.perl }}${{ matrix.architecture }}
path: |
src\auto\XSTools\XSTools_notes.txt
src\auto\XSTools\XSTools.dll
src\auto\XSTools\NetRedirect.dll
########################
# start the second job #
########################
make_Windows_test:
name: test ${{ matrix.os }} (perl ${{ matrix.perl }}) ${{ matrix.architecture }}
needs: build_XSTools_Windows
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
architecture: x86
perl: 5.12
- os: windows-2022
architecture: x86
perl: 5.32
steps:
- name: GIT checkout
uses: actions/checkout@v3
########################
# preparing Windows OS #
########################
- name: Remove default Strawberry perl, XSTools.dll
if: runner.os == 'Windows'
run: |
$OS = "${{ matrix.os }}"
if ( $OS -eq "windows-2022" ) {
echo "Add the path to strawberry to the PATH variable"
echo "C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
echo "====================="
}
if ( Test-Path "c:/Strawberry/" ) {
echo "== remove c:/Strawberry/"
echo 'mv c:/Strawberry/ c:/Strawberry_old'
mv c:/Strawberry/ c:/Strawberry_old
echo "====================="
}
echo "rm XSTools.dll"
rm XSTools.dll
- name: Check the Strawberry cache
id: cache-strawberry
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: c:\Strawberry
key: ${{ runner.os }}-strawberry-${{ matrix.perl }}
- name: Display an error if the cache is found
if: steps.cache-strawberry.outputs.cache-hit != 'true'
run: |
echo "::error ::cache '${{ runner.os }}-strawberry-${{ matrix.perl }}' was NOT found!!! See the 'Post Check the Strawberry cache' step in the previous job"
exit 1
###############
# final check #
###############
- name: Environment check
run: |
echo "== perl version check:"
perl --version
- name: Restoring XTools from artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.os }}_perl-${{ matrix.perl }}${{ matrix.architecture }}
- name: Checking for XSTools
shell: bash
run: |
echo -e "\e[34m# ls -lh | grep XSTools"
ls -lh | grep XSTools
#############
# make test #
#############
- name: Running tests
run: |
cd src\test
perl unittests.pl
###################
## Linux Actions ##
###################
build_XSTools_Linux:
name: XSTools ${{ matrix.os }} (python ${{ matrix.python }}, perl ${{ matrix.perl }}) ${{ matrix.architecture }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
python: 2.7
architecture: x64
perl: 5.12
- os: ubuntu-22.04
python: 3
architecture: x64
perl: latest
steps:
- name: GIT checkout
uses: actions/checkout@v3
# setup matrix:
# - ubuntu-20.04 + python 2.7.18 x64 + perl 5.12 x64
# - ubuntu-22.04 + python 3 x64 + perl last (5.38) x64
######################
# preparing Linux OS #
######################
- name: (Ubuntu-22.04) Setup python ${{ matrix.python }} ${{ matrix.architecture }}
if: matrix.os == 'ubuntu-22.04'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.architecture }}
- name: (Ubuntu-20.04) Setup python ${{ matrix.python }} ${{ matrix.architecture }}
if: matrix.os == 'ubuntu-20.04'
run: |
echo "== python version check:"
python -V
echo "== rename symbolic link"
sudo rm -f /usr/bin/python
cd /usr/bin/ && sudo ln -rs python2.7 python
# ls -l /usr/bin/ |grep python
echo "== new python version check:"
python -V
- name: Setup perl ${{ matrix.perl }} on linux
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.perl }}
###############################
# final check of all versions #
###############################
- name: Environment check
run: |
echo "== python version check (should be '${{ matrix.python }}'):"
python -V
echo "======================"
echo "== perl version check (should be '${{ matrix.perl }}'):"
perl --version
echo "======================"
echo "== Time::HiRes module:"
perl -e "use Time::HiRes;"
echo "========================="
echo "== Compress::Zlib module:"
perl -e "use Compress::Zlib;"
echo "====================="
echo "== g++ version check:"
g++ --version
####################
# building XSTools #
####################
- name: make XSTools.so
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
PERL: ${{ matrix.perl }}
ARCHITECTURE: ${{ matrix.architecture }}
run: |
sudo apt update
sudo apt install -y libreadline6-dev libcurl4-openssl-dev
make all
echo "======================================================"
echo "DONE:"
ls -lh src/auto/XSTools/ | grep so
echo "These XSTools.so and NetRedirect.so are built using: $OS + python $PYTHON $ARCHITECTURE + strawberry perl $PERL $ARCHITECTURE + strawberry g++ x86" > src/auto/XSTools/XSTools_notes.txt
####################
# making artifacts #
####################
- name: Making artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_perl-${{ matrix.perl }}${{ matrix.architecture }}
path: |
src/auto/XSTools/XSTools_notes.txt
src/auto/XSTools/XSTools.so
########################
# start the second job #
########################
make_Linux_test:
name: test ${{ matrix.os }} (perl ${{ matrix.perl }}) ${{ matrix.architecture }}
needs: build_XSTools_Linux
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
architecture: x64
perl: 5.12
- os: ubuntu-22.04
architecture: x64
perl: latest
steps:
- name: GIT checkout
uses: actions/checkout@v3
######################
# preparing Linux OS #
######################
- name: Setup perl ${{ matrix.perl }}
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.perl }}
###############
# final check #
###############
- name: Environment check
run: |
echo "== perl version check:"
perl --version
- name: Restoring XTools from artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.os }}_perl-${{ matrix.perl }}${{ matrix.architecture }}
- name: Checking for XSTools
shell: bash
run: |
echo -e "\e[34m# ls -lh | grep XSTools"
ls -lh | grep XSTools
#############
# make test #
#############
- name: Running tests
run: |
make test
#######################
# start the third job #
#######################
make_distrib:
name: checking makedist.sh
needs: build_XSTools_Linux
runs-on: ubuntu-latest
steps:
- name: GIT checkout
uses: actions/checkout@v3
- name: run "makedist.sh --help"
shell: bash
run: ./makedist.sh --help || echo -e "\e[34m# done"
- name: run "makedist.sh --bin"
shell: bash
run: |
echo "::group::script debug"
./makedist.sh --bin
echo "::endgroup::"
echo -e "\e[34m# ls -lh | grep zip"
ls -lh | grep zip
- name: run "makedist.sh --semibin test_semibin"
shell: bash
run: |
mkdir test_semibin
echo "::group::script debug"
./makedist.sh --semibin test_semibin
echo "::endgroup::"
echo -e "\e[34m# ls -lh | grep test_semibin"
ls -lh | grep test_semibin
- name: run "makedist.sh --unknown"
shell: bash
run: ./makedist.sh --unknown || echo -e "\e[34m# done"