@@ -28,6 +28,7 @@ ddp="$HOME/Library/Developer/Xcode/DerivedData"
28
28
xp=" "
29
29
files=" "
30
30
save_to=" "
31
+ direct_file_upload=" "
31
32
cacert=" $CODECOV_CA_BUNDLE "
32
33
gcov_ignore=" -not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**'"
33
34
gcov_include=" "
@@ -146,6 +147,9 @@ cat << EOF
146
147
-F ui,chrome This upload is Chrome - UI tests
147
148
148
149
-c Move discovered coverage reports to the trash
150
+ -z FILE Upload specified file directly to Codecov and bypass all report generation.
151
+ This is inteded to be used only with a pre-formatted Codecov report and is not
152
+ expected to work under any other circumstances.
149
153
-Z Exit with 1 if not successful. Default will Exit with 0
150
154
151
155
-- xcode --
@@ -248,10 +252,9 @@ parse_yaml() {
248
252
}'
249
253
}
250
254
251
-
252
255
if [ $# != 0 ];
253
256
then
254
- while getopts " a:A:b:B:cC:dD:e:f:F:g:G:hJ:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:ZN :-" o
257
+ while getopts " a:A:b:B:cC:dD:e:f:F:g:G:hJ:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:Zz:N :-" o
255
258
do
256
259
codecov_flags+=( " $o " )
257
260
case " $o " in
@@ -451,6 +454,17 @@ $OPTARG"
451
454
" Z" )
452
455
exit_with=1
453
456
;;
457
+ " z" )
458
+ direct_file_upload=" $OPTARG "
459
+ ft_gcov=" 0"
460
+ ft_coveragepy=" 0"
461
+ ft_fix=" 0"
462
+ ft_search=" 0"
463
+ ft_network=" 0"
464
+ ft_xcodellvm=" 0"
465
+ ft_gcovout=" 0"
466
+ include_cov=" "
467
+ ;;
454
468
* )
455
469
echo -e " ${r} Unexpected flag not supported${x} "
456
470
;;
@@ -471,16 +485,19 @@ say "
471
485
472
486
# check for installed tools
473
487
# git/hg
474
- if [ -x " $( command -v git ) " ];
488
+ if [ " $direct_file_upload " = " " ];
475
489
then
476
- say " $b ==>$x $( git --version) found"
477
- else
478
- say " $y ==>$x git not installed, testing for mercurial"
479
- if [ -x " $( command -v hg) " ];
490
+ if [ -x " $( command -v git) " ];
480
491
then
481
- say " $b ==>$x $( hg --version) found"
492
+ say " $b ==>$x $( git --version) found"
482
493
else
483
- say " $r ==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences"
494
+ say " $y ==>$x git not installed, testing for mercurial"
495
+ if [ -x " $( command -v hg) " ];
496
+ then
497
+ say " $b ==>$x $( hg --version) found"
498
+ else
499
+ say " $r ==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences"
500
+ fi
484
501
fi
485
502
fi
486
503
# curl
@@ -1373,6 +1390,9 @@ $PWD/coverage.xml"
1373
1390
elif [ " $include_cov " != " " ];
1374
1391
then
1375
1392
files=$( eval " find $search_in -type f \( ${include_cov: 5} \)$exclude_cov 2>/dev/null" || echo ' ' )
1393
+ elif [ " $direct_file_upload " != " " ];
1394
+ then
1395
+ files=$direct_file_upload
1376
1396
fi
1377
1397
1378
1398
num_of_files=$( echo " $files " | wc -l | tr -d ' ' )
@@ -1442,6 +1462,7 @@ cleanup() {
1442
1462
1443
1463
trap cleanup INT ABRT TERM
1444
1464
1465
+
1445
1466
if [ " $env " != " " ];
1446
1467
then
1447
1468
inc_env=" "
@@ -1455,13 +1476,16 @@ then
1455
1476
"
1456
1477
fi
1457
1478
done
1458
-
1459
- echo " $inc_env <<<<<< ENV" >> " $upload_file "
1479
+ echo " $inc_env <<<<<< ENV" >> " $upload_file "
1460
1480
fi
1461
1481
1462
1482
# Append git file list
1463
1483
# write discovered yaml location
1464
- echo " $yaml " >> " $upload_file "
1484
+ if [ " $direct_file_upload " = " " ];
1485
+ then
1486
+ echo " $yaml " >> " $upload_file "
1487
+ fi
1488
+
1465
1489
if [ " $ft_network " == " 1" ];
1466
1490
then
1467
1491
i=" woff|eot|otf" # fonts
@@ -1473,70 +1497,78 @@ then
1473
1497
then
1474
1498
i=" $i |html"
1475
1499
fi
1476
-
1477
1500
echo " $network " | grep -vwE " ($i )$" >> " $upload_file "
1478
1501
fi
1479
1502
echo " <<<<<< network" >> " $upload_file "
1480
1503
1481
- fr=0
1482
- say " ${e} ==> ${x} Reading reports "
1483
- while IFS= ' ' read -r file ;
1484
- do
1485
- # read the coverage file
1486
- if [ " $( echo " $file " | tr -d ' ' ) " != ' ' ] ;
1487
- then
1488
- if [ -f " $file " ];
1504
+ if [ " $direct_file_upload " = " " ] ;
1505
+ then
1506
+ fr=0
1507
+ say " ${e} ==> ${x} Reading reports "
1508
+ while IFS= ' ' read -r file;
1509
+ do
1510
+ # read the coverage file
1511
+ if [ " $( echo " $file " | tr -d ' ' ) " != ' ' ];
1489
1512
then
1490
- report_len=$( wc -c < " $file " )
1491
- if [ " $report_len " -ne 0 ];
1513
+ if [ -f " $file " ];
1492
1514
then
1493
- say " ${g} +${x} $file ${e} bytes=$( echo " $report_len " | tr -d ' ' ) ${x} "
1494
- # append to to upload
1495
- _filename=$( basename " $file " )
1496
- if [ " ${_filename##* .} " = ' gcov' ];
1515
+ report_len=$( wc -c < " $file " )
1516
+ if [ " $report_len " -ne 0 ];
1497
1517
then
1498
- {
1499
- echo " # path=$( echo " $file .reduced" | sed " s|^$git_root /||" ) " ;
1500
- # get file name
1501
- head -1 " $file " ;
1502
- } >> " $upload_file "
1503
- # 1. remove source code
1504
- # 2. remove ending bracket lines
1505
- # 3. remove whitespace
1506
- # 4. remove contextual lines
1507
- # 5. remove function names
1508
- awk -F' : *' ' {print $1":"$2":"}' " $file " \
1509
- | sed ' \/: *} *$/d' \
1510
- | sed ' s/^ *//' \
1511
- | sed ' /^-/d' \
1512
- | sed ' s/^function.*/func/' >> " $upload_file "
1518
+ say " ${g} +${x} $file ${e} bytes=$( echo " $report_len " | tr -d ' ' ) ${x} "
1519
+ # append to to upload
1520
+ _filename=$( basename " $file " )
1521
+ if [ " ${_filename##* .} " = ' gcov' ];
1522
+ then
1523
+ {
1524
+ echo " # path=$( echo " $file .reduced" | sed " s|^$git_root /||" ) " ;
1525
+ # get file name
1526
+ head -1 " $file " ;
1527
+ } >> " $upload_file "
1528
+ # 1. remove source code
1529
+ # 2. remove ending bracket lines
1530
+ # 3. remove whitespace
1531
+ # 4. remove contextual lines
1532
+ # 5. remove function names
1533
+ awk -F' : *' ' {print $1":"$2":"}' " $file " \
1534
+ | sed ' \/: *} *$/d' \
1535
+ | sed ' s/^ *//' \
1536
+ | sed ' /^-/d' \
1537
+ | sed ' s/^function.*/func/' >> " $upload_file "
1538
+ else
1539
+ {
1540
+ echo " # path=${file// ^$git_root / ||} " ;
1541
+ cat " $file " ;
1542
+ } >> " $upload_file "
1543
+ fi
1544
+ echo " <<<<<< EOF" >> " $upload_file "
1545
+ fr=1
1546
+ if [ " $clean " = " 1" ];
1547
+ then
1548
+ rm " $file "
1549
+ fi
1513
1550
else
1514
- {
1515
- echo " # path=${file// ^$git_root / ||} " ;
1516
- cat " $file " ;
1517
- } >> " $upload_file "
1518
- fi
1519
- echo " <<<<<< EOF" >> " $upload_file "
1520
- fr=1
1521
- if [ " $clean " = " 1" ];
1522
- then
1523
- rm " $file "
1551
+ say " ${r} -${x} Skipping empty file $file "
1524
1552
fi
1525
1553
else
1526
- say " ${r} -${x} Skipping empty file $file "
1554
+ say " ${r} -${x} file not found at $file "
1527
1555
fi
1528
- else
1529
- say " ${r} -${x} file not found at $file "
1530
1556
fi
1531
- fi
1532
- done <<< " $(echo -e " $files " )"
1557
+ done <<< " $(echo -e " $files " )"
1533
1558
1534
- if [ " $fr " = " 0" ];
1535
- then
1536
- say " ${r} -->${x} No coverage data found."
1537
- say " Please visit ${b} http://docs.codecov.io/docs/supported-languages${x} "
1538
- say " search for your projects language to learn how to collect reports."
1539
- exit ${exit_with} ;
1559
+ if [ " $fr " = " 0" ];
1560
+ then
1561
+ say " ${r} -->${x} No coverage data found."
1562
+ say " Please visit ${b} http://docs.codecov.io/docs/supported-languages${x} "
1563
+ say " search for your projects language to learn how to collect reports."
1564
+ exit ${exit_with} ;
1565
+ fi
1566
+ else
1567
+ cp " $direct_file_upload " " $upload_file "
1568
+ if [ " $clean " = " 1" ];
1569
+ then
1570
+ rm " $direct_file_upload "
1571
+ fi
1540
1572
fi
1541
1573
1542
1574
if [ " $ft_fix " = " 1" ];
@@ -1725,7 +1757,7 @@ else
1725
1757
if [ " $save_to " != " " ];
1726
1758
then
1727
1759
say " ${e} ==>${x} Copying upload file to ${save_to} "
1728
- mkdir --parents " $save_to "
1760
+ mkdir -p " $( dirname " $ save_to" ) "
1729
1761
cp " $upload_file " " $save_to "
1730
1762
fi
1731
1763
0 commit comments