@@ -44,43 +44,44 @@ jobs:
44
44
echo ::set-output name=is_production::true
45
45
fi
46
46
scan-code-net :
47
- name : Sonar scan
48
- timeout-minutes : 20
47
+ name : Sonar Code
49
48
runs-on : ubuntu-latest-4-cores
49
+ timeout-minutes : 10
50
50
needs :
51
51
- version
52
- - docker-build-auth-service
53
- - docker-build-auth-test-unit
52
+ - build-and-run-integration-tests
53
+ - run-acceptance-tests
54
+ - run-api-test-integration
55
+ - run-auth-test-unit
54
56
steps :
55
- - name : Checkout repository
56
- uses : actions/checkout@v3
57
+ - uses : actions/checkout@v3
57
58
with :
58
59
fetch-depth : 0
59
60
- name : Set up Java 17
60
61
uses : actions/setup-java@v3
61
62
with :
62
63
java-version : 17
63
64
distribution : adopt
64
- - name : Add GitHub Packages to NuGet config
65
- env :
66
- GH_ACCOUNT : ${{ secrets.PAT_USER_READ_PACKAGES }}
67
- GH_TOKEN : ${{ secrets.PAT_READ_PACKAGES }}
65
+ - name : Setup Dotnet
66
+ uses : actions/setup-dotnet@v4
67
+ with :
68
+ dotnet-version : 6.x
69
+ - name : CoverGo Nuget
70
+ run : dotnet nuget update source github --username ${{ secrets.PAT_USER_READ_PACKAGES }} --password ${{ secrets.PAT_READ_PACKAGES }} --store-password-in-clear-text
71
+ - name : Download Coverage Artifacts
72
+ uses : actions/download-artifact@v4
73
+ with :
74
+ path : ./
75
+ - name : Fix coverage paths
68
76
run : |
69
- dotnet nuget update source github --username ${GH_ACCOUNT} --password ${GH_TOKEN} --store-password-in-clear-text
70
- - name : Scan
71
-
72
- with :
73
- test-result-artifacts : Unit tests results,Integration tests results,Acceptance tests results,Integration API tests results
74
- sonar-token : ${{ secrets.SONAR_TOKEN }}
75
- coverage-solution-root-path : /sln
76
- verbose : " true"
77
- dotnet-build-command : dotnet build -v q -nologo --configuration Release
78
- opencover-reports-paths : /**/*.opencover.test.xml
79
- vstest-reports-paths : /**/*.test.trx
80
- project-name : Auth Service
81
- coverage-artifact-pooling-timeout-sec : " 1200"
82
- env :
83
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
77
+ echo "Root directory: $GITHUB_WORKSPACE"
78
+ find . -name "*.opencover.xml" -exec sed -i -e "s@/app@$GITHUB_WORKSPACE@g" {} \;
79
+ - name : SonarCloud Scan
80
+ run : |
81
+ dotnet tool install --global dotnet-sonarscanner
82
+ dotnet sonarscanner begin /k:"${{ github.repository_owner }}_${{ github.event.repository.name }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /o:covergo /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
83
+ dotnet build --configuration Release
84
+ dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
84
85
scan-code :
85
86
name : Sonar scan
86
87
runs-on : ubuntu-latest
@@ -469,13 +470,48 @@ jobs:
469
470
!hep/**/.tmp
470
471
include-hidden-files : true
471
472
- name : Publish Unit tests results as check
472
- uses : docker://ghcr.io/enricomi/publish-unit-test-result-action:latest
473
473
if : always()
474
- with :
475
- report_individual_runs : " true"
476
- check_name : Unit tests check
477
- github_token : ${{ secrets.GITHUB_TOKEN }}
478
- files : ./TestResults/**/*.xml
474
+ env :
475
+ CHECK_NAME : Unit tests check
476
+ FILE_PATH : ./TestResults/**/*.xml
477
+ run : |
478
+ RETRY_COUNT=0
479
+ MAX_RETRIES=3
480
+ BACKOFF=10
481
+
482
+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
483
+ # Check GitHub Rate Limit
484
+ REMAINING=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq '.rate.remaining')
485
+ if [ "$REMAINING" -lt 100 ]; then
486
+ echo "API rate limit is too low: $REMAINING remaining requests. Retrying in $BACKOFF seconds..."
487
+ sleep $BACKOFF
488
+ BACKOFF=$((BACKOFF * 2))
489
+ RETRY_COUNT=$((RETRY_COUNT + 1))
490
+ continue
491
+ fi
492
+
493
+ # Publish test results as check
494
+ docker run --rm -v $PWD:/workspace -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} ghcr.io/enricomi/publish-unit-test-result-action \
495
+ --check_name "$CHECK_NAME" \
496
+ --report_individual_runs "true" \
497
+ --files "$FILE_PATH"
498
+
499
+ # Check if publishing succeeded
500
+ if [ $? -eq 0 ]; then
501
+ echo "Test results published successfully!"
502
+ break
503
+ else
504
+ echo "Failed to publish test results. Retrying in $BACKOFF seconds..."
505
+ sleep $BACKOFF
506
+ BACKOFF=$((BACKOFF * 2))
507
+ RETRY_COUNT=$((RETRY_COUNT + 1))
508
+ fi
509
+
510
+ if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
511
+ echo "Max retries reached. Failing the job."
512
+ exit 1
513
+ fi
514
+ done
479
515
build-and-run-integration-tests :
480
516
name : Build and run Integration tests
481
517
timeout-minutes : 20
@@ -586,13 +622,48 @@ jobs:
586
622
path : TestResults
587
623
include-hidden-files : true
588
624
- name : Publish Integration tests results as check
589
- uses : docker://ghcr.io/enricomi/publish-unit-test-result-action:latest
590
625
if : always()
591
- with :
592
- report_individual_runs : " true"
593
- check_name : Integration tests check
594
- github_token : ${{ secrets.GITHUB_TOKEN }}
595
- files : ./TestResults/**/*.xml
626
+ env :
627
+ CHECK_NAME : Integration tests check
628
+ FILE_PATH : ./TestResults/**/*.xml
629
+ run : |
630
+ RETRY_COUNT=0
631
+ MAX_RETRIES=3
632
+ BACKOFF=10
633
+
634
+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
635
+ # Check GitHub Rate Limit
636
+ REMAINING=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq '.rate.remaining')
637
+ if [ "$REMAINING" -lt 100 ]; then
638
+ echo "API rate limit is too low: $REMAINING remaining requests. Retrying in $BACKOFF seconds..."
639
+ sleep $BACKOFF
640
+ BACKOFF=$((BACKOFF * 2))
641
+ RETRY_COUNT=$((RETRY_COUNT + 1))
642
+ continue
643
+ fi
644
+
645
+ # Publish test results as check
646
+ docker run --rm -v $PWD:/workspace -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} ghcr.io/enricomi/publish-unit-test-result-action \
647
+ --check_name "$CHECK_NAME" \
648
+ --report_individual_runs "true" \
649
+ --files "$FILE_PATH"
650
+
651
+ # Check if publishing succeeded
652
+ if [ $? -eq 0 ]; then
653
+ echo "Test results published successfully!"
654
+ break
655
+ else
656
+ echo "Failed to publish test results. Retrying in $BACKOFF seconds..."
657
+ sleep $BACKOFF
658
+ BACKOFF=$((BACKOFF * 2))
659
+ RETRY_COUNT=$((RETRY_COUNT + 1))
660
+ fi
661
+
662
+ if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
663
+ echo "Max retries reached. Failing the job."
664
+ exit 1
665
+ fi
666
+ done
596
667
docker-build-acceptance-tests :
597
668
name : Build Acceptance tests image
598
669
timeout-minutes : 20
@@ -717,13 +788,48 @@ jobs:
717
788
path : TestResults
718
789
include-hidden-files : true
719
790
- name : Publish Acceptance tests results as check
720
- uses : docker://ghcr.io/enricomi/publish-unit-test-result-action:latest
721
791
if : always()
722
- with :
723
- report_individual_runs : " true"
724
- check_name : Acceptance tests check
725
- github_token : ${{ secrets.GITHUB_TOKEN }}
726
- files : ./TestResults/TestResultJUnit.xml
792
+ env :
793
+ CHECK_NAME : Acceptance tests check
794
+ FILE_PATH : ./TestResults/TestResultJUnit.xml
795
+ run : |
796
+ RETRY_COUNT=0
797
+ MAX_RETRIES=3
798
+ BACKOFF=10
799
+
800
+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
801
+ # Check GitHub Rate Limit
802
+ REMAINING=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq '.rate.remaining')
803
+ if [ "$REMAINING" -lt 100 ]; then
804
+ echo "API rate limit is too low: $REMAINING remaining requests. Retrying in $BACKOFF seconds..."
805
+ sleep $BACKOFF
806
+ BACKOFF=$((BACKOFF * 2))
807
+ RETRY_COUNT=$((RETRY_COUNT + 1))
808
+ continue
809
+ fi
810
+
811
+ # Publish test results as check
812
+ docker run --rm -v $PWD:/workspace -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} ghcr.io/enricomi/publish-unit-test-result-action \
813
+ --check_name "$CHECK_NAME" \
814
+ --report_individual_runs "true" \
815
+ --files "$FILE_PATH"
816
+
817
+ # Check if publishing succeeded
818
+ if [ $? -eq 0 ]; then
819
+ echo "Test results published successfully!"
820
+ break
821
+ else
822
+ echo "Failed to publish test results. Retrying in $BACKOFF seconds..."
823
+ sleep $BACKOFF
824
+ BACKOFF=$((BACKOFF * 2))
825
+ RETRY_COUNT=$((RETRY_COUNT + 1))
826
+ fi
827
+
828
+ if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
829
+ echo "Max retries reached. Failing the job."
830
+ exit 1
831
+ fi
832
+ done
727
833
- name : Upload Acceptance tests results to Behave.Pro
728
834
if : always()
729
835
env :
@@ -874,13 +980,48 @@ jobs:
874
980
path : abc
875
981
include-hidden-files : true
876
982
- name : Publish Integration API tests results as check
877
- uses : docker://ghcr.io/enricomi/publish-unit-test-result-action:latest
878
983
if : always()
879
- with :
880
- report_individual_runs : " true"
881
- check_name : Integration API tests check
882
- github_token : ${{ secrets.GITHUB_TOKEN }}
883
- files : ./TestResults/*.JUnit.xml
984
+ env :
985
+ CHECK_NAME : Integration API tests check
986
+ FILE_PATH : ./TestResults/*.JUnit.xml
987
+ run : |
988
+ RETRY_COUNT=0
989
+ MAX_RETRIES=3
990
+ BACKOFF=10
991
+
992
+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
993
+ # Check GitHub Rate Limit
994
+ REMAINING=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq '.rate.remaining')
995
+ if [ "$REMAINING" -lt 100 ]; then
996
+ echo "API rate limit is too low: $REMAINING remaining requests. Retrying in $BACKOFF seconds..."
997
+ sleep $BACKOFF
998
+ BACKOFF=$((BACKOFF * 2))
999
+ RETRY_COUNT=$((RETRY_COUNT + 1))
1000
+ continue
1001
+ fi
1002
+
1003
+ # Publish test results as check
1004
+ docker run --rm -v $PWD:/workspace -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} ghcr.io/enricomi/publish-unit-test-result-action \
1005
+ --check_name "$CHECK_NAME" \
1006
+ --report_individual_runs "true" \
1007
+ --files "$FILE_PATH"
1008
+
1009
+ # Check if publishing succeeded
1010
+ if [ $? -eq 0 ]; then
1011
+ echo "Test results published successfully!"
1012
+ break
1013
+ else
1014
+ echo "Failed to publish test results. Retrying in $BACKOFF seconds..."
1015
+ sleep $BACKOFF
1016
+ BACKOFF=$((BACKOFF * 2))
1017
+ RETRY_COUNT=$((RETRY_COUNT + 1))
1018
+ fi
1019
+
1020
+ if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
1021
+ echo "Max retries reached. Failing the job."
1022
+ exit 1
1023
+ fi
1024
+ done
884
1025
docker-publish-github-auth-service :
885
1026
name : Tag service image in GitHub
886
1027
timeout-minutes : 20
0 commit comments