@@ -452,6 +452,13 @@ def main(ctx):
452
452
),
453
453
)
454
454
455
+ test_pipelines .append (
456
+ pipelineDependsOn (
457
+ generateAndUploadCoverageReport (ctx ),
458
+ testPipelines (ctx ),
459
+ ),
460
+ )
461
+
455
462
pipelines = test_pipelines + build_release_pipelines
456
463
457
464
if ctx .build .event == "cron" :
@@ -1041,7 +1048,8 @@ def localApiTestPipeline(ctx):
1041
1048
((wopiCollaborationService ("fakeoffice" ) + wopiCollaborationService ("collabora" ) + wopiCollaborationService ("onlyoffice" )) if params ["collaborationServiceNeeded" ] else []) +
1042
1049
(ocisHealthCheck ("wopi" , ["wopi-collabora:9304" , "wopi-onlyoffice:9304" , "wopi-fakeoffice:9304" ]) if params ["collaborationServiceNeeded" ] else []) +
1043
1050
localApiTests (ctx , name , params ["suites" ], storage , params ["extraEnvironment" ], run_with_remote_php ) +
1044
- logRequests (),
1051
+ logRequests () +
1052
+ (generateCoverageReportFromTest (ctx , name )),
1045
1053
"services" : (emailService () if params ["emailNeeded" ] else []) +
1046
1054
(clamavService () if params ["antivirusNeeded" ] else []) +
1047
1055
((fakeOffice () + collaboraService () + onlyofficeService ()) if params ["collaborationServiceNeeded" ] else []),
@@ -1056,6 +1064,49 @@ def localApiTestPipeline(ctx):
1056
1064
pipelines .append (pipeline )
1057
1065
return pipelines
1058
1066
1067
+ def generateCoverageReportFromTest (ctx , name ):
1068
+ environment = {
1069
+ "GOCOVERDIR" : "reports" ,
1070
+ }
1071
+
1072
+ return [
1073
+ {
1074
+ "name" : "coverageReport-%s" % name ,
1075
+ "image" : OC_CI_GOLANG ,
1076
+ "environment" : environment ,
1077
+ "commands" : [
1078
+ "go tool covdata percent -i=$GOCOVERDIR -o=coverage-%s.out" % name ,
1079
+ ],
1080
+ },
1081
+ {
1082
+ "name" : "coverage-locate" ,
1083
+ "image" : OC_UBUNTU ,
1084
+ "commands" : [
1085
+ "mkdir -p cache/acceptance/coverage/" ,
1086
+ "mv coverage-%s.out cache/acceptance/coverage/" % name ,
1087
+ ],
1088
+ },
1089
+ {
1090
+ "name" : "coverage-cache-1" ,
1091
+ "image" : PLUGINS_S3 ,
1092
+ "settings" : {
1093
+ "endpoint" : {
1094
+ "from_secret" : "cache_s3_server" ,
1095
+ },
1096
+ "bucket" : "cache" ,
1097
+ "source" : "cache/acceptance/coverage/coverage-%s.out" % name ,
1098
+ "target" : "%s/%s/coverage" % (ctx .repo .slug , ctx .build .commit + "-${DRONE_BUILD_NUMBER}" ),
1099
+ "path_style" : True ,
1100
+ "access_key" : {
1101
+ "from_secret" : "cache_s3_access_key" ,
1102
+ },
1103
+ "secret_key" : {
1104
+ "from_secret" : "cache_s3_secret_key" ,
1105
+ },
1106
+ },
1107
+ },
1108
+ ]
1109
+
1059
1110
def localApiTests (ctx , name , suites , storage = "ocis" , extra_environment = {}, with_remote_php = False ):
1060
1111
test_dir = "%s/tests/acceptance" % dirs ["base" ]
1061
1112
expected_failures_file = "%s/expected-failures-localAPI-on-%s-storage.md" % (test_dir , storage .upper ())
@@ -1137,7 +1188,7 @@ def wopiValidatorTests(ctx, storage, wopiServerType, accounts_hash_difficulty =
1137
1188
"RenameFileIfCreateChildFileIsNotSupported" ,
1138
1189
]
1139
1190
1140
- ocis_bin = "ocis/bin/ocis"
1191
+ ocis_bin = "ocis/bin/ocis-debug "
1141
1192
validatorTests = []
1142
1193
wopiServer = []
1143
1194
extra_server_environment = {}
@@ -1280,7 +1331,8 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, with_remote_php = Fa
1280
1331
],
1281
1332
},
1282
1333
] +
1283
- logRequests (),
1334
+ logRequests () +
1335
+ generateCoverageReportFromTest (ctx , part_number ),
1284
1336
"services" : redisForOCStorage (storage ),
1285
1337
"depends_on" : getPipelineNames (buildOcisBinaryForTesting (ctx )),
1286
1338
"trigger" : {
@@ -2407,6 +2459,7 @@ def ocisServer(storage = "ocis", accounts_hash_difficulty = 4, volumes = [], dep
2407
2459
"WEB_DEBUG_ADDR" : "0.0.0.0:9104" ,
2408
2460
"WEBDAV_DEBUG_ADDR" : "0.0.0.0:9119" ,
2409
2461
"WEBFINGER_DEBUG_ADDR" : "0.0.0.0:9279" ,
2462
+ "GOCOVERDIR" : "reports" ,
2410
2463
}
2411
2464
2412
2465
if deploy_type == "" :
@@ -2450,7 +2503,7 @@ def ocisServer(storage = "ocis", accounts_hash_difficulty = 4, volumes = [], dep
2450
2503
for item in extra_server_environment :
2451
2504
environment [item ] = extra_server_environment [item ]
2452
2505
2453
- ocis_bin = "ocis/bin/ocis"
2506
+ ocis_bin = "ocis/bin/ocis-debug "
2454
2507
2455
2508
wrapper_commands = [
2456
2509
"make -C %s build" % dirs ["ocisWrapper" ],
@@ -2469,18 +2522,21 @@ def ocisServer(storage = "ocis", accounts_hash_difficulty = 4, volumes = [], dep
2469
2522
"depends_on" : depends_on ,
2470
2523
}
2471
2524
2525
+ commands = [
2526
+ "mkdir -p $GOCOVERDIR" ,
2527
+ "%s init --insecure true" % ocis_bin ,
2528
+ "cat $OCIS_CONFIG_DIR/ocis.yaml" ,
2529
+ "cp tests/config/drone/app-registry.yaml /root/.ocis/config/app-registry.yaml" ,
2530
+ ] + (wrapper_commands )
2531
+
2472
2532
return [
2473
2533
{
2474
2534
"name" : container_name ,
2475
2535
"image" : OC_CI_GOLANG ,
2476
2536
"detach" : True ,
2477
2537
"environment" : environment ,
2478
2538
"user" : user ,
2479
- "commands" : [
2480
- "%s init --insecure true" % ocis_bin ,
2481
- "cat $OCIS_CONFIG_DIR/ocis.yaml" ,
2482
- "cp tests/config/drone/app-registry.yaml /root/.ocis/config/app-registry.yaml" ,
2483
- ] + (wrapper_commands ),
2539
+ "commands" : commands ,
2484
2540
"volumes" : volumes ,
2485
2541
"depends_on" : depends_on ,
2486
2542
},
@@ -2513,7 +2569,7 @@ def startOcisService(service = None, name = None, environment = {}, volumes = []
2513
2569
"detach" : True ,
2514
2570
"environment" : environment ,
2515
2571
"commands" : [
2516
- "ocis/bin/ocis %s server" % service ,
2572
+ "ocis/bin/ocis-debug %s server" % service ,
2517
2573
],
2518
2574
"volumes" : volumes ,
2519
2575
},
@@ -2539,7 +2595,7 @@ def build():
2539
2595
"name" : "build" ,
2540
2596
"image" : OC_CI_GOLANG ,
2541
2597
"commands" : [
2542
- "retry -t 3 'make -C ocis build'" ,
2598
+ "retry -t 3 'make -C ocis build-debug '" ,
2543
2599
],
2544
2600
"environment" : DRONE_HTTP_PROXY_ENV ,
2545
2601
"volumes" : [stepVolumeGo ],
@@ -2744,6 +2800,75 @@ def genericCache(name, action, mounts, cache_path):
2744
2800
}
2745
2801
return step
2746
2802
2803
+ def generateAndUploadCoverageReport (ctx ):
2804
+ cache_path = "%s/%s/%s" % ("cache" , ctx .repo .slug , ctx .build .commit + "-${DRONE_BUILD_NUMBER}" )
2805
+
2806
+ sonar_env = {
2807
+ "SONAR_TOKEN" : {
2808
+ "from_secret" : "sonarcloud_acceptance_tests" ,
2809
+ },
2810
+ }
2811
+
2812
+ if ctx .build .event == "pull_request" :
2813
+ sonar_env .update ({
2814
+ "SONAR_PULL_REQUEST_BASE" : "%s" % (ctx .build .target ),
2815
+ "SONAR_PULL_REQUEST_BRANCH" : "%s" % (ctx .build .source ),
2816
+ "SONAR_PULL_REQUEST_KEY" : "%s" % (ctx .build .ref .replace ("refs/pull/" , "" ).split ("/" )[0 ]),
2817
+ })
2818
+
2819
+ return {
2820
+ "kind" : "pipeline" ,
2821
+ "type" : "docker" ,
2822
+ "name" : "sonarcloud" ,
2823
+ "platform" : {
2824
+ "os" : "linux" ,
2825
+ "arch" : "amd64" ,
2826
+ },
2827
+ "steps" : [
2828
+ {
2829
+ "name" : "sync-from-cache" ,
2830
+ "image" : MINIO_MC ,
2831
+ "environment" : MINIO_MC_ENV ,
2832
+ "commands" : [
2833
+ "mkdir -p results" ,
2834
+ "mc alias set cache $MC_HOST $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY" ,
2835
+ "mc mirror cache/$CACHE_BUCKET/%s/%s/coverage results/" % (ctx .repo .slug , ctx .build .commit + "-${DRONE_BUILD_NUMBER}" ),
2836
+ ],
2837
+ },
2838
+ {
2839
+ "name" : "sonarcloud-properties" ,
2840
+ "image" : OC_UBUNTU ,
2841
+ "commands" : [
2842
+ "mv sonar-project.properties sonar-project.properties.skip" ,
2843
+ "mv tests/acceptance/sonar-project.properties sonar-project.properties" ,
2844
+ ],
2845
+ },
2846
+ {
2847
+ "name" : "sonarcloud" ,
2848
+ "image" : SONARSOURCE_SONAR_SCANNER_CLI ,
2849
+ "environment" : sonar_env ,
2850
+ },
2851
+ {
2852
+ "name" : "purge-cache" ,
2853
+ "image" : MINIO_MC ,
2854
+ "environment" : MINIO_MC_ENV ,
2855
+ "commands" : [
2856
+ "mc alias set cache $MC_HOST $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY" ,
2857
+ "mc rm --recursive --force cache/$CACHE_BUCKET/%s/%s" % (ctx .repo .slug , ctx .build .commit + "-${DRONE_BUILD_NUMBER}" ),
2858
+ ],
2859
+ },
2860
+ ],
2861
+ "trigger" : {
2862
+ "ref" : [
2863
+ "refs/heads/master" ,
2864
+ ],
2865
+ "status" : [
2866
+ "success" ,
2867
+ "failure" ,
2868
+ ],
2869
+ },
2870
+ }
2871
+
2747
2872
def genericCachePurge (flush_path ):
2748
2873
return {
2749
2874
"kind" : "pipeline" ,
0 commit comments