forked from OpenRadioss/OpenRadioss
-
Notifications
You must be signed in to change notification settings - Fork 0
970 lines (828 loc) · 35.1 KB
/
prmerge_ci_main.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
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
name: PR Merge CI MAIN
on:
push:
branches:
- main
env:
CLOSE_BRANCH: 0
TEAM_RESTRICTIVE_CLOSED_BRANCH: ${{ secrets.TEAM_RESTRICTIVE_CLOSED_BRANCH }}
FROM_EMAIL: ${{ secrets.FROM_EMAIL }}
TO_EMAIL: ${{ secrets.TO_EMAIL }}
MAIL_RELAY: ${{ secrets.MAIL_RELAY }}
QA_TIMEOUT_PER_TEST_LINUX: 150
QA_TIMEOUT_PER_TEST_WIN: 500
jobs:
build_tools_linux:
if: ${{ github.repository_owner == 'OpenRadioss' }}
# DEV ONLY # runs-on: ["linux64","dev_pmci"]
runs-on: ["linux64","prmerge_ci"]
continue-on-error: true
container:
image: fr-qafactorydev.europe.altair.com/build-linux64_gf:cos8-ompi411-devts11
credentials:
username: ${{secrets.DOCKER_REGISTRY_USER}}
password: ${{secrets.DOCKER_REGISTRY_PASSWD}}
volumes:
- /etc/localtime:/etc/localtime:ro
env:
STATUS_BUILD: 0
os: linux64
steps:
# Set the working dir suffixed with branch name
- name: Set workdir
run: |
if [ "${{ github.base_ref }}" = "" ]
then
echo "WORKDIR=${{github.ref_name}}" >> $GITHUB_ENV
else
echo "WORKDIR=${{github.base_ref}}" >> $GITHUB_ENV
fi
- name: Create branch oriented WS directory & integration WS
run: |
mkdir -p ${{ env.WORKDIR }}
- name: Clean local exe dir
working-directory: ${{ env.WORKDIR }}
run: |
rm -rf exec
md5sum exec/* || echo "Nothing in exec/"
# Get last git modifications, don't clean before (way to keep persistent obj files)
- name: Checkout git sources
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
clean: 'false'
lfs: 'true'
- name: Running builds
working-directory: ${{ env.WORKDIR }}
run: |
mkdir exec
source /home/adminqa/.bashrc
cmd="./build.bash"
echo "========================================="
echo "-- BUILD tools for anim_to_vtk (${{ env.os }}) --"
echo "-- $cmd --"
echo "========================================="
cd tools/anim_to_vtk/${{ env.os }}
eval $cmd
cmd="./build.bash"
echo "========================================="
echo "-- BUILD tools for anim_to_vtk (${{ env.os }}) --"
echo "-- $cmd --"
echo "========================================="
cd ../../th_to_csv/${{ env.os }}
eval $cmd
# Set correct end of step status (if not an email will be sent)
echo "STATUS_BUILD=1" >> $GITHUB_ENV
- name: Managing step execution
if: ${{ always() }}
run: |
MAILMSG="Some error(s) has(ve) been raised during workflow execution:\n\n"
echo -e "\n#### STATUS_STEP_BUILD ${{ env.os }} ###"
if [ "$STATUS_BUILD" = 0 ]
then
echo -e "Status\t[ \033[31;2;1mFAILED\033[0m ]"
MAILMSG="The build tools ${{ env.os }} has failed \n"
# Send email
# Setting SMTP server (docker host)
DOCKER_HOST=`/sbin/ip route|awk '/default/ { print $3 }'`
echo "set smtp=smtp://${DOCKER_HOST}:25" >> /etc/mail.rc
# Print message in log
echo -e $MAILMSG
# Send email
echo -e "$MAILMSG" | Mail -r $FROM_EMAIL -s "Error in Github CI repo ${{ github.repository }} (${{github.sha}})" $TO_EMAIL
else
echo -e "Status\t[ \033[32;2;1mOK\033[0m ]"
fi
# Upload artifact
- name: Upload built artifacts
uses: actions/upload-artifact@v4
with:
name: tools-${{ env.os }}
path: ${{ env.WORKDIR }}/exec
build_tools_windows_no_container:
if: ${{ github.repository_owner == 'OpenRadioss' }}
runs-on: ["win64","build","prmerge_ci"]
continue-on-error: true
env:
STATUS_BUILD: 0
os: win64
steps:
# Set the working dir suffixed with branch name
- name: Set workdir
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
if [ \"${{ github.base_ref }}\" = \"\" ];
then
echo \"WORKDIR=${{github.ref_name}}\" >> $GITHUB_ENV;
else
echo \"WORKDIR=${{github.base_ref}}\" >> $GITHUB_ENV;
fi;
"
- name: Create branch oriented WS directory & integration WS (WIN64)
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
cd %cd:\=/%;
mkdir -p ${{ env.WORKDIR }};
"
- name: Clean local exe dir
working-directory: ${{ env.WORKDIR }}
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
cd %cd:\=/%;
rm -rf exec;
"
# Get last git modifications, don't clean before (way to keep persistent obj files)
- name: Checkout git sources
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
clean: 'false'
lfs: 'true'
- name: Running builds
working-directory: ${{ env.WORKDIR }}
shell: cmd
run: >
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 vs2019 && C:\cygwin64\bin\bash --login -c "
cd %cd:\=/%;
mkdir exec;
cmd=\"./build.bat\";
echo \"=========================================\";
echo \"-- BUILD tools for anim_to_vtk (${{ env.os }}) --\";
echo \"-- $cmd --\";
echo \"=========================================\";
cd tools/anim_to_vtk/${{ env.os }};
eval $cmd || exit 1;
cmd=\"./build.bat\";
echo \"=========================================\";
echo \"-- BUILD tools for anim_to_vtk (${{ env.os }}) --\";
echo \"-- $cmd --\";
echo \"=========================================\";
cd ../../th_to_csv/${{ env.os }};
eval $cmd || exit 1;
echo \"STATUS_BUILD=1\" >> $GITHUB_ENV;
"
- name: Managing step execution
if: ${{ always() }}
# Running cygwin from powershell or cmd => neither identation nor comment !
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
MAILMSG=\"Some error(s) has(ve) been raised during workflow execution:\n\n\";
echo -e \"\n#### STATUS_STEP_BUILD ${{ env.os }} ###\";
if [ ${{ env.STATUS_BUILD }} = 0 ];
then
echo -e \"Status\t[ \033[31;2;1mFAILED\033[0m ]\";
MAILMSG+=\"The build tools ${{ env.os }} has failed \n\";
echo -e $MAILMSG;
echo -e \"$MAILMSG\" | Email -f $FROM_EMAIL -s \"Error in Github CI repo ${{ github.repository }} (${{github.sha}})\" -r $MAIL_RELAY $TO_EMAIL;
exit 1;
else
echo -e \"Status\t[ \033[32;2;1mOK\033[0m ]\";
fi;
"
# Upload artifact
- name: Upload built artifacts
uses: actions/upload-artifact@v4
with:
name: tools-${{ env.os }}
path: ${{ env.WORKDIR }}/exec
build_linux:
if: ${{ github.repository_owner == 'OpenRadioss' }}
# DEV ONLY # runs-on: ["${{ matrix.build }}","dev_pmci"]
runs-on: ["${{ matrix.build }}","prmerge_ci"]
container:
image: fr-qafactorydev.europe.altair.com/build-linux64_gf:cos8-ompi411-devts11
credentials:
username: ${{secrets.DOCKER_REGISTRY_USER}}
password: ${{secrets.DOCKER_REGISTRY_PASSWD}}
volumes:
- /etc/localtime:/etc/localtime:ro
env:
BUILD_NB_THREAD: 2
STATUS_BUILD: 0
SERVBOT_PAT: ${{ secrets.SERVBOT_PAT }}
strategy:
# If one job fails others are canceled
fail-fast: true
matrix:
include:
- build: starter_linux64_gf
precision: dp
os: linux64
binary: starter
- build: starter_linux64_gf_sp
precision: sp
os: linux64
binary: starter
- build: engine_linux64_gf_ompi
precision: dp
os: linux64
binary: engine
mpi: ompi
- build: engine_linux64_gf_ompi_sp
precision: sp
os: linux64
binary: engine
mpi: ompi
- build: engine_linux64_gf
precision: dp
os: linux64
binary: engine
- build: engine_linux64_gf_sp
precision: sp
os: linux64
binary: engine
steps:
# Set the working dir suffixed with branch name
- name: Set workdir
run: |
if [ "${{ github.base_ref }}" = "" ]
then
echo "WORKDIR=${{github.ref_name}}" >> $GITHUB_ENV
else
echo "WORKDIR=${{github.base_ref}}" >> $GITHUB_ENV
fi
- name: Create branch oriented WS directory & integration WS
run: |
mkdir -p ${{ env.WORKDIR }}
- name: Clean local exe dir
working-directory: ${{ env.WORKDIR }}
run: |
rm -rf exec
md5sum exec/* || echo "Nothing in exec/"
# Get last git modifications, don't clean before (way to keep persistent obj files)
- name: Checkout git sources
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
clean: 'false'
lfs: 'true'
- name: Running build
working-directory: ${{ env.WORKDIR }}
run: |
mpi_opts=''
if [ ! -z ${{ matrix.mpi }} ]
then
mpi_opts="-mpi=${{ matrix.mpi }}"
fi
cmd="./build_script.sh -release -arch=${{ matrix.os }}_gf -prec=${{ matrix.precision }} -nt=${{ env.BUILD_NB_THREAD }} -static-link $mpi_opts"
echo "========================================="
echo "-- BUILD ${{ matrix.build }} --"
echo "-- $cmd --"
echo "========================================="
source /home/adminqa/.bashrc
chmod 755 Compiling_tools/script/*
chmod 755 ${{ matrix.binary }}/build_script.sh
# USED for development only (avoid using lfs)
test ! -e extlib && ln -s /__w/_tool/extlib .
md5sum exec/* || echo "Nothing in exec/"
mkdir exec
cd ${{ matrix.binary }}
eval $cmd
cd ..
# Exiting with failure is no bins generated, should be handle by build_script soon
md5sum exec/* || exit 1
# Set correct end of step status (if not an email will be sent)
echo "STATUS_BUILD=1" >> $GITHUB_ENV
- name: Managing step execution
if: ${{ always() }}
run: |
MAILMSG="Some error(s) has(ve) been raised during workflow execution:\n\n"
echo -e "\n#### STATUS_STEP_BUILD ${{ matrix.build }} ###"
if [ "$STATUS_BUILD" = 0 ]
then
echo -e "Status\t[ \033[31;2;1mFAILED\033[0m ]"
MAILMSG+="The build ${{ matrix.build }} has failed \n"
# Send email
# Close the branch
echo "CLOSE_BRANCH=1" >> $GITHUB_ENV
# Setting SMTP server (docker host)
DOCKER_HOST=`/sbin/ip route|awk '/default/ { print $3 }'`
echo "set smtp=smtp://${DOCKER_HOST}:25" >> /etc/mail.rc
# Print message in log
echo -e $MAILMSG
# Send email
echo -e "$MAILMSG\nThe branch is closed" | Mail -r $FROM_EMAIL -s "Error in Github CI repo ${{ github.repository }} (${{github.sha}})" $TO_EMAIL
# Exit fail to see it as a failure
exit 1
else
echo -e "Status\t[ \033[32;2;1mOK\033[0m ]"
fi
# Upload artifact (since V4 we can't upload artifact using the same name, each one must be unique)
- name: Upload built artifacts
uses: actions/upload-artifact@v4
with:
name: bins-${{ matrix.os }}-${{ matrix.precision }}-${{ matrix.build }}
path: ${{ env.WORKDIR }}/exec
if: ${{ env.CLOSE_BRANCH == 0 }}
# Close the branch (= restrict push to team devopsadmins) if needed
# Owner is not mandatory here ... PAT is sufficient ??? seems that as servbot has permissions on this repo so his PAT is sufficient ...
- uses: octokit/request-action@v2.x
id: close_branch_build
env:
GITHUB_TOKEN: ${{ env.SERVBOT_PAT }}
REQUEST_BODY: "['${{ env.TEAM_RESTRICTIVE_CLOSED_BRANCH}}']"
with:
route: PUT /repos/${{ github.repository }}/branches/main/protection/restrictions/teams
data: ${{ env.REQUEST_BODY }}
if: ${{ always() && env.CLOSE_BRANCH == 1 }}
# It the closing went wrong we send an email
- name: "Check result of closing branch and warn if it fails"
run: |
# No need to configure SMTP server, already done in previous steps
MAILMSG="Some error(s) has(ve) been raised during workflow execution:\n\n"
MAILMSG+="A branch closing is needed but has failed\n\n"
MAILMSG+="Return status API is : ${{ steps.close_branch_build.outputs.status }}\n\n"
MAILMSG+="Check more detailed datas in CI logs\n"
# Print message in log
echo -e $MAILMSG
echo -e "\nClose return data API is : ${{ steps.close_branch_build.outputs.data }}"
# Send email
echo -e "$MAILMSG" | Mail -r $FROM_EMAIL -s "Error in Github CI repo ${{ github.repository }} (${{github.sha}}) on closing branch" $TO_EMAIL
# Exit fail to see it as a failure
exit 1
if: ${{ always() && env.CLOSE_BRANCH == 1 && steps.close_branch_build.outputs.status != 200 }}
qa_linux:
needs: build_linux
# DEV ONLY # runs-on: ["qa_${{ matrix.os }}","dev"]
runs-on: ["qa_${{ matrix.os }}","prmerge_ci"]
container:
image: fr-qafactorydev.europe.altair.com/qa-linux64_gf:cos8-ompi411
credentials:
username: ${{secrets.DOCKER_REGISTRY_USER}}
password: ${{secrets.DOCKER_REGISTRY_PASSWD}}
volumes:
- /etc/localtime:/etc/localtime:ro
env:
hm_reader_extlib: ../../extlib/hm_reader
hm_reader_cfgfiles: ../../hm_cfg_files
homeuser: /home/adminqa
mpi: ompi
STATUS_QA: 0
SERVBOT_PAT: ${{ secrets.SERVBOT_PAT }}
# DEV ONLY # QA_NB_PROC: 2
QA_NB_PROC: 4
QA_NB_THREAD: 2
strategy:
# If one job fails others continue
fail-fast: false
matrix:
os: [linux64]
# precision: [dp,sp]
precision: [dp]
steps:
# Get git related to the commit
- name: Checkout git sources
uses: actions/checkout@v4
with:
lfs: 'true'
- name: Clean local exe dir
run: |
rm -rf exec
# Download artifacts (since V4 we must download all needed artifacts, we could do it using wildcard but it doesn't work ... see https://github.com/actions/download-artifact/issues/337)
# Using hard name waiting for this issue to be fixed
# - name: Download artifacts
# uses: actions/download-artifact@v4
# with:
# name: bins-${{ matrix.os }}-${{ matrix.precision }}-*
# path: exec
# merge-multiple: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
# name: "bins-${{ matrix.os }}-${{ matrix.precision }}-*"
name: bins-${{ matrix.os }}-${{ matrix.precision }}-starter_linux64_gf
path: exec
merge-multiple: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
# name: "bins-${{ matrix.os }}-${{ matrix.precision }}-*"
name: bins-${{ matrix.os }}-${{ matrix.precision }}-engine_linux64_gf_ompi
path: exec
merge-multiple: true
- name: Running qa
run: |
# USED for development only (avoid using lfs)
test ! -e extlib && ln -s /__w/_tool/extlib .
md5sum exec/* || echo "Nothing in exec/"
if [ "${{ matrix.precision }}" = "dp" ]
then
precision_ext=""
else
precision_ext="_${{ matrix.precision }}"
fi
chmod 755 exec/*
cd qa-tests/scripts
rm -f QA.summary
chmod 755 or_qa_script or_radioss.pl
source ${{ env.homeuser }}/.bashrc
export LD_LIBRARY_PATH=${{ env.hm_reader_extlib }}/${{ matrix.os }}:$LD_LIBRARY_PATH
cmd="./or_qa_script ../../exec/engine_${{ matrix.os }}_gf_${{ env.mpi }}${precision_ext} 1.0 --env:RAD_CFG_PATH=${{ env.hm_reader_cfgfiles }} --system_run --env:OMP_STACKSIZE=400m --exec_script_args='mpiexec -np ${{ env.QA_NB_PROC }}' --env:OMP_NUM_THREADS=${{ env.QA_NB_THREAD }} --output_failures_stdout --xtra_args='--timeoutscript=${{ env.QA_TIMEOUT_PER_TEST_LINUX }}'"
echo "========================================="
echo "-- QA ${{ matrix.os }}_${{ matrix.precision }} --"
echo "-- $cmd --"
echo "========================================="
eval $cmd
res=$?
# Getting failed test
nbtestsfailed=$(grep "# Runs Failed\s*:" QA.summary | tail -n 1 | awk -F' ' '{print $5}')
# Checking if no test has run at all (maybe exec errors)
nbtestsok=$(grep "# Runs Successful\s*:" QA.summary | tail -n 1 | awk -F' ' '{print $5}')
if [ $res = 0 ] && [ $nbtestsfailed = 0 ] && [ $nbtestsok -gt 0 ]
then
# Set correct end of step status (if not an email will be sent)
echo "STATUS_QA=1" >> $GITHUB_ENV
fi
- name: Managing step execution
if: ${{ always() }}
run: |
MAILMSG="Some error(s) has(ve) been raised during workflow execution:\n\n"
echo -e "\n#### STATUS_STEP_QA ###"
if [ "$STATUS_QA" = 0 ]
then
echo -e "Status\t[ \033[31;2;1mFAILED\033[0m ]"
MAILMSG+="The QA ${{ matrix.os }}-${{ matrix.precision }} has failed \n"
# Send email
# Close the branch
echo "CLOSE_BRANCH=1" >> $GITHUB_ENV
# Setting SMTP server (docker host)
DOCKER_HOST=`/sbin/ip route|awk '/default/ { print $3 }'`
echo "set smtp=smtp://${DOCKER_HOST}:25" >> /etc/mail.rc
# Print message in log
echo -e $MAILMSG
# Send email
echo -e "$MAILMSG\nThe branch is closed" | Mail -r $FROM_EMAIL -s "Error in Github CI repo ${{ github.repository }} (${{github.sha}})" $TO_EMAIL
# Exit fail to see it as a failure
exit 1
else
echo -e "Status\t[ \033[32;2;1mOK\033[0m ]"
fi
# Close the branch (= restrict push to team devopsadmins) if needed
# Owner is not mandatory here ... PAT is sufficient ??? seems that as servbot has permissions on this repo so his PAT is sufficient ...
- uses: octokit/request-action@v2.x
id: close_branch_qa
env:
GITHUB_TOKEN: ${{ env.SERVBOT_PAT }}
REQUEST_BODY: "['${{ env.TEAM_RESTRICTIVE_CLOSED_BRANCH}}']"
with:
route: PUT /repos/${{ github.repository }}/branches/main/protection/restrictions/teams
data: ${{ env.REQUEST_BODY }}
if: ${{ always() && env.CLOSE_BRANCH == 1 }}
# It the closing went wrong we send an email
- name: "Check result of closing branch and warn if it fails"
run: |
# No need to configure SMTP server, already done in previous steps
MAILMSG="Some error(s) has(ve) been raised during workflow execution:\n\n"
MAILMSG+="A branch closing is needed but has failed\n\n"
MAILMSG+="Return status API is : ${{ steps.close_branch_qa.outputs.status }}\n\n"
MAILMSG+="Check more detailed datas in CI logs\n"
# Print message in log
echo -e $MAILMSG
echo -e "\nClose return data API is : ${{ steps.close_branch_qa.outputs.data }}"
# Send email
echo -e "$MAILMSG" | Mail -r $FROM_EMAIL -s "Error in Github CI repo ${{ github.repository }} (${{github.sha}}) on closing branch" $TO_EMAIL
# Exit fail to see it as a failure
exit 1
if: ${{ always() && env.CLOSE_BRANCH == 1 && steps.close_branch_qa.outputs.status != 200 }}
build_windows_no_container:
if: ${{ github.repository_owner == 'OpenRadioss' }}
runs-on: ["${{ matrix.build }}","prmerge_ci"]
env:
BUILD_NB_THREAD: 2
STATUS_BUILD: 0
SERVBOT_PAT: ${{ secrets.SERVBOT_PAT }}
CLOSE_BRANCH: 0
strategy:
# If one job fails others are canceled
fail-fast: true
matrix:
include:
- build: starter_win64
precision: dp
os: win64
binary: starter
- build: starter_win64_sp
precision: sp
os: win64
binary: starter
- build: engine_win64_impi
precision: dp
os: win64
binary: engine
mpi: impi
- build: engine_win64_impi_sp
precision: sp
os: win64
binary: engine
mpi: impi
- build: engine_win64
precision: dp
os: win64
binary: engine
- build: engine_win64_sp
precision: sp
os: win64
binary: engine
steps:
# Set the working dir suffixed with branch name
- name: Set workdir
run: |
if ([string]::IsNullOrEmpty($env:GITHUB_BASE_REF)) {
Add-Content -Path $env:GITHUB_ENV -Value "WORKDIR=$env:GITHUB_REF_NAME"
}
else {
Add-Content -Path $env:GITHUB_ENV -Value "WORKDIR=$env:GITHUB_BASE_REF"
}
- name: Create branch oriented WS directory & integration WS (WIN64)
run: |
$dir2create = "$env:WORKDIR"
if (-not (Test-Path -Path $dir2create)) {
New-Item -Path $dir2create -ItemType "Directory"
}
- name: Clean local exe dir
working-directory: ${{ env.WORKDIR }}
run: |
$dir2remove = "exec"
if (Test-Path -Path $dir2remove) {
Remove-Item -Path $dir2remove -Recurse -Force
}
# Get last git modifications, don't clean before (way to keep persistent obj files)
- name: Checkout git sources
uses: actions/checkout@v4
with:
path: ${{ env.WORKDIR }}
clean: 'false'
lfs: 'true'
- name: Running builds
working-directory: ${{ env.WORKDIR }}
run: |
cd ${{ matrix.binary }}
@"
@echo off
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 vs2019
cmake --version
ninja --version
if not '${{ matrix.mpi }}'=='' (
set mpi_opts=-mpi=${{ matrix.mpi }}
)
echo =========================================
echo -- BUILD ${{ matrix.build }} --
echo =========================================
.\build_windows.bat -release -arch=${{ matrix.os }} -prec=${{ matrix.precision }} -nt=$env:BUILD_NB_THREAD %mpi_opts%
"@ -replace "'", '"' | Out-File -FilePath myrun.bat -Encoding ASCII
cmd /c .\myrun.bat
cd ..
$directoryPath = "exec"
if (Test-Path -Path $directoryPath) {
$files = Get-ChildItem -Path $directoryPath
if ($files.Count -eq 0) {
Write-Output "The directory is empty."
exit 1
} else {
# Display the contents of the directory
$files | ForEach-Object { Write-Output $_.FullName }
}
} else {
Write-Output "The directory does not exist."
exit 1
}
Add-Content -Path $env:GITHUB_ENV -Value "STATUS_BUILD=1"
- name: Managing step execution
if: ${{ always() }}
run: |
$MAILMSG = "Some error(s) has(ve) been raised during workflow execution:`r`n`r`n"
Write-Output "`r`n#### STATUS_STEP_BUILD ${{ matrix.build }} ($env:STATUS_BUILD) ###"
if ($env:STATUS_BUILD -eq 0) {
Write-Output "Status`t[ $([char]27)[31;2;1mFAILED$([char]27)[0m ]"
$MAILMSG += "The build ${{ matrix.build }} has failed `r`n"
Add-Content -Path $env:GITHUB_ENV -Value "CLOSE_BRANCH=1"
Send-MailMessage -SmtpServer $env:MAIL_RELAY -From $env:FROM_EMAIL -To $env:TO_EMAIL -Subject "Error in Github CI repo ${{ github.repository }} (${{github.sha}})" -Body $MAILMSG -Port 25
exit 1
}
else {
Write-Output "Status`t[ $([char]27)[32;2;1mOK$([char]27)[0m ]"
}
# Upload artifact (since V4 we can't upload artifact using the same name, each one must be unique)
- name: Upload built artifacts
uses: actions/upload-artifact@v4
with:
name: bins-${{ matrix.os }}-${{ matrix.precision }}-${{ matrix.build }}
path: ${{ env.WORKDIR }}/exec
if: ${{ env.CLOSE_BRANCH == 0 }}
# Close the branch (= restrict push to team devopsadmins) if needed
# Owner is not mandatory here ... PAT is sufficient ??? seems that as servbot has permissions on this repo so his PAT is sufficient ...
- name: Close the branch if errors
uses: octokit/request-action@v2.x
id: close_branch_build
env:
GITHUB_TOKEN: ${{ env.SERVBOT_PAT }}
REQUEST_BODY: "['${{ env.TEAM_RESTRICTIVE_CLOSED_BRANCH}}']"
with:
route: PUT /repos/${{ github.repository }}/branches/main/protection/restrictions/teams
data: ${{ env.REQUEST_BODY }}
if: ${{ always() && env.CLOSE_BRANCH == 1 }}
# If the closing went wrong we send an email
- name: "Check result of closing branch and warn if it fails"
run: |
$MAILMSG = "Some error(s) has(ve) been raised during workflow execution:`r`n`r`n"
$MAILMSG += "A branch closing is needed but has failed`r`n`r`n"
$MAILMSG += "Return status API is : ${{ steps.close_branch_build.outputs.status }}`r`n`r`n"
$MAILMSG += "Check more detailed datas in CI logs`r`n"
Write-Output "`r`nClose return API is : ${{ steps.close_branch_build.outputs.status }} / ${{ steps.close_branch_build.outputs.data }}";
Send-MailMessage -SmtpServer $env:MAIL_RELAY -From $env:FROM_EMAIL -To $env:TO_EMAIL -Subject "Error in Github CI repo ${{ github.repository }} (${{github.sha}}) on closing branch" -Body $MAILMSG -Port 25
exit 1
if: ${{ always() && env.CLOSE_BRANCH == 1 && steps.close_branch_build.outputs.status != 200 }}
qa_windows_no_container:
needs: build_windows_no_container
runs-on: ["qa_${{ matrix.os }}","prmerge_ci"]
env:
hm_reader_extlib: ../../extlib/hm_reader
hm_reader_cfgfiles: ../../hm_cfg_files
oneapi_exlib: ../../EXTRA/win64/extlib/intelOneAPI_runtime
mpi: impi
STATUS_QA: 0
SERVBOT_PAT: ${{ secrets.SERVBOT_PAT }}
# DEV ONLY # QA_NB_PROC: 2
QA_NB_PROC: 4
QA_NB_THREAD: 2
strategy:
# If one job fails others continue
fail-fast: false
matrix:
os: [win64]
# precision: [dp,sp]
precision: [dp]
steps:
# Get git related to the commit
- name: Checkout git sources
uses: actions/checkout@v4
with:
lfs: 'true'
# Get OpenRadioss extras from dedicated repository
- name: Checkout git EXTRA sources
uses: actions/checkout@v4
with:
lfs: 'true'
clean: 'false'
repository: '${{ secrets.EXTRA_REPOSITORY }}'
path: 'EXTRA'
token: '${{ secrets.EXTRA_REPOSITORY_PAT }}'
- name: Clean local exe dir
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
cd %cd:\=/%;
rm -rf exec;
"
# Download artifacts (since V4 we must download all needed artifacts, we could do it using wildcard but it doesn't work ... see https://github.com/actions/download-artifact/issues/337)
# Using hard name waiting for this issue to be fixed
# - name: Download artifacts
# uses: actions/download-artifact@v4
# with:
# name: bins-${{ matrix.os }}-${{ matrix.precision }}-*
# path: exec
# merge-multiple: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
# name: "bins-${{ matrix.os }}-${{ matrix.precision }}-*"
name: bins-${{ matrix.os }}-${{ matrix.precision }}-starter_win64
path: exec
merge-multiple: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
# name: "bins-${{ matrix.os }}-${{ matrix.precision }}-*"
name: bins-${{ matrix.os }}-${{ matrix.precision }}-engine_win64_impi
path: exec
merge-multiple: true
- name: Running qa
# Running cygwin from powershell or cmd => neither identation nor comment !
shell: cmd
run: >
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 vs2019 && C:\cygwin64\bin\bash --login -c "
cd %cd:\=/%;
md5sum exec/* || echo \"Nothing in exec/\";
if [ \"${{ matrix.precision }}\" = \"dp\" ];
then
precision_ext='';
else
precision_ext=\"_${{ matrix.precision }}\";
fi;
/cygdrive/c/mybin/clean_win10.pl;
cd qa-tests/scripts;
rm -f QA.summary;
export PATH=${{ env.hm_reader_extlib }}/${{ matrix.os }}:$PATH;
export PATH=${{ env.oneapi_exlib }}/${{ matrix.os }}:$PATH;
cmd=\"./or_qa_script ../../exec/engine_${{ matrix.os }}_${{ env.mpi }}${precision_ext} 1.0 --env:RAD_CFG_PATH=${{ env.hm_reader_cfgfiles }} --system_run --env:KMP_STACKSIZE=400m --exec_script_args='mpiexec -np ${{ env.QA_NB_PROC }}' --env:OMP_NUM_THREADS=${{ env.QA_NB_THREAD }} --output_failures_stdout --xtra_args='--timeoutscript=${{ env.QA_TIMEOUT_PER_TEST_WIN }}' \";
echo \"=========================================\";
echo \"-- QA ${{ matrix.os }}_${{ matrix.precision }} --\";
echo \"-- $cmd --\";
echo \"=========================================\";
eval $cmd || exit 1;
res=$?;
nbtestsfailed=$(grep \"# Runs Failed\s*:\" QA.summary | tail -n 1 | awk -F' ' '{print $5}');
nbtestsok=$(grep \"# Runs Successful\s*:\" QA.summary | tail -n 1 | awk -F' ' '{print $5}');
if [ $res = 0 ] && [ $nbtestsfailed = 0 ] && [ $nbtestsok -gt 0 ];
then
echo \"STATUS_QA=1\" >> $GITHUB_ENV;
fi;
"
- name: Managing step execution
if: ${{ always() }}
# Running cygwin from powershell or cmd => neither identation nor comment !
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
MAILMSG=\"Some error(s) has(ve) been raised during workflow execution:\n\n\";
echo -e \"\n#### STATUS_STEP_QA ###\";
if [ ${{ env.STATUS_QA }} = 0 ];
then
echo -e \"Status\t[ \033[31;2;1mFAILED\033[0m ]\";
MAILMSG+=\"The QA ${{ matrix.os }}-${{ matrix.precision }} has failed \n\";
echo \"CLOSE_BRANCH=1\" >> $GITHUB_ENV;
echo -e $MAILMSG;
echo -e \"$MAILMSG\nThe branch is closed\" | Email -f $FROM_EMAIL -s \"Error in Github CI repo ${{ github.repository }} (${{github.sha}})\" -r $MAIL_RELAY $TO_EMAIL;
exit 1;
else
echo -e \"Status\t[ \033[32;2;1mOK\033[0m ]\";
fi;
"
# Close the branch (= restrict push to team devopsadmins) if needed
# Owner is not mandatory here ... PAT is sufficient ??? seems that as servbot has permissions on this repo so his PAT is sufficient ...
- uses: octokit/request-action@v2.x
id: close_branch_qa
env:
GITHUB_TOKEN: ${{ env.SERVBOT_PAT }}
REQUEST_BODY: "['${{ env.TEAM_RESTRICTIVE_CLOSED_BRANCH}}']"
with:
route: PUT /repos/${{ github.repository }}/branches/main/protection/restrictions/teams
data: ${{ env.REQUEST_BODY }}
if: ${{ always() && env.CLOSE_BRANCH == 1 }}
# If the closing went wrong we send an email
- name: "Check result of closing branch and warn if it fails"
# Running cygwin from powershell or cmd => neither identation nor comment !
shell: cmd
run: >
call C:\cygwin64\bin\bash --login -c "
MAILMSG=\"Some error(s) has(ve) been raised during workflow execution:\n\n\";
MAILMSG+=\"A branch closing is needed but has failed\n\n\";
MAILMSG+=\"Return status API is : ${{ steps.close_branch_qa.outputs.status }}\n\n\";
MAILMSG+=\"Check more detailed datas in CI logs\n\";
echo -e $MAILMSG;
echo -e \"\nClose return data API is : ${{ steps.close_branch_qa.outputs.data }}\";
echo -e \"$MAILMSG\" | Email -f $FROM_EMAIL -s \"Error in Github CI repo ${{ github.repository }} (${{github.sha}}) on closing branch\" -r $MAIL_RELAY $TO_EMAIL;
exit 1;
"
if: ${{ always() && env.CLOSE_BRANCH == 1 && steps.close_branch_qa.outputs.status != 200 }}
# Call the sync CI if build and qa are OK
# Secrets variables must be passed
call-workflow-sync-git2perforce:
needs: [qa_linux,qa_windows_no_container]
uses: ./.github/workflows/prmerge_ci_sync.yml
secrets:
DOCKER_REGISTRY_USER: ${{secrets.DOCKER_REGISTRY_USER}}
DOCKER_REGISTRY_PASSWD: ${{secrets.DOCKER_REGISTRY_PASSWD}}
SERVBOT_PAT: ${{ secrets.SERVBOT_PAT }}
FROM_EMAIL: ${{ secrets.FROM_EMAIL }}
TO_EMAIL: ${{ secrets.TO_EMAIL }}
GITLAB_PAT: "${{ secrets.GITLAB_PAT }}"
GITLAB_REPO_URL: "${{ secrets.GITLAB_REPO_URL }}"
GITLAB_SERVBOT_USER: ${{ secrets.GITLAB_SERVBOT_USER }}
GITLAB_SERVBOT_EMAIL: ${{ secrets.GITLAB_SERVBOT_EMAIL }}
update_counters:
# DEV ONLY # runs-on: dev_delivery
# runs-on: dev_delivery
if: ${{ github.repository_owner == 'OpenRadioss' }}
runs-on: delivery
container:
image: fr-qafactorydev.europe.altair.com/common-linux64
credentials:
username: ${{secrets.DOCKER_REGISTRY_USER}}
password: ${{secrets.DOCKER_REGISTRY_PASSWD}}
volumes:
- /etc/localtime:/etc/localtime:ro
# DEV ONLY # - /github_download_counter_dev:/github_download_counter
- /github_download_counter:/github_download_counter
env:
SERVBOT_USER: ${{ secrets.SERVBOT_USER }}
SERVBOT_PAT: ${{ secrets.SERVBOT_PAT }}
steps:
- name: Set variables
run: |
echo "DATEOFTHEDAY=`date +'%Y%m%d'`" >> $GITHUB_ENV
- name: Counter Download - Update values
run: |
cd /github_download_counter
# Do some before using some lock and retry stuff
cp download_count.json sav-merge-main-${{ env.DATEOFTHEDAY }}-download_count.json
github_download_count.py \
--git_api_url ${{ github.api_url }} \
--git_repo ${{ github.repository }} \
--git_user $SERVBOT_USER \
--git_token $SERVBOT_PAT \
--action update_values