-
Notifications
You must be signed in to change notification settings - Fork 456
927 lines (892 loc) · 35.5 KB
/
cpp-python-build.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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
name: C/C++ build
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
env:
release: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
jobs:
XML-validation:
if: ${{ !startsWith(github.event.head_commit.message, '[skip ci]') || github.event_name == 'pull_request' }}
name: XML validation
runs-on: ubuntu-latest
steps:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Validate scripts files
run: |
for filename in scripts/*.xml; do
[ -e "$filename" ] || continue
[ "$filename" != "scripts/kml_output.xml" ] || continue
[ "$filename" != "scripts/plotfile.xml" ] || continue
[ "$filename" != "scripts/unitconversions.xml" ] || continue
xmllint --noout --schema JSBSimScript.xsd $filename
done
- name: Validate systems files
run: |
for filename in systems/*.xml; do
[ -e "$filename" ] || continue
xmllint --noout --schema JSBSimSystem.xsd $filename
done
MSIS-validation:
name: MSIS code validation
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{matrix.os}}
steps:
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Configure the MSIS test program
run: |
mkdir build && cd build
cmake ../src/models/atmosphere/MSIS
- name: Build the JSBSim test program
working-directory: build
run: make -j2
- name: Run the NRLMSIS-00 C package
working-directory: src/models/atmosphere/MSIS
run: |
if [[ $(head -261 DOCUMENTATION | tail -104 | diff -urN <(../../../../build/nrlmsise-test) - | wc -c) -ne 0 ]]; then
echo "Failed."
exit 1
fi
Linux:
name: C/C++ build (Linux)
needs: [XML-validation, MSIS-validation]
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
expat: [ON, OFF]
shared_libs: [ON, OFF]
build_julia: [OFF]
display_stack_trace: [ON]
include:
- os: ubuntu-20.04
expat: OFF
shared_libs: OFF
build_julia: ON
display_stack_trace: OFF
env:
static_link: ${{ matrix.expat == 'OFF' && matrix.shared_libs == 'OFF' }}
runs-on: ${{ matrix.os }}
steps:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install cxxtest valgrind binutils-dev
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Python packages
run: pip install -U cython 'numpy>=1.20' pandas scipy wheel valgrindci 'setuptools>=60.0.0'
- name: Configure Julia
if: matrix.build_julia == 'ON'
run: |
julia -e "import Pkg;Pkg.add(\"CxxWrap\")"
export CXXWRAP_PREFIX_PATH=`julia -e "using CxxWrap;print(CxxWrap.prefix_path())"`
echo "JSBSIM_PREFIX_PATH=$CXXWRAP_PREFIX_PATH" >> $GITHUB_ENV
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Checkout Backward-cpp
if: matrix.display_stack_trace == 'ON'
id: BackwardCppCheckout
uses: actions/checkout@v3
with:
repository: bombela/backward-cpp
ref: 'v1.6'
path: backward-cpp
- name: Configure Backward-cpp
if: steps.BackwardCppCheckout.outcome == 'success'
run: echo "JSBSIM_PREFIX_PATH=$PWD/backward-cpp" >> $GITHUB_ENV
- name: Configure JSBSim
run: |
mkdir build && cd build
cmake -DCPACK_GENERATOR=DEB -DINSTALL_JSBSIM_PYTHON_MODULE=ON -DCMAKE_C_FLAGS_DEBUG="-g -O2" -DCMAKE_CXX_FLAGS_DEBUG="-g -O2" -DCMAKE_BUILD_TYPE=Debug -DSYSTEM_EXPAT=${{matrix.expat}} -DBUILD_SHARED_LIBS=${{matrix.shared_libs}} -DBUILD_JULIA_PACKAGE=${{matrix.build_julia}} -DFPECTL_DISPLAY_STACK_TRACE=${{matrix.display_stack_trace}} -DCMAKE_PREFIX_PATH=$JSBSIM_PREFIX_PATH -DCMAKE_INSTALL_PREFIX=/usr ..
- name: Cache CTest cost data
# This file is used by CTest to optimize the distribution of the tests
# between the cores and reduce execution time.
uses: actions/cache@v3
with:
path: build/Testing/Temporary/CTestCostData.txt
key: ${{ runner.os }}-${{ hashFiles('tests/CMakeLists.txt') }}
- name: Build JSBSim
working-directory: build
run: make -j2
- name: Test with Valgrind
run: |
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --track-origins=yes --xml=yes --xml-file=valgrind_Short_S23_3.xml build/src/JSBSim scripts/Short_S23_3.xml --end-time=5.
valgrind-ci valgrind_Short_S23_3.xml --abort-on-errors
- name: Test the Display of the Stack Trace when an FPE is raised
if: steps.BackwardCppCheckout.outcome == 'success'
working-directory: build
run: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/src ctest -R fpectl -V
- name: Test JSBSim
working-directory: build
run: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/src ctest -j2 --output-on-failure
- name: Build Ubuntu packages
if: env.static_link == 'true'
working-directory: build
run: cpack
# On failure, upload logs
- name: On failure - Upload logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: Linux-${{ matrix.os }}-system_expat_${{ matrix.expat }}-shared_libs_${{ matrix.shared_libs }}.logs
path: |
build/Testing/Temporary/*.log
build/tests/*-build.log
valgrind_Short_S23_3.xml
- name: On failure - Display a summary of valgrind errors.
if: failure()
run: valgrind-ci valgrind_Short_S23_3.xml --number-of-errors --summary --source=.
- name: Upload Files for Release
uses: actions/upload-artifact@v3
if: env.release == 'true' && env.static_link == 'true'
with:
name: Linux-${{ matrix.os }}.binaries
path: build/*.deb
Matlab-SFunction:
name: Matlab S-Function
needs: [ Linux, MacOSX, Windows-MSVC ]
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-22.04, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Set up Matlab
uses: matlab-actions/[email protected]
with:
release: R2022a
- name: Configure JSBSim
run: |
mkdir build
cd build
cmake -DBUILD_MATLAB_SFUNCTION=ON ..
- name: Build JSBSim S-Function
working-directory: build
run: cmake --build . --config RelWithDebInfo --target JSBSim_SFunction
- name: Prepare Tests
working-directory: matlab
# The script will be run from the directory 'matlab' so we need to copy
# the folders that will be used by JSBSim
run: |
cp -R ../aircraft .
cp -R ../engine .
cp -R ../systems .
cp -R ../scripts .
- name: Force Matlab using the system libstdc++ rather than its own (Linux)
# See https://stackoverflow.com/questions/37921139/error-version-glibcxx-3-4-21-not-found
if: runner.os == 'Linux'
run: echo "LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6" >> $GITHUB_ENV
- name: Run Tests (Linux & MacOSX)
if: runner.os != 'Windows'
id: tests-unix
uses: matlab-actions/run-command@v1
with:
command: addpath('build/matlab'), run('matlab/TestJSBSim.m')
- name: Run Tests (Windows)
if: runner.os == 'Windows'
id: tests-windows
uses: matlab-actions/run-command@v1
with:
command: addpath('build/matlab/RelWithDebInfo'), run('matlab/TestJSBSim.m')
- name: Upload Files for Release (Linux & MacOSX)
if: steps.tests-unix.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: Matlab-SFunction-${{ runner.os }}.binaries
path: build/matlab/JSBSim_SFunction.mex*
- name: Upload Files for Release (Windows)
if: steps.tests-windows.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: Matlab-SFunction-${{ runner.os }}.binaries
path: |
build/JSBSim.iss
build/matlab/JSBSimSimulinkCompile.m
build/matlab/RelWithDebInfo/JSBSim_SFunction.mex*
Windows-MinGW32:
name: C/C++ build (MinGW32)
needs: XML-validation
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
shared_libs: [ON, OFF]
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Checkout CxxTest
uses: actions/checkout@v3
with:
repository: CxxTest/cxxtest
ref: '4.4'
path: cxxtest
- name : Configure CxxTest
working-directory: cxxtest
run: |
cp python/python3/cxxtest/*.py cxxtest/.
cp python/python3/scripts/cxxtestgen .
- name: Configure JSBSim
run: |
mkdir build && cd build
julia -e 'import Pkg;Pkg.add(\"CxxWrap\")'
$CXXWRAP_PREFIX_PATH=julia -e 'using CxxWrap;print(CxxWrap.prefix_path())'
cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{matrix.shared_libs}} -DBUILD_JULIA_PACKAGE=ON -DCMAKE_INCLUDE_PATH="$(get-location)\..\cxxtest" -DBUILD_PYTHON_MODULE=OFF -DBUILD_DOCS=OFF -DCMAKE_PREFIX_PATH="$CXXWRAP_PREFIX_PATH" ..
- name: Build JSBSim
working-directory: build
run: mingw32-make -j2
- name: Test executable
run: build/src/JSBSim.exe scripts/c1721.xml
- name: Run JSBSim tests
working-directory: build
run: |
cp src/libJSBSim.* julia/.
ctest -j2 --output-on-failure
# Upload files
- name: On failure - Upload logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: Windows_MinGW32.logs
path: build/Testing/Temporary
Windows-MSVC:
name: C/C++ build (MSVC)
needs: XML-validation
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
shared_libs: [ON, OFF]
steps:
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Python packages
run: pip install -U cython 'numpy>=1.20' pandas scipy wheel pywin32 'setuptools>=60.0.0'
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Cache CTest cost data
# Cache the file is used by CTest to optimize the distribution of the tests
# between the cores and reduce execution time.
uses: actions/cache@v3
id: cache-win-msvc
with:
path: |
build/Testing/Temporary/CTestCostData.txt
key: ${{ runner.os }}-${{ hashFiles('tests/CMakeLists.txt') }}
- name: Checkout CxxTest
uses: actions/checkout@v3
with:
repository: CxxTest/cxxtest
ref: '4.4'
path: cxxtest
- name : Configure CxxTest
working-directory: cxxtest
run: |
cp python/python3/cxxtest/*.py cxxtest/.
cp python/python3/scripts/cxxtestgen .
- name: Checkout Backward-cpp
uses: actions/checkout@v3
with:
repository: bombela/backward-cpp
ref: 'v1.6'
path: backward-cpp
- name: MSVC version
run: |
$MSVC_name = vswhere -property displayName
$MSVC_build = vswhere -property catalog_buildVersion
Out-File -InputObject $MSVC_name" (build "$MSVC_build")" -NoNewLine MSVC_version.txt
- name: Configure JSBSim
run: |
New-Item -Path .\build -ItemType Directory -Force
cd build
cmake -DCMAKE_INCLUDE_PATH="$(get-location)\..\cxxtest" -DCMAKE_PREFIX_PATH="$(get-location)\..\backward-cpp" -DBUILD_SHARED_LIBS=${{matrix.shared_libs}} -DFPECTL_DISPLAY_STACK_TRACE=ON -DSTACK_DETAILS_AUTO_DETECT=FALSE ..
- name: Build JSBSim
working-directory: build
run: cmake --build . --config RelWithDebInfo
- name: Test the Display of the Stack Trace when an FPE is raised
working-directory: build
run: ctest -R fpectl --build-config RelWithDebInfo -V
- name: Test JSBSim
working-directory: build
run: ctest -j2 --build-config RelWithDebInfo --output-on-failure
# On failure, upload logs
- name: On failure - Upload logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: Windows_MSVC.logs
path: |
build/Testing/Temporary/*.log
build/tests/*-build.log
- name: Upload Files for Release
uses: actions/upload-artifact@v3
if: env.release == 'true' && matrix.shared_libs == 'OFF'
with:
name: ${{ runner.os }}.binaries
path: |
build/src/RelWithDebInfo/JSBSim.lib
build/src/RelWithDebInfo/JSBSim.exe
build/utils/aeromatic++/RelWithDebInfo/aeromatic.exe
build/python/setup.py
MSVC_version.txt
Windows-installer:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
name: Build Windows installer
needs: Matlab-SFunction
runs-on: windows-2019
steps:
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Checkout JSBSim logos
uses: actions/checkout@v3
with:
repository: JSBSim-Team/jsbsim-logo
path: jsbsim-logo
- name: Download binary file for JSBSim.iss
uses: actions/download-artifact@v3
with:
name: Matlab-SFunction-Windows.binaries
path: build
- name: Download JSBSim library and executable
uses: actions/download-artifact@v3
with:
name: Windows.binaries
- name: Update the version of JSBSim in matlab/README.md
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
$JSBSim_version = ((.\build\src\RelWithDebInfo\JSBSim.exe --version) -split '\s+')[4]
$prev_version = ((Get-Content README.md | Select-String -Pattern 'JSBSim-([0-9]+\.)+[0-9]+-setup.exe') -split '-')[1]
(Get-Content -Path matlab\README.md) -Replace "$prev_version", "$JSBSim_version" | Set-Content -Path matlab\README.md
- name: Build JSBSim installer for Windows
working-directory: build
run: |
# Relocate the logos for the wizard installer
mkdir logos
cp ..\jsbsim-logo\wizard_installer\*.bmp logos\.
mkdir small
cp ..\jsbsim-logo\wizard_installer\small\*.bmp small\.
# Update the version of MSVC in matlab/README.md
$MSVC_version = Get-Content -Path ..\MSVC_version.txt
(Get-Content -Path ..\matlab\README.md) -Replace 'Visual Studio\s[A-Za-z0-9 ]+\s\(build\s[0-9.]+\)', "$MSVC_Version" | Set-Content -Path ..\matlab\README.md
# Relocate the executables for the installer
cp src\RelWithDebInfo\JSBSim.exe src\.
cp src\RelWithDebInfo\JSBSim.lib src\.
cp utils\aeromatic++\RelWithDebInfo\aeromatic.exe utils\aeromatic++\.
# Get the MSVC C++ DLL
$Paths = $Env:PATH+';'+[System.Environment]::SystemDirectory
foreach($path in $Paths -split ';') {
if (Test-Path $path) {
$File = Get-ChildItem -Path $path | Where-Object {$_.Name -eq 'msvcp140.dll'}
if ($File) {
cp $File.FullName .
break;
}
}
}
# Compile the installer with Inno Setup
iscc JSBSim.iss
- name: Upload the installer for Release
uses: actions/upload-artifact@v3
with:
name: Windows-installer.binaries
path: |
build\Output\*.exe
MacOSX:
name: C/C++ build (MacOSX)
needs: [XML-validation, MSIS-validation]
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64]
steps:
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Python packages
if: matrix.arch == 'x86_64'
run: pip install -U cython 'numpy>=1.20' pandas scipy build 'setuptools>=60.0.0' mypy
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Cache CTest cost data
# This file is used by CTest to optimize the distribution of the tests
# between the cores and reduce execution time.
uses: actions/cache@v3
if: matrix.arch == 'x86_64'
with:
path: build/Testing/Temporary/CTestCostData.txt
key: ${{ runner.os }}-${{ hashFiles('tests/CMakeLists.txt') }}
- name: Install & Configure Doxygen
if: env.release == 'true' && matrix.arch == 'x86_64'
run: |
brew install doxygen
# We don't want Doxygen to generate the HTML docs in this job (saves time)
# Set GENERATE_HTML and HAVE_DOT to NO
perl -i -pe 's/^(GENERATE_HTML\s*=\s*)YES/\1NO/g' doc/JSBSim.dox.in
perl -i -pe 's/^(HAVE_DOT\s*=\s*)YES/\1NO/g' doc/JSBSim.dox.in
- name: Checkout CxxTest
uses: actions/checkout@v3
with:
repository: CxxTest/cxxtest
ref: '4.4'
path: cxxtest
- name: Configure CxxTest
working-directory: cxxtest/python
run: python setup.py install
- name: Configure JSBSim (x86_64)
if: matrix.arch == 'x86_64'
run: |
mkdir -p build && cd build
julia -e "import Pkg;Pkg.add(\"CxxWrap\")"
export CXXWRAP_PREFIX_PATH=`julia -e "using CxxWrap;print(CxxWrap.prefix_path())"`
cmake -DCMAKE_INCLUDE_PATH=$PWD/../cxxtest -DBUILD_JULIA_PACKAGE=ON -DCYTHON_FLAGS="-X embedsignature=True" -DCMAKE_PREFIX_PATH=$CXXWRAP_PREFIX_PATH ..
- name: Configure JSBSim (arm64)
if: matrix.arch == 'arm64'
run: |
mkdir -p build && cd build
cmake -DCMAKE_INCLUDE_PATH=$PWD/../cxxtest -DCMAKE_OSX_ARCHITECTURES=${{matrix.arch}} -DBUILD_PYTHON_MODULE=OFF -DBUILD_DOCS=OFF ..
- name: Build JSBSim
working-directory: build
run: make -j3
- name: Test JSBSim
if: matrix.arch == 'x86_64'
working-directory: build
run: ctest -j3 --output-on-failure
- name: Build the source package for Python
if: env.release == 'true' && matrix.arch == 'x86_64'
working-directory: build/tests
run: |
echo "::group::Build the type hints stubs"
stubgen -p jsbsim -o ../python
echo "::endgroup::"
echo "::group::Build the source package"
cd ../python
touch jsbsim/py.typed
rm -f _jsbsim.cxx # Make sure that jsbsim.cxx is not stored in the source distribution
python -m build --sdist
echo "::endgroup::"
# On failure, upload logs
- name: On failure - Upload logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: MacOSX.logs
path: |
build/Testing/Temporary/*.log
build/tests/*-build.log
- name: Upload Files for Release
uses: actions/upload-artifact@v3
if: env.release == 'true' && matrix.arch == 'x86_64'
with:
name: ${{ runner.os }}.binaries
path: |
build/src/libJSBSim.a
build/python/setup.py
build/python/dist/*.tar.gz
Test-Build-PyPackage-From-Source:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
name: Build Python Module from Source
needs: MacOSX
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7]
include:
- python-version: 3.9
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python packages
run: pip install -U cython 'numpy>=1.20' mypy
- name: Download source package
uses: actions/download-artifact@v3
with:
name: macOS.binaries
- name: Build Python module from sources (Linux & MacOSX)
if: runner.os != 'Windows'
run: pip install python/dist/*.tar.gz -vv
- name: Build Python module from sources (Windows)
if: runner.os == 'Windows'
run: |
$PyPackage = Get-ChildItem -Path python\dist -Filter *.tar.gz | Select-Object -First 1
pip install $PyPackage.FullName -vv
- name: Test Python module
shell: python
run: |
import jsbsim
print(jsbsim.FGAircraft.__doc__)
fdm=jsbsim.FGFDMExec(None)
fdm.load_script('scripts/Short_S23_1.xml')
fdm.run_ic()
while fdm.get_sim_time() < 10:
fdm.run()
- name: Test type hints
run: |
echo "import jsbsim" > test.py
mypy test.py
Python-Wheels:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
name: Build Python wheels
needs: [Linux, Windows-MSVC, MacOSX]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-2019]
steps:
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install Python packages
run: pip install -U cython 'numpy>=1.20' mypy
- name: Install Doxygen (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install doxygen
- name: Install Doxygen (MacOSX)
if: matrix.os == 'macos-11'
run: brew install doxygen
- name: Install Doxygen (Windows)
if: runner.os == 'Windows'
run: cinst doxygen.install
- name: Configure Doxygen
run: |
# We don't want Doxygen to generate the HTML docs in this job (saves time)
# Set GENERATE_HTML and HAVE_DOT to NO
perl -i -pe 's/^(GENERATE_HTML\s*=\s*)YES/\1NO/g' doc/JSBSim.dox.in
perl -i -pe 's/^(HAVE_DOT\s*=\s*)YES/\1NO/g' doc/JSBSim.dox.in
- name: Download source package
uses: actions/download-artifact@v3
with:
name: macOS.binaries
- name: Configure JSBSim (BSD/Unix)
if: runner.os != 'Windows'
run: |
echo "::group::Run CMake"
mkdir build && cd build
cmake ..
echo "::endgroup::"
echo "::group::Get Python package sources"
touch python/jsbsim/py.typed
cd ../python/dist
tar zxvf *.tar.gz
cp -R JSBSim-*/jsbsim/*.pyi ../../build/python/jsbsim/.
echo "::endgroup::"
- name: Configure JSBSim (Windows)
if: runner.os == 'Windows'
run: |
echo "::group::Run CMake"
New-Item -Path .\build -ItemType Directory -Force
cd build
cmake ..
cmake --build . --target libJSBSim --config RelWithDebInfo
echo "::endgroup::"
echo "::group::Get Python package sources"
New-Item python\jsbsim\py.typed
cd ..\python/dist
$PyPackage = Get-ChildItem .\*.tar.gz -Name
tar zxvf $PyPackage
Copy-Item -Path .\JSBSim-*\jsbsim\*.pyi -Destination ..\..\build\python\jsbsim
echo "::endgroup::"
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL_LINUX: |
cd build
rm -f CMakeCache.txt
cmake -DCMAKE_C_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno" -DCMAKE_CXX_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno" -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --target libJSBSim -- -j2
CIBW_BEFORE_ALL_MACOS: |
cd build
rm -f CMakeCache.txt
cmake -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_C_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno" -DCMAKE_CXX_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno" -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --target libJSBSim -- -j3
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_SKIP: cp*-musllinux_* cp38-macosx_x86_64 cp39-macosx_x86_64 cp310-macosx_x86_64 cp311-macosx_x86_64
CIBW_ARCHS_WINDOWS: native
JSBSIM_BUILD_CONFIG: RelWithDebInfo
with:
package-dir: build/python
- name: Test wheel package
run: |
echo "::group::Test module execution"
pip install jsbsim --no-index -f wheelhouse
python -c "import jsbsim;print(jsbsim.FGAircraft.__doc__);fdm=jsbsim.FGFDMExec(None);fdm.load_script('scripts/Short_S23_1.xml');fdm.run_ic()"
echo "::endgroup::"
echo "::group::Test type hints"
echo "import jsbsim" > test.py
mypy test.py
echo "::endgroup::"
- name: Test default root package detection (global & --user)
run: |
# Test global installation
python -c "import jsbsim;print(jsbsim.get_default_root_dir())"
pip uninstall jsbsim -y
# Test --user installation
pip install --user jsbsim --no-index -f wheelhouse
python -c "import jsbsim;print(jsbsim.get_default_root_dir())"
pip uninstall jsbsim -y
- name: Test default root package detection (virtual env - Windows)
if: runner.os == 'Windows'
run: |
# Test virtual environment installation
python -m venv test_venv
test_venv\Scripts\activate.ps1
pip install 'numpy>=1.20'
pip install jsbsim --no-index -f wheelhouse
python -c "import jsbsim;print(jsbsim.get_default_root_dir())"
pip uninstall jsbsim -y
deactivate
- name: Test default root package detection (virtual env - BSD/Unix)
if: runner.os != 'Windows'
run: |
# Test virtual environment installation
python -m venv test_venv
source test_venv/bin/activate
pip install 'numpy>=1.20'
pip install jsbsim --no-index -f wheelhouse
python -c "import jsbsim;print(jsbsim.get_default_root_dir())"
pip uninstall jsbsim -y
deactivate
- name: Upload Files for Release
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-Wheels.binaries
path: ./wheelhouse/*.whl
Codecov:
name: Code coverage
needs: Linux
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install cxxtest lcov
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Configure JSBSim
run: |
mkdir build && cd build
cmake -DENABLE_COVERAGE=ON -DBUILD_PYTHON_MODULE=OFF ..
- name: Build JSBSim
working-directory: build
run: make -j2
- name: Run JSBSim tests
working-directory: build
run: ctest -R Test1 --output-on-failure
- name: Generate coverage report
working-directory: build
run: make lcov
- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
working-directory: build/lcov/data/capture
files: all_targets.info
Rolling-Release:
needs: [Test-Build-PyPackage-From-Source, Windows-MinGW32, Windows-installer]
name: Deploy Rolling Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Download files
uses: actions/download-artifact@v3
- name: Prepare files
run: |
mkdir dist
find . -type f -name *.exe -exec cp {} dist/. \;
find . -type f -name *.whl -exec cp {} dist/. \;
find . -type f -name *.deb -exec cp {} dist/. \;
- name: Rolling release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Rolling release
tag_name: Linux
prerelease: true
body: |
Contains the packages built from the bleeding edge code
(branch ${{ github.ref }} commit ${{ github.sha}})
files: |
dist/*.exe
dist/*.whl
dist/*.deb
Stable-Release:
name: Deploy Stable Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [Python-Wheels, Test-Build-PyPackage-From-Source, Windows-MinGW32, Windows-installer]
runs-on: ubuntu-latest
environment: release
permissions:
contents: write # Needed for the GitHub release
id-token: write # Mandatory for PyPI trusted publishing
steps:
- name: Download files
uses: actions/download-artifact@v3
- name: Prepare files for deployment
run: |
find . -type f -name MSVC_version.txt -exec cp {} . \;
mkdir dist
find . -type f -name *.whl -exec cp {} dist/. \;
find . -type f -name *.tar.gz -exec cp {} dist/. \;
mkdir GH_release
find . -type f -name *.exe -exec cp {} GH_release/. \;
find . -type f -name *.deb -exec cp {} GH_release/. \;
# PyPI deployment
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: PyPI deployment
uses: pypa/gh-action-pypi-publish@release/v1
# Deploy stable release to GitHub
- name: Get JSBSim version
run: |
pip install -U 'numpy>=1.20'
pip install jsbsim --no-index -f dist
export VERSION=`pip show jsbsim | grep -i version | awk '{ print $2 }'`
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get MSVC version
run : |
export MSVC_VERSION=`cat MSVC_version.txt`
echo "MSVC_VERSION=$MSVC_VERSION" >> $GITHUB_ENV
- name: GitHub release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: v${{ env.VERSION }}
body: |
JSBSim version ${{ env.VERSION }}
## Release files
- Windows 64 bits
- `JSBSim-${{ env.VERSION }}-setup.exe` (Windows installer compiled with Microsoft ${{ env.MSVC_VERSION }})
- Ubuntu Focal 20.04 and Jammy 22.04 - amd64
- `*.deb` (Debian packages)
- Python wheel packages can be installed from [PyPI](https://pypi.org/project/JSBSim/) with the command `pip install jsbsim` or `pip install --upgrade jsbsim` when JSBSim is already installed on your system.
- Conda packages are available from [conda-forge](https://anaconda.org/conda-forge/jsbsim). To install this package with conda run: `conda install -c conda-forge jsbsim`
## Changelog
prerelease: false
draft: false
files: |
GH_release/*.exe
GH_release/*.deb
# Bump version
- name: Checkout JSBSim
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Bump version
run: |
# Increment the value of PROJECT_VERSION_PATCH
sed -ri 's/(set\(PROJECT_VERSION_PATCH\s\")([0-9]+)(.*)/echo "\1\\"$((\2+1))\\"\3"/ge' CMakeLists.txt
# Extract from CMake the project version number at the next release.
echo "message(STATUS \"JSBSIM_VERSION:\${PROJECT_VERSION}\")" >> src/CMakeLists.txt
export FUTURE_VERSION=`cmake . | grep JSBSIM_VERSION | awk -F':' '{print $2}'`
# Extract the project old version number
export OLD_VERSION=`egrep 'JSBSim-([0-9]+\.)+[0-9]+-setup.exe' README.md | awk -F'JSBSim-' '{ print $2}' | awk -F'-setup.exe' '{ print $1}'`
echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV
# Update references to the current stable version in README.md
sed -ri 's/_'"$OLD_VERSION"'-[0-9]+.amd64.deb/_'"$VERSION"'-'"$GITHUB_RUN_NUMBER"'.amd64.deb/g' README.md
sed -ri 's/'"$OLD_VERSION"'/'"$VERSION"'/g' README.md
sed -ri 's/'"$OLD_VERSION"'/'"$VERSION"'/g' matlab/README.md
# Update the MSVC project files.
sed -ri 's/JSBSIM_VERSION=".*"/JSBSIM_VERSION="'$FUTURE_VERSION'"/g' JSBSim.vcxproj
sed -ri 's/JSBSIM_VERSION=".*"/JSBSIM_VERSION="'$FUTURE_VERSION'"/g' JSBSimForUnreal.vcxproj
# Update the MSVC version
sed -ri 's/Visual Studio\s[A-Za-z0-9 ]+\s\(build\s[0-9.]+\)/'"$MSVC_VERSION"'/g' matlab/README.md
# Determine the branch name
export BRANCH_NAME=`git branch -a --contains HEAD | awk -F'/' 'NR==2 { s=$3;for(i=4;i<=NF;i++){ s=s"/"$i };print s }'`
# Commit the change to CMakeLists.txt
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout $BRANCH_NAME
git commit -m "Bump version" CMakeLists.txt README.md matlab/README.md JSBSim.vcxproj JSBSimForUnreal.vcxproj
git push origin $BRANCH_NAME
# Bump stable version of the `master` branch
- name: Checkout JSBSim master branch
uses: actions/checkout@v3
with:
ref: master
path: _master
- name: Bump stable version in README.md
working-directory: _master
run: |
# Update references to the current stable version in README.md
sed -ri 's/_'"$OLD_VERSION"'-[0-9]+.amd64.deb/_'"$VERSION"'-'"$GITHUB_RUN_NUMBER"'.amd64.deb/g' README.md
sed -ri 's/'"$OLD_VERSION"'/'"$VERSION"'/g' README.md
sed -ri 's/'"$OLD_VERSION"'/'"$VERSION"'/g' matlab/README.md
# Update the MSVC version
sed -ri 's/Visual Studio\s[A-Za-z0-9 ]+\s\(build\s[0-9.]+\)/'"$MSVC_VERSION"'/g' matlab/README.md
git commit -m "Bump stable release version" README.md matlab/README.md
git push origin master
Documentation:
needs: Stable-Release
name: Deploy Documentation
runs-on: ubuntu-latest
steps:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install doxygen graphviz
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Python packages
run: pip install -U 'numpy>=1.20' sphinx cython
- name: Checkout JSBSim
uses: actions/checkout@v3
- name: Configure JSBSim
run: |
mkdir build && cd build
cmake ..
- name: Download Python wheels
uses: actions/download-artifact@v3
with:
name: ubuntu-latest-Wheels.binaries
path: build
- name: Build Python docs
working-directory: build
run: |
pip install jsbsim --no-index -f .
touch documentation/html/.nojekyll
sphinx-build -b html documentation documentation/html/python
- name: Publish docs to GitHub Pages
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: build/documentation/html
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}