github.com/prysmaticlabs/prysm@v1.4.4/scripts/codecov.sh (about) 1 #!/usr/bin/env bash 2 3 # Apache License Version 2.0, January 2004 4 # https://github.com/codecov/codecov-bash/blob/master/LICENSE 5 6 set -e +o pipefail 7 8 VERSION="1.0.2" 9 10 codecov_flags=( ) 11 url="https://codecov.io" 12 env="$CODECOV_ENV" 13 service="" 14 token="" 15 search_in="" 16 # shellcheck disable=SC2153 17 flags="$CODECOV_FLAGS" 18 exit_with=0 19 curlargs="" 20 curlawsargs="" 21 dump="0" 22 clean="0" 23 curl_s="-s" 24 name="$CODECOV_NAME" 25 include_cov="" 26 exclude_cov="" 27 ddp="$HOME/Library/Developer/Xcode/DerivedData" 28 xp="" 29 files="" 30 save_to="" 31 direct_file_upload="" 32 cacert="$CODECOV_CA_BUNDLE" 33 gcov_ignore="-not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**'" 34 gcov_include="" 35 36 ft_gcov="1" 37 ft_coveragepy="1" 38 ft_fix="1" 39 ft_search="1" 40 ft_s3="1" 41 ft_network="1" 42 ft_xcodellvm="1" 43 ft_xcodeplist="0" 44 ft_gcovout="1" 45 ft_html="0" 46 ft_yaml="0" 47 48 _git_root=$(git rev-parse --show-toplevel 2>/dev/null || hg root 2>/dev/null || echo "$PWD") 49 git_root="$_git_root" 50 remote_addr="" 51 if [ "$git_root" = "$PWD" ]; 52 then 53 git_root="." 54 fi 55 56 branch_o="" 57 build_o="" 58 commit_o="" 59 pr_o="" 60 prefix_o="" 61 network_filter_o="" 62 search_in_o="" 63 slug_o="" 64 tag_o="" 65 url_o="" 66 git_ls_files_recurse_submodules_o="" 67 package="bash" 68 69 commit="$VCS_COMMIT_ID" 70 branch="$VCS_BRANCH_NAME" 71 pr="$VCS_PULL_REQUEST" 72 slug="$VCS_SLUG" 73 tag="$VCS_TAG" 74 build_url="$CI_BUILD_URL" 75 build="$CI_BUILD_ID" 76 job="$CI_JOB_ID" 77 78 beta_xcode_partials="" 79 80 proj_root="$git_root" 81 gcov_exe="gcov" 82 gcov_arg="" 83 84 b="\033[0;36m" 85 g="\033[0;32m" 86 r="\033[0;31m" 87 e="\033[0;90m" 88 y="\033[0;33m" 89 x="\033[0m" 90 91 show_help() { 92 cat << EOF 93 94 Codecov Bash $VERSION 95 96 Global report uploading tool for Codecov 97 Documentation at https://docs.codecov.io/docs 98 Contribute at https://github.com/codecov/codecov-bash 99 100 101 -h Display this help and exit 102 -f FILE Target file(s) to upload 103 104 -f "path/to/file" only upload this file 105 skips searching unless provided patterns below 106 107 -f '!*.bar' ignore all files at pattern *.bar 108 -f '*.foo' include all files at pattern *.foo 109 Must use single quotes. 110 This is non-exclusive, use -s "*.foo" to match specific paths. 111 112 -s DIR Directory to search for coverage reports. 113 Already searches project root and artifact folders. 114 -t TOKEN Set the private repository token 115 (option) set environment variable CODECOV_TOKEN=:uuid 116 117 -t @/path/to/token_file 118 -t uuid 119 120 -n NAME Custom defined name of the upload. Visible in Codecov UI 121 122 -e ENV Specify environment variables to be included with this build 123 Also accepting environment variables: CODECOV_ENV=VAR,VAR2 124 125 -e VAR,VAR2 126 127 -k prefix Prefix filepaths to help resolve path fixing 128 129 -i prefix Only include files in the network with a certain prefix. Useful for upload-specific path fixing 130 131 -X feature Toggle functionalities 132 133 -X gcov Disable gcov 134 -X coveragepy Disable python coverage 135 -X fix Disable report fixing 136 -X search Disable searching for reports 137 -X xcode Disable xcode processing 138 -X network Disable uploading the file network 139 -X gcovout Disable gcov output 140 -X html Enable coverage for HTML files 141 -X recursesubs Enable recurse submodules in git projects when searching for source files 142 -X yaml Enable coverage for YAML files 143 144 -N The commit SHA of the parent for which you are uploading coverage. If not present, 145 the parent will be determined using the API of your repository provider. 146 When using the repository provider's API, the parent is determined via finding 147 the closest ancestor to the commit. 148 149 -R root dir Used when not in git/hg project to identify project root directory 150 -F flag Flag the upload to group coverage metrics 151 152 -F unittests This upload is only unittests 153 -F integration This upload is only integration tests 154 -F ui,chrome This upload is Chrome - UI tests 155 156 -c Move discovered coverage reports to the trash 157 -z FILE Upload specified file directly to Codecov and bypass all report generation. 158 This is inteded to be used only with a pre-formatted Codecov report and is not 159 expected to work under any other circumstances. 160 -Z Exit with 1 if not successful. Default will Exit with 0 161 162 -- xcode -- 163 -D Custom Derived Data Path for Coverage.profdata and gcov processing 164 Default '~/Library/Developer/Xcode/DerivedData' 165 -J Specify packages to build coverage. Uploader will only build these packages. 166 This can significantly reduces time to build coverage reports. 167 168 -J 'MyAppName' Will match "MyAppName" and "MyAppNameTests" 169 -J '^ExampleApp$' Will match only "ExampleApp" not "ExampleAppTests" 170 171 -- gcov -- 172 -g GLOB Paths to ignore during gcov gathering 173 -G GLOB Paths to include during gcov gathering 174 -p dir Project root directory 175 Also used when preparing gcov 176 -x gcovexe gcov executable to run. Defaults to 'gcov' 177 -a gcovargs extra arguments to pass to gcov 178 179 -- Override CI Environment Variables -- 180 These variables are automatically detected by popular CI providers 181 182 -B branch Specify the branch name 183 -C sha Specify the commit sha 184 -P pr Specify the pull request number 185 -b build Specify the build number 186 -T tag Specify the git tag 187 188 -- Enterprise -- 189 -u URL Set the target url for Enterprise customers 190 Not required when retrieving the bash uploader from your CCE 191 (option) Set environment variable CODECOV_URL=https://my-hosted-codecov.com 192 -r SLUG owner/repo slug used instead of the private repo token in Enterprise 193 (option) set environment variable CODECOV_SLUG=:owner/:repo 194 (option) set in your codecov.yml "codecov.slug" 195 -S PATH File path to your cacert.pem file used to verify ssl with Codecov Enterprise (optional) 196 (option) Set environment variable: CODECOV_CA_BUNDLE="/path/to/ca.pem" 197 -U curlargs Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy" 198 -A curlargs Extra curl arguments to communicate with AWS. 199 200 -- Debugging -- 201 -d Don't upload, but dump upload file to stdout 202 -q PATH Write upload file to path 203 -K Remove color from the output 204 -v Verbose mode 205 206 EOF 207 } 208 209 210 say() { 211 echo -e "$1" 212 } 213 214 215 urlencode() { 216 echo "$1" | curl -Gso /dev/null -w "%{url_effective}" --data-urlencode @- "" | cut -c 3- | sed -e 's/%0A//' 217 } 218 219 swiftcov() { 220 _dir=$(dirname "$1" | sed 's/\(Build\).*/\1/g') 221 for _type in app framework xctest 222 do 223 find "$_dir" -name "*.$_type" | while read -r f 224 do 225 _proj=${f##*/} 226 _proj=${_proj%."$_type"} 227 if [ "$2" = "" ] || [ "$(echo "$_proj" | grep -i "$2")" != "" ]; 228 then 229 say " $g+$x Building reports for $_proj $_type" 230 dest=$([ -f "$f/$_proj" ] && echo "$f/$_proj" || echo "$f/Contents/MacOS/$_proj") 231 # shellcheck disable=SC2001 232 _proj_name=$(echo "$_proj" | sed -e 's/[[:space:]]//g') 233 # shellcheck disable=SC2086 234 xcrun llvm-cov show $beta_xcode_partials -instr-profile "$1" "$dest" > "$_proj_name.$_type.coverage.txt" \ 235 || say " ${r}x>${x} llvm-cov failed to produce results for $dest" 236 fi 237 done 238 done 239 } 240 241 242 # Credits to: https://gist.github.com/pkuczynski/8665367 243 parse_yaml() { 244 local prefix=$2 245 local s='[[:space:]]*' w='[a-zA-Z0-9_]*' 246 local fs 247 fs=$(echo @|tr @ '\034') 248 sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ 249 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | 250 awk -F"$fs" '{ 251 indent = length($1)/2; 252 vname[indent] = $2; 253 for (i in vname) {if (i > indent) {delete vname[i]}} 254 if (length($3) > 0) { 255 vn=""; if (indent > 0) {vn=(vn)(vname[0])("_")} 256 printf("%s%s%s=\"%s\"\n", "'"$prefix"'",vn, $2, $3); 257 } 258 }' 259 } 260 261 if [ $# != 0 ]; 262 then 263 while getopts "a:A:b:B:cC:dD:e:f:F:g:G:hi:J:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:Zz:N:-" o 264 do 265 codecov_flags+=( "$o" ) 266 case "$o" in 267 "-") 268 echo -e "${r}Long options are not supported${x}" 269 exit 2 270 ;; 271 "?") 272 ;; 273 "N") 274 parent=$OPTARG 275 ;; 276 "a") 277 gcov_arg=$OPTARG 278 ;; 279 "A") 280 curlawsargs="$OPTARG" 281 ;; 282 "b") 283 build_o="$OPTARG" 284 ;; 285 "B") 286 branch_o="$OPTARG" 287 ;; 288 "c") 289 clean="1" 290 ;; 291 "C") 292 commit_o="$OPTARG" 293 ;; 294 "d") 295 dump="1" 296 ;; 297 "D") 298 ddp="$OPTARG" 299 ;; 300 "e") 301 env="$env,$OPTARG" 302 ;; 303 "f") 304 if [ "${OPTARG::1}" = "!" ]; 305 then 306 exclude_cov="$exclude_cov -not -path '${OPTARG:1}'" 307 308 elif [[ "$OPTARG" = *"*"* ]]; 309 then 310 include_cov="$include_cov -or -path '$OPTARG'" 311 312 else 313 ft_search=0 314 if [ "$files" = "" ]; 315 then 316 files="$OPTARG" 317 else 318 files="$files 319 $OPTARG" 320 fi 321 fi 322 ;; 323 "F") 324 if [ "$flags" = "" ]; 325 then 326 flags="$OPTARG" 327 else 328 flags="$flags,$OPTARG" 329 fi 330 ;; 331 "g") 332 gcov_ignore="$gcov_ignore -not -path '$OPTARG'" 333 ;; 334 "G") 335 gcov_include="$gcov_include -path '$OPTARG'" 336 ;; 337 "h") 338 show_help 339 exit 0; 340 ;; 341 "i") 342 network_filter_o="$OPTARG" 343 ;; 344 "J") 345 ft_xcodellvm="1" 346 ft_xcodeplist="0" 347 if [ "$xp" = "" ]; 348 then 349 xp="$OPTARG" 350 else 351 xp="$xp\|$OPTARG" 352 fi 353 ;; 354 "k") 355 prefix_o=$(echo "$OPTARG" | sed -e 's:^/*::' -e 's:/*$::') 356 ;; 357 "K") 358 b="" 359 g="" 360 r="" 361 e="" 362 x="" 363 ;; 364 "n") 365 name="$OPTARG" 366 ;; 367 "p") 368 proj_root="$OPTARG" 369 ;; 370 "P") 371 pr_o="$OPTARG" 372 ;; 373 "Q") 374 # this is only meant for Codecov packages to overwrite 375 package="$OPTARG" 376 ;; 377 "q") 378 save_to="$OPTARG" 379 ;; 380 "r") 381 slug_o="$OPTARG" 382 ;; 383 "R") 384 git_root="$OPTARG" 385 ;; 386 "s") 387 if [ "$search_in_o" = "" ]; 388 then 389 search_in_o="$OPTARG" 390 else 391 search_in_o="$search_in_o $OPTARG" 392 fi 393 ;; 394 "S") 395 # shellcheck disable=SC2089 396 cacert="--cacert \"$OPTARG\"" 397 ;; 398 "t") 399 if [ "${OPTARG::1}" = "@" ]; 400 then 401 token=$(< "${OPTARG:1}" tr -d ' \n') 402 else 403 token="$OPTARG" 404 fi 405 ;; 406 "T") 407 tag_o="$OPTARG" 408 ;; 409 "u") 410 url_o=$(echo "$OPTARG" | sed -e 's/\/$//') 411 ;; 412 "U") 413 curlargs="$OPTARG" 414 ;; 415 "v") 416 set -x 417 curl_s="" 418 ;; 419 "x") 420 gcov_exe=$OPTARG 421 ;; 422 "X") 423 if [ "$OPTARG" = "gcov" ]; 424 then 425 ft_gcov="0" 426 elif [ "$OPTARG" = "coveragepy" ] || [ "$OPTARG" = "py" ]; 427 then 428 ft_coveragepy="0" 429 elif [ "$OPTARG" = "gcovout" ]; 430 then 431 ft_gcovout="0" 432 elif [ "$OPTARG" = "xcodellvm" ]; 433 then 434 ft_xcodellvm="1" 435 ft_xcodeplist="0" 436 elif [ "$OPTARG" = "fix" ] || [ "$OPTARG" = "fixes" ]; 437 then 438 ft_fix="0" 439 elif [ "$OPTARG" = "xcode" ]; 440 then 441 ft_xcodellvm="0" 442 ft_xcodeplist="0" 443 elif [ "$OPTARG" = "search" ]; 444 then 445 ft_search="0" 446 elif [ "$OPTARG" = "xcodepartials" ]; 447 then 448 beta_xcode_partials="-use-color" 449 elif [ "$OPTARG" = "network" ]; 450 then 451 ft_network="0" 452 elif [ "$OPTARG" = "s3" ]; 453 then 454 ft_s3="0" 455 elif [ "$OPTARG" = "html" ]; 456 then 457 ft_html="1" 458 elif [ "$OPTARG" = "recursesubs" ]; 459 then 460 git_ls_files_recurse_submodules_o="--recurse-submodules" 461 elif [ "$OPTARG" = "yaml" ]; 462 then 463 ft_yaml="1" 464 fi 465 ;; 466 "Z") 467 exit_with=1 468 ;; 469 "z") 470 direct_file_upload="$OPTARG" 471 ft_gcov="0" 472 ft_coveragepy="0" 473 ft_fix="0" 474 ft_search="0" 475 ft_network="0" 476 ft_xcodellvm="0" 477 ft_gcovout="0" 478 include_cov="" 479 ;; 480 *) 481 echo -e "${r}Unexpected flag not supported${x}" 482 ;; 483 esac 484 done 485 fi 486 487 say " 488 _____ _ 489 / ____| | | 490 | | ___ __| | ___ ___ _____ __ 491 | | / _ \\ / _\` |/ _ \\/ __/ _ \\ \\ / / 492 | |___| (_) | (_| | __/ (_| (_) \\ V / 493 \\_____\\___/ \\__,_|\\___|\\___\\___/ \\_/ 494 Bash-$VERSION 495 496 " 497 498 # check for installed tools 499 # git/hg 500 if [ "$direct_file_upload" = "" ]; 501 then 502 if [ -x "$(command -v git)" ]; 503 then 504 say "$b==>$x $(git --version) found" 505 else 506 say "$y==>$x git not installed, testing for mercurial" 507 if [ -x "$(command -v hg)" ]; 508 then 509 say "$b==>$x $(hg --version) found" 510 else 511 say "$r==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences" 512 fi 513 fi 514 fi 515 # curl 516 if [ -x "$(command -v curl)" ]; 517 then 518 say "$b==>$x $(curl --version)" 519 else 520 say "$r==>$x curl not installed. Exiting." 521 exit ${exit_with}; 522 fi 523 524 search_in="$proj_root" 525 526 #shellcheck disable=SC2154 527 if [ "$JENKINS_URL" != "" ]; 528 then 529 say "$e==>$x Jenkins CI detected." 530 # https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project 531 # https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables 532 service="jenkins" 533 534 # shellcheck disable=SC2154 535 if [ "$ghprbSourceBranch" != "" ]; 536 then 537 branch="$ghprbSourceBranch" 538 elif [ "$GIT_BRANCH" != "" ]; 539 then 540 branch="$GIT_BRANCH" 541 elif [ "$BRANCH_NAME" != "" ]; 542 then 543 branch="$BRANCH_NAME" 544 fi 545 546 # shellcheck disable=SC2154 547 if [ "$ghprbActualCommit" != "" ]; 548 then 549 commit="$ghprbActualCommit" 550 elif [ "$GIT_COMMIT" != "" ]; 551 then 552 commit="$GIT_COMMIT" 553 fi 554 555 # shellcheck disable=SC2154 556 if [ "$ghprbPullId" != "" ]; 557 then 558 pr="$ghprbPullId" 559 elif [ "$CHANGE_ID" != "" ]; 560 then 561 pr="$CHANGE_ID" 562 fi 563 564 build="$BUILD_NUMBER" 565 # shellcheck disable=SC2153 566 build_url=$(urlencode "$BUILD_URL") 567 568 elif [ "$CI" = "true" ] && [ "$TRAVIS" = "true" ] && [ "$SHIPPABLE" != "true" ]; 569 then 570 say "$e==>$x Travis CI detected." 571 # https://docs.travis-ci.com/user/environment-variables/ 572 service="travis" 573 commit="${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}" 574 build="$TRAVIS_JOB_NUMBER" 575 pr="$TRAVIS_PULL_REQUEST" 576 job="$TRAVIS_JOB_ID" 577 slug="$TRAVIS_REPO_SLUG" 578 env="$env,TRAVIS_OS_NAME" 579 tag="$TRAVIS_TAG" 580 if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ]; 581 then 582 branch="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" 583 fi 584 585 language=$(compgen -A variable | grep "^TRAVIS_.*_VERSION$" | head -1) 586 if [ "$language" != "" ]; 587 then 588 env="$env,${!language}" 589 fi 590 591 elif [ "$CODEBUILD_CI" = "true" ]; 592 then 593 say "$e==>$x AWS Codebuild detected." 594 # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html 595 service="codebuild" 596 commit="$CODEBUILD_RESOLVED_SOURCE_VERSION" 597 build="$CODEBUILD_BUILD_ID" 598 branch="$(echo "$CODEBUILD_WEBHOOK_HEAD_REF" | sed 's/^refs\/heads\///')" 599 if [ "${CODEBUILD_SOURCE_VERSION/pr}" = "$CODEBUILD_SOURCE_VERSION" ] ; then 600 pr="false" 601 else 602 pr="$(echo "$CODEBUILD_SOURCE_VERSION" | sed 's/^pr\///')" 603 fi 604 job="$CODEBUILD_BUILD_ID" 605 slug="$(echo "$CODEBUILD_SOURCE_REPO_URL" | sed 's/^.*:\/\/[^\/]*\///' | sed 's/\.git$//')" 606 607 elif [ "$CI" = "true" ] && [ "$CI_NAME" = "codeship" ]; 608 then 609 say "$e==>$x Codeship CI detected." 610 # https://www.codeship.io/documentation/continuous-integration/set-environment-variables/ 611 service="codeship" 612 branch="$CI_BRANCH" 613 build="$CI_BUILD_NUMBER" 614 build_url=$(urlencode "$CI_BUILD_URL") 615 commit="$CI_COMMIT_ID" 616 617 elif [ -n "$CF_BUILD_URL" ] && [ -n "$CF_BUILD_ID" ]; 618 then 619 say "$e==>$x Codefresh CI detected." 620 # https://docs.codefresh.io/v1.0/docs/variables 621 service="codefresh" 622 branch="$CF_BRANCH" 623 build="$CF_BUILD_ID" 624 build_url=$(urlencode "$CF_BUILD_URL") 625 commit="$CF_REVISION" 626 627 elif [ "$TEAMCITY_VERSION" != "" ]; 628 then 629 say "$e==>$x TeamCity CI detected." 630 # https://confluence.jetbrains.com/display/TCD8/Predefined+Build+Parameters 631 # https://confluence.jetbrains.com/plugins/servlet/mobile#content/view/74847298 632 if [ "$TEAMCITY_BUILD_BRANCH" = '' ]; 633 then 634 echo " Teamcity does not automatically make build parameters available as environment variables." 635 echo " Add the following environment parameters to the build configuration" 636 echo " env.TEAMCITY_BUILD_BRANCH = %teamcity.build.branch%" 637 echo " env.TEAMCITY_BUILD_ID = %teamcity.build.id%" 638 echo " env.TEAMCITY_BUILD_URL = %teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%" 639 echo " env.TEAMCITY_BUILD_COMMIT = %system.build.vcs.number%" 640 echo " env.TEAMCITY_BUILD_REPOSITORY = %vcsroot.<YOUR TEAMCITY VCS NAME>.url%" 641 fi 642 service="teamcity" 643 branch="$TEAMCITY_BUILD_BRANCH" 644 build="$TEAMCITY_BUILD_ID" 645 build_url=$(urlencode "$TEAMCITY_BUILD_URL") 646 if [ "$TEAMCITY_BUILD_COMMIT" != "" ]; 647 then 648 commit="$TEAMCITY_BUILD_COMMIT" 649 else 650 commit="$BUILD_VCS_NUMBER" 651 fi 652 remote_addr="$TEAMCITY_BUILD_REPOSITORY" 653 654 elif [ "$CI" = "true" ] && [ "$CIRCLECI" = "true" ]; 655 then 656 say "$e==>$x Circle CI detected." 657 # https://circleci.com/docs/environment-variables 658 service="circleci" 659 branch="$CIRCLE_BRANCH" 660 build="$CIRCLE_BUILD_NUM" 661 job="$CIRCLE_NODE_INDEX" 662 if [ "$CIRCLE_PROJECT_REPONAME" != "" ]; 663 then 664 slug="$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" 665 else 666 # git@github.com:owner/repo.git 667 slug="${CIRCLE_REPOSITORY_URL##*:}" 668 # owner/repo.git 669 slug="${slug%%.git}" 670 fi 671 pr="${CIRCLE_PULL_REQUEST##*/}" 672 commit="$CIRCLE_SHA1" 673 search_in="$search_in $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS" 674 675 elif [ "$BUDDYBUILD_BRANCH" != "" ]; 676 then 677 say "$e==>$x buddybuild detected" 678 # http://docs.buddybuild.com/v6/docs/custom-prebuild-and-postbuild-steps 679 service="buddybuild" 680 branch="$BUDDYBUILD_BRANCH" 681 build="$BUDDYBUILD_BUILD_NUMBER" 682 build_url="https://dashboard.buddybuild.com/public/apps/$BUDDYBUILD_APP_ID/build/$BUDDYBUILD_BUILD_ID" 683 # BUDDYBUILD_TRIGGERED_BY 684 if [ "$ddp" = "$HOME/Library/Developer/Xcode/DerivedData" ]; 685 then 686 ddp="/private/tmp/sandbox/${BUDDYBUILD_APP_ID}/bbtest" 687 fi 688 689 elif [ "${bamboo_planRepository_revision}" != "" ]; 690 then 691 say "$e==>$x Bamboo detected" 692 # https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html#Bamboovariables-Build-specificvariables 693 service="bamboo" 694 commit="${bamboo_planRepository_revision}" 695 # shellcheck disable=SC2154 696 branch="${bamboo_planRepository_branch}" 697 # shellcheck disable=SC2154 698 build="${bamboo_buildNumber}" 699 # shellcheck disable=SC2154 700 build_url="${bamboo_buildResultsUrl}" 701 # shellcheck disable=SC2154 702 remote_addr="${bamboo_planRepository_repositoryUrl}" 703 704 elif [ "$CI" = "true" ] && [ "$BITRISE_IO" = "true" ]; 705 then 706 # http://devcenter.bitrise.io/faq/available-environment-variables/ 707 say "$e==>$x Bitrise CI detected." 708 service="bitrise" 709 branch="$BITRISE_GIT_BRANCH" 710 build="$BITRISE_BUILD_NUMBER" 711 build_url=$(urlencode "$BITRISE_BUILD_URL") 712 pr="$BITRISE_PULL_REQUEST" 713 if [ "$GIT_CLONE_COMMIT_HASH" != "" ]; 714 then 715 commit="$GIT_CLONE_COMMIT_HASH" 716 fi 717 718 elif [ "$CI" = "true" ] && [ "$SEMAPHORE" = "true" ]; 719 then 720 say "$e==>$x Semaphore CI detected." 721 # https://docs.semaphoreci.com/ci-cd-environment/environment-variables/#semaphore-related 722 service="semaphore" 723 branch="$SEMAPHORE_GIT_BRANCH" 724 build="$SEMAPHORE_WORKFLOW_NUMBER" 725 job="$SEMAPHORE_JOB_ID" 726 pr="$PULL_REQUEST_NUMBER" 727 slug="$SEMAPHORE_REPO_SLUG" 728 commit="$REVISION" 729 env="$env,SEMAPHORE_TRIGGER_SOURCE" 730 731 elif [ "$CI" = "true" ] && [ "$BUILDKITE" = "true" ]; 732 then 733 say "$e==>$x Buildkite CI detected." 734 # https://buildkite.com/docs/guides/environment-variables 735 service="buildkite" 736 branch="$BUILDKITE_BRANCH" 737 build="$BUILDKITE_BUILD_NUMBER" 738 job="$BUILDKITE_JOB_ID" 739 build_url=$(urlencode "$BUILDKITE_BUILD_URL") 740 slug="$BUILDKITE_PROJECT_SLUG" 741 commit="$BUILDKITE_COMMIT" 742 if [[ "$BUILDKITE_PULL_REQUEST" != "false" ]]; then 743 pr="$BUILDKITE_PULL_REQUEST" 744 fi 745 tag="$BUILDKITE_TAG" 746 747 elif [ "$CI" = "drone" ] || [ "$DRONE" = "true" ]; 748 then 749 say "$e==>$x Drone CI detected." 750 # http://docs.drone.io/env.html 751 # drone commits are not full shas 752 service="drone.io" 753 branch="$DRONE_BRANCH" 754 build="$DRONE_BUILD_NUMBER" 755 build_url=$(urlencode "${DRONE_BUILD_LINK}") 756 pr="$DRONE_PULL_REQUEST" 757 job="$DRONE_JOB_NUMBER" 758 tag="$DRONE_TAG" 759 760 elif [ "$CI" = "true" ] && [ "$HEROKU_TEST_RUN_BRANCH" != "" ]; 761 then 762 say "$e==>$x Heroku CI detected." 763 # https://devcenter.heroku.com/articles/heroku-ci#environment-variables 764 service="heroku" 765 branch="$HEROKU_TEST_RUN_BRANCH" 766 build="$HEROKU_TEST_RUN_ID" 767 commit="$HEROKU_TEST_RUN_COMMIT_VERSION" 768 769 elif [[ "$CI" = "true" || "$CI" = "True" ]] && [[ "$APPVEYOR" = "true" || "$APPVEYOR" = "True" ]]; 770 then 771 say "$e==>$x Appveyor CI detected." 772 # http://www.appveyor.com/docs/environment-variables 773 service="appveyor" 774 branch="$APPVEYOR_REPO_BRANCH" 775 build=$(urlencode "$APPVEYOR_JOB_ID") 776 pr="$APPVEYOR_PULL_REQUEST_NUMBER" 777 job="$APPVEYOR_ACCOUNT_NAME%2F$APPVEYOR_PROJECT_SLUG%2F$APPVEYOR_BUILD_VERSION" 778 slug="$APPVEYOR_REPO_NAME" 779 commit="$APPVEYOR_REPO_COMMIT" 780 build_url=$(urlencode "${APPVEYOR_URL}/project/${APPVEYOR_REPO_NAME}/builds/$APPVEYOR_BUILD_ID/job/${APPVEYOR_JOB_ID}") 781 782 elif [ "$CI" = "true" ] && [ "$WERCKER_GIT_BRANCH" != "" ]; 783 then 784 say "$e==>$x Wercker CI detected." 785 # http://devcenter.wercker.com/articles/steps/variables.html 786 service="wercker" 787 branch="$WERCKER_GIT_BRANCH" 788 build="$WERCKER_MAIN_PIPELINE_STARTED" 789 slug="$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY" 790 commit="$WERCKER_GIT_COMMIT" 791 792 elif [ "$CI" = "true" ] && [ "$MAGNUM" = "true" ]; 793 then 794 say "$e==>$x Magnum CI detected." 795 # https://magnum-ci.com/docs/environment 796 service="magnum" 797 branch="$CI_BRANCH" 798 build="$CI_BUILD_NUMBER" 799 commit="$CI_COMMIT" 800 801 elif [ "$SHIPPABLE" = "true" ]; 802 then 803 say "$e==>$x Shippable CI detected." 804 # http://docs.shippable.com/ci_configure/ 805 service="shippable" 806 # shellcheck disable=SC2153 807 branch=$([ "$HEAD_BRANCH" != "" ] && echo "$HEAD_BRANCH" || echo "$BRANCH") 808 build="$BUILD_NUMBER" 809 build_url=$(urlencode "$BUILD_URL") 810 pr="$PULL_REQUEST" 811 slug="$REPO_FULL_NAME" 812 # shellcheck disable=SC2153 813 commit="$COMMIT" 814 815 elif [ "$TDDIUM" = "true" ]; 816 then 817 say "Solano CI detected." 818 # http://docs.solanolabs.com/Setup/tddium-set-environment-variables/ 819 service="solano" 820 commit="$TDDIUM_CURRENT_COMMIT" 821 branch="$TDDIUM_CURRENT_BRANCH" 822 build="$TDDIUM_TID" 823 pr="$TDDIUM_PR_ID" 824 825 elif [ "$GREENHOUSE" = "true" ]; 826 then 827 say "$e==>$x Greenhouse CI detected." 828 # http://docs.greenhouseci.com/docs/environment-variables-files 829 service="greenhouse" 830 branch="$GREENHOUSE_BRANCH" 831 build="$GREENHOUSE_BUILD_NUMBER" 832 build_url=$(urlencode "$GREENHOUSE_BUILD_URL") 833 pr="$GREENHOUSE_PULL_REQUEST" 834 commit="$GREENHOUSE_COMMIT" 835 search_in="$search_in $GREENHOUSE_EXPORT_DIR" 836 837 elif [ "$GITLAB_CI" != "" ]; 838 then 839 say "$e==>$x GitLab CI detected." 840 # http://doc.gitlab.com/ce/ci/variables/README.html 841 service="gitlab" 842 branch="${CI_BUILD_REF_NAME:-$CI_COMMIT_REF_NAME}" 843 build="${CI_BUILD_ID:-$CI_JOB_ID}" 844 remote_addr="${CI_BUILD_REPO:-$CI_REPOSITORY_URL}" 845 commit="${CI_BUILD_REF:-$CI_COMMIT_SHA}" 846 slug="${CI_PROJECT_PATH}" 847 848 elif [ "$GITHUB_ACTIONS" != "" ]; 849 then 850 say "$e==>$x GitHub Actions detected." 851 say " Env vars used:" 852 say " -> GITHUB_ACTIONS: ${GITHUB_ACTIONS}" 853 say " -> GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}" 854 say " -> GITHUB_REF: ${GITHUB_REF}" 855 say " -> GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}" 856 say " -> GITHUB_RUN_ID: ${GITHUB_RUN_ID}" 857 say " -> GITHUB_SHA: ${GITHUB_SHA}" 858 say " -> GITHUB_WORKFLOW: ${GITHUB_WORKFLOW}" 859 860 # https://github.com/features/actions 861 service="github-actions" 862 863 # https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables 864 branch="${GITHUB_REF#refs/heads/}" 865 if [ "$GITHUB_HEAD_REF" != "" ]; 866 then 867 # PR refs are in the format: refs/pull/7/merge 868 pr="${GITHUB_REF#refs/pull/}" 869 pr="${pr%/merge}" 870 branch="${GITHUB_HEAD_REF}" 871 fi 872 commit="${GITHUB_SHA}" 873 slug="${GITHUB_REPOSITORY}" 874 build="${GITHUB_RUN_ID}" 875 build_url=$(urlencode "http://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}") 876 job="$(urlencode "${GITHUB_WORKFLOW}")" 877 878 # actions/checkout runs in detached HEAD 879 mc= 880 if [ -n "$pr" ] && [ "$pr" != false ] && [ "$commit_o" == "" ]; 881 then 882 mc=$(git show --no-patch --format="%P" 2>/dev/null || echo "") 883 884 if [[ "$mc" =~ ^[a-z0-9]{40}[[:space:]][a-z0-9]{40}$ ]]; 885 then 886 mc=$(echo "$mc" | cut -d' ' -f2) 887 say " Fixing merge commit SHA $commit -> $mc" 888 commit=$mc 889 elif [[ "$mc" = "" ]]; 890 then 891 say "$r-> Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0$x" 892 fi 893 fi 894 895 elif [ "$SYSTEM_TEAMFOUNDATIONSERVERURI" != "" ]; 896 then 897 say "$e==>$x Azure Pipelines detected." 898 # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=vsts 899 # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&viewFallbackFrom=vsts&tabs=yaml 900 service="azure_pipelines" 901 commit="$BUILD_SOURCEVERSION" 902 build="$BUILD_BUILDNUMBER" 903 if [ -z "$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" ]; 904 then 905 pr="$SYSTEM_PULLREQUEST_PULLREQUESTID" 906 else 907 pr="$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" 908 fi 909 project="${SYSTEM_TEAMPROJECT}" 910 server_uri="${SYSTEM_TEAMFOUNDATIONSERVERURI}" 911 job="${BUILD_BUILDID}" 912 branch="${BUILD_SOURCEBRANCH#"refs/heads/"}" 913 build_url=$(urlencode "${SYSTEM_TEAMFOUNDATIONSERVERURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}") 914 915 # azure/pipelines runs in detached HEAD 916 mc= 917 if [ -n "$pr" ] && [ "$pr" != false ]; 918 then 919 mc=$(git show --no-patch --format="%P" 2>/dev/null || echo "") 920 921 if [[ "$mc" =~ ^[a-z0-9]{40}[[:space:]][a-z0-9]{40}$ ]]; 922 then 923 mc=$(echo "$mc" | cut -d' ' -f2) 924 say " Fixing merge commit SHA $commit -> $mc" 925 commit=$mc 926 fi 927 fi 928 929 elif [ "$CI" = "true" ] && [ "$BITBUCKET_BUILD_NUMBER" != "" ]; 930 then 931 say "$e==>$x Bitbucket detected." 932 # https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html 933 service="bitbucket" 934 branch="$BITBUCKET_BRANCH" 935 build="$BITBUCKET_BUILD_NUMBER" 936 slug="$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG" 937 job="$BITBUCKET_BUILD_NUMBER" 938 pr="$BITBUCKET_PR_ID" 939 commit="$BITBUCKET_COMMIT" 940 # See https://jira.atlassian.com/browse/BCLOUD-19393 941 if [ "${#commit}" = 12 ]; 942 then 943 commit=$(git rev-parse "$BITBUCKET_COMMIT") 944 fi 945 946 elif [ "$CI" = "true" ] && [ "$BUDDY" = "true" ]; 947 then 948 say "$e==>$x Buddy CI detected." 949 # https://buddy.works/docs/pipelines/environment-variables 950 service="buddy" 951 branch="$BUDDY_EXECUTION_BRANCH" 952 build="$BUDDY_EXECUTION_ID" 953 build_url=$(urlencode "$BUDDY_EXECUTION_URL") 954 commit="$BUDDY_EXECUTION_REVISION" 955 pr="$BUDDY_EXECUTION_PULL_REQUEST_NO" 956 tag="$BUDDY_EXECUTION_TAG" 957 slug="$BUDDY_REPO_SLUG" 958 959 elif [ "$CIRRUS_CI" != "" ]; 960 then 961 say "$e==>$x Cirrus CI detected." 962 # https://cirrus-ci.org/guide/writing-tasks/#environment-variables 963 service="cirrus-ci" 964 slug="$CIRRUS_REPO_FULL_NAME" 965 branch="$CIRRUS_BRANCH" 966 pr="$CIRRUS_PR" 967 commit="$CIRRUS_CHANGE_IN_REPO" 968 build="$CIRRUS_BUILD_ID" 969 build_url=$(urlencode "https://cirrus-ci.com/task/$CIRRUS_TASK_ID") 970 job="$CIRRUS_TASK_NAME" 971 972 elif [ "$DOCKER_REPO" != "" ]; 973 then 974 say "$e==>$x Docker detected." 975 # https://docs.docker.com/docker-cloud/builds/advanced/ 976 service="docker" 977 branch="$SOURCE_BRANCH" 978 commit="$SOURCE_COMMIT" 979 slug="$DOCKER_REPO" 980 tag="$CACHE_TAG" 981 env="$env,IMAGE_NAME" 982 983 else 984 say "${r}x>${x} No CI provider detected." 985 say " Testing inside Docker? ${b}http://docs.codecov.io/docs/testing-with-docker${x}" 986 say " Testing with Tox? ${b}https://docs.codecov.io/docs/python#section-testing-with-tox${x}" 987 988 fi 989 990 say " ${e}project root:${x} $git_root" 991 992 # find branch, commit, repo from git command 993 if [ "$GIT_BRANCH" != "" ]; 994 then 995 branch="$GIT_BRANCH" 996 997 elif [ "$branch" = "" ]; 998 then 999 branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || hg branch 2>/dev/null || echo "") 1000 if [ "$branch" = "HEAD" ]; 1001 then 1002 branch="" 1003 fi 1004 fi 1005 1006 if [ "$commit_o" = "" ]; 1007 then 1008 if [ "$GIT_COMMIT" != "" ]; 1009 then 1010 commit="$GIT_COMMIT" 1011 elif [ "$commit" = "" ]; 1012 then 1013 commit=$(git log -1 --format="%H" 2>/dev/null || hg id -i --debug 2>/dev/null | tr -d '+' || echo "") 1014 fi 1015 else 1016 commit="$commit_o" 1017 fi 1018 1019 if [ "$CODECOV_TOKEN" != "" ] && [ "$token" = "" ]; 1020 then 1021 say "${e}-->${x} token set from env" 1022 token="$CODECOV_TOKEN" 1023 fi 1024 1025 if [ "$CODECOV_URL" != "" ] && [ "$url_o" = "" ]; 1026 then 1027 say "${e}-->${x} url set from env" 1028 url_o=$(echo "$CODECOV_URL" | sed -e 's/\/$//') 1029 fi 1030 1031 if [ "$CODECOV_SLUG" != "" ]; 1032 then 1033 say "${e}-->${x} slug set from env" 1034 slug_o="$CODECOV_SLUG" 1035 1036 elif [ "$slug" = "" ]; 1037 then 1038 if [ "$remote_addr" = "" ]; 1039 then 1040 remote_addr=$(git config --get remote.origin.url || hg paths default || echo '') 1041 fi 1042 if [ "$remote_addr" != "" ]; 1043 then 1044 if echo "$remote_addr" | grep -q "//"; then 1045 # https 1046 slug=$(echo "$remote_addr" | cut -d / -f 4,5 | sed -e 's/\.git$//') 1047 else 1048 # ssh 1049 slug=$(echo "$remote_addr" | cut -d : -f 2 | sed -e 's/\.git$//') 1050 fi 1051 fi 1052 if [ "$slug" = "/" ]; 1053 then 1054 slug="" 1055 fi 1056 fi 1057 1058 yaml=$(cd "$git_root" && \ 1059 git ls-files "*codecov.yml" "*codecov.yaml" 2>/dev/null \ 1060 || hg locate "*codecov.yml" "*codecov.yaml" 2>/dev/null \ 1061 || cd "$proj_root" && find . -maxdepth 1 -type f -name '*codecov.y*ml' 2>/dev/null \ 1062 || echo '') 1063 yaml=$(echo "$yaml" | head -1) 1064 1065 if [ "$yaml" != "" ]; 1066 then 1067 say " ${e}Yaml found at:${x} $yaml" 1068 if [[ "$yaml" != /* ]]; then 1069 # relative path for yaml file given, assume relative to the repo root 1070 yaml="$git_root/$yaml" 1071 fi 1072 config=$(parse_yaml "$yaml" || echo '') 1073 1074 # TODO validate the yaml here 1075 1076 if [ "$(echo "$config" | grep 'codecov_token="')" != "" ] && [ "$token" = "" ]; 1077 then 1078 say "${e}-->${x} token set from yaml" 1079 token="$(echo "$config" | grep 'codecov_token="' | sed -e 's/codecov_token="//' | sed -e 's/"\.*//')" 1080 fi 1081 1082 if [ "$(echo "$config" | grep 'codecov_url="')" != "" ] && [ "$url_o" = "" ]; 1083 then 1084 say "${e}-->${x} url set from yaml" 1085 url_o="$(echo "$config" | grep 'codecov_url="' | sed -e 's/codecov_url="//' | sed -e 's/"\.*//')" 1086 fi 1087 1088 if [ "$(echo "$config" | grep 'codecov_slug="')" != "" ] && [ "$slug_o" = "" ]; 1089 then 1090 say "${e}-->${x} slug set from yaml" 1091 slug_o="$(echo "$config" | grep 'codecov_slug="' | sed -e 's/codecov_slug="//' | sed -e 's/"\.*//')" 1092 fi 1093 else 1094 say " ${g}Yaml not found, that's ok! Learn more at${x} ${b}http://docs.codecov.io/docs/codecov-yaml${x}" 1095 fi 1096 1097 if [ "$branch_o" != "" ]; 1098 then 1099 branch=$(urlencode "$branch_o") 1100 else 1101 branch=$(urlencode "$branch") 1102 fi 1103 1104 if [ "$slug_o" = "" ]; 1105 then 1106 urlencoded_slug=$(urlencode "$slug") 1107 else 1108 urlencoded_slug=$(urlencode "$slug_o") 1109 fi 1110 1111 query="branch=$branch\ 1112 &commit=$commit\ 1113 &build=$([ "$build_o" = "" ] && echo "$build" || echo "$build_o")\ 1114 &build_url=$build_url\ 1115 &name=$(urlencode "$name")\ 1116 &tag=$([ "$tag_o" = "" ] && echo "$tag" || echo "$tag_o")\ 1117 &slug=$urlencoded_slug\ 1118 &service=$service\ 1119 &flags=$flags\ 1120 &pr=$([ "$pr_o" = "" ] && echo "${pr##\#}" || echo "${pr_o##\#}")\ 1121 &job=$job\ 1122 &cmd_args=$(IFS=,; echo "${codecov_flags[*]}")" 1123 1124 if [ -n "$project" ] && [ -n "$server_uri" ]; 1125 then 1126 query=$(echo "$query&project=$project&server_uri=$server_uri" | tr -d ' ') 1127 fi 1128 1129 if [ "$parent" != "" ]; 1130 then 1131 query=$(echo "parent=$parent&$query" | tr -d ' ') 1132 fi 1133 1134 if [ "$ft_search" = "1" ]; 1135 then 1136 # detect bower comoponents location 1137 bower_components="bower_components" 1138 bower_rc=$(cd "$git_root" && cat .bowerrc 2>/dev/null || echo "") 1139 if [ "$bower_rc" != "" ]; 1140 then 1141 bower_components=$(echo "$bower_rc" | tr -d '\n' | grep '"directory"' | cut -d'"' -f4 | sed -e 's/\/$//') 1142 if [ "$bower_components" = "" ]; 1143 then 1144 bower_components="bower_components" 1145 fi 1146 fi 1147 1148 # Swift Coverage 1149 if [ "$ft_xcodellvm" = "1" ] && [ -d "$ddp" ]; 1150 then 1151 say "${e}==>${x} Processing Xcode reports via llvm-cov" 1152 say " DerivedData folder: $ddp" 1153 profdata_files=$(find "$ddp" -name '*.profdata' 2>/dev/null || echo '') 1154 if [ "$profdata_files" != "" ]; 1155 then 1156 # xcode via profdata 1157 if [ "$xp" = "" ]; 1158 then 1159 # xp=$(xcodebuild -showBuildSettings 2>/dev/null | grep -i "^\s*PRODUCT_NAME" | sed -e 's/.*= \(.*\)/\1/') 1160 # say " ${e}->${x} Speed up Xcode processing by adding ${e}-J '$xp'${x}" 1161 say " ${g}hint${x} Speed up Swift processing by using use ${g}-J 'AppName'${x} (regexp accepted)" 1162 say " ${g}hint${x} This will remove Pods/ from your report. Also ${b}https://docs.codecov.io/docs/ignoring-paths${x}" 1163 fi 1164 while read -r profdata; 1165 do 1166 if [ "$profdata" != "" ]; 1167 then 1168 swiftcov "$profdata" "$xp" 1169 fi 1170 done <<< "$profdata_files" 1171 else 1172 say " ${e}->${x} No Swift coverage found" 1173 fi 1174 1175 # Obj-C Gcov Coverage 1176 if [ "$ft_gcov" = "1" ]; 1177 then 1178 say " ${e}->${x} Running $gcov_exe for Obj-C" 1179 if [ "$ft_gcovout" = "0" ]; 1180 then 1181 # suppress gcov output 1182 bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" >/dev/null 2>&1 || true 1183 else 1184 bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" || true 1185 fi 1186 fi 1187 fi 1188 1189 if [ "$ft_xcodeplist" = "1" ] && [ -d "$ddp" ]; 1190 then 1191 say "${e}==>${x} Processing Xcode plists" 1192 plists_files=$(find "$ddp" -name '*.xccoverage' 2>/dev/null || echo '') 1193 if [ "$plists_files" != "" ]; 1194 then 1195 while read -r plist; 1196 do 1197 if [ "$plist" != "" ]; 1198 then 1199 say " ${g}Found${x} plist file at $plist" 1200 plutil -convert xml1 -o "$(basename "$plist").plist" -- "$plist" 1201 fi 1202 done <<< "$plists_files" 1203 fi 1204 fi 1205 1206 # Gcov Coverage 1207 if [ "$ft_gcov" = "1" ]; 1208 then 1209 say "${e}==>${x} Running $gcov_exe in $proj_root ${e}(disable via -X gcov)${x}" 1210 if [ "$ft_gcovout" = "0" ]; 1211 then 1212 # suppress gcov output 1213 bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" >/dev/null 2>&1 || true 1214 else 1215 bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" || true 1216 fi 1217 else 1218 say "${e}==>${x} gcov disabled" 1219 fi 1220 1221 # Python Coverage 1222 if [ "$ft_coveragepy" = "1" ]; 1223 then 1224 if [ ! -f coverage.xml ]; 1225 then 1226 if command -v coverage >/dev/null 2>&1; 1227 then 1228 say "${e}==>${x} Python coveragepy exists ${e}disable via -X coveragepy${x}" 1229 1230 dotcoverage=$(find "$git_root" -name '.coverage' -or -name '.coverage.*' | head -1 || echo '') 1231 if [ "$dotcoverage" != "" ]; 1232 then 1233 cd "$(dirname "$dotcoverage")" 1234 if [ ! -f .coverage ]; 1235 then 1236 say " ${e}->${x} Running coverage combine" 1237 coverage combine -a 1238 fi 1239 say " ${e}->${x} Running coverage xml" 1240 if [ "$(coverage xml -i)" != "No data to report." ]; 1241 then 1242 files="$files 1243 $PWD/coverage.xml" 1244 else 1245 say " ${r}No data to report.${x}" 1246 fi 1247 cd "$proj_root" 1248 else 1249 say " ${r}No .coverage file found.${x}" 1250 fi 1251 else 1252 say "${e}==>${x} Python coveragepy not found" 1253 fi 1254 fi 1255 else 1256 say "${e}==>${x} Python coveragepy disabled" 1257 fi 1258 1259 if [ "$search_in_o" != "" ]; 1260 then 1261 # location override 1262 search_in="$search_in_o" 1263 fi 1264 1265 say "$e==>$x Searching for coverage reports in:" 1266 for _path in $search_in 1267 do 1268 say " ${g}+${x} $_path" 1269 done 1270 1271 patterns="find $search_in \( \ 1272 -name vendor \ 1273 -or -name '$bower_components' \ 1274 -or -name '.egg-info*' \ 1275 -or -name 'conftest_*.c.gcov' \ 1276 -or -name .env \ 1277 -or -name .envs \ 1278 -or -name .git \ 1279 -or -name .hg \ 1280 -or -name .tox \ 1281 -or -name .venv \ 1282 -or -name .venvs \ 1283 -or -name .virtualenv \ 1284 -or -name .virtualenvs \ 1285 -or -name .yarn-cache \ 1286 -or -name __pycache__ \ 1287 -or -name env \ 1288 -or -name envs \ 1289 -or -name htmlcov \ 1290 -or -name js/generated/coverage \ 1291 -or -name node_modules \ 1292 -or -name venv \ 1293 -or -name venvs \ 1294 -or -name virtualenv \ 1295 -or -name virtualenvs \ 1296 \) -prune -or \ 1297 -type f \( -name '*coverage*.*' \ 1298 -or -name '*.clover' \ 1299 -or -name '*.codecov.*' \ 1300 -or -name '*.gcov' \ 1301 -or -name '*.lcov' \ 1302 -or -name '*.lst' \ 1303 -or -name 'clover.xml' \ 1304 -or -name 'cobertura.xml' \ 1305 -or -name 'codecov.*' \ 1306 -or -name 'cover.out' \ 1307 -or -name 'codecov-result.json' \ 1308 -or -name 'coverage-final.json' \ 1309 -or -name 'excoveralls.json' \ 1310 -or -name 'gcov.info' \ 1311 -or -name 'jacoco*.xml' \ 1312 -or -name '*Jacoco*.xml' \ 1313 -or -name 'lcov.dat' \ 1314 -or -name 'lcov.info' \ 1315 -or -name 'luacov.report.out' \ 1316 -or -name 'naxsi.info' \ 1317 -or -name 'nosetests.xml' \ 1318 -or -name 'report.xml' \ 1319 $include_cov \) \ 1320 $exclude_cov \ 1321 -not -name '*.am' \ 1322 -not -name '*.bash' \ 1323 -not -name '*.bat' \ 1324 -not -name '*.bw' \ 1325 -not -name '*.cfg' \ 1326 -not -name '*.class' \ 1327 -not -name '*.cmake' \ 1328 -not -name '*.cmake' \ 1329 -not -name '*.conf' \ 1330 -not -name '*.coverage' \ 1331 -not -name '*.cp' \ 1332 -not -name '*.cpp' \ 1333 -not -name '*.crt' \ 1334 -not -name '*.css' \ 1335 -not -name '*.csv' \ 1336 -not -name '*.csv' \ 1337 -not -name '*.data' \ 1338 -not -name '*.db' \ 1339 -not -name '*.dox' \ 1340 -not -name '*.ec' \ 1341 -not -name '*.ec' \ 1342 -not -name '*.egg' \ 1343 -not -name '*.el' \ 1344 -not -name '*.env' \ 1345 -not -name '*.erb' \ 1346 -not -name '*.exe' \ 1347 -not -name '*.ftl' \ 1348 -not -name '*.gif' \ 1349 -not -name '*.gradle' \ 1350 -not -name '*.gz' \ 1351 -not -name '*.h' \ 1352 -not -name '*.html' \ 1353 -not -name '*.in' \ 1354 -not -name '*.jade' \ 1355 -not -name '*.jar*' \ 1356 -not -name '*.jpeg' \ 1357 -not -name '*.jpg' \ 1358 -not -name '*.js' \ 1359 -not -name '*.less' \ 1360 -not -name '*.log' \ 1361 -not -name '*.m4' \ 1362 -not -name '*.mak*' \ 1363 -not -name '*.md' \ 1364 -not -name '*.o' \ 1365 -not -name '*.p12' \ 1366 -not -name '*.pem' \ 1367 -not -name '*.png' \ 1368 -not -name '*.pom*' \ 1369 -not -name '*.profdata' \ 1370 -not -name '*.proto' \ 1371 -not -name '*.ps1' \ 1372 -not -name '*.pth' \ 1373 -not -name '*.py' \ 1374 -not -name '*.pyc' \ 1375 -not -name '*.pyo' \ 1376 -not -name '*.rb' \ 1377 -not -name '*.rsp' \ 1378 -not -name '*.rst' \ 1379 -not -name '*.ru' \ 1380 -not -name '*.sbt' \ 1381 -not -name '*.scss' \ 1382 -not -name '*.scss' \ 1383 -not -name '*.serialized' \ 1384 -not -name '*.sh' \ 1385 -not -name '*.snapshot' \ 1386 -not -name '*.sql' \ 1387 -not -name '*.svg' \ 1388 -not -name '*.tar.tz' \ 1389 -not -name '*.template' \ 1390 -not -name '*.whl' \ 1391 -not -name '*.xcconfig' \ 1392 -not -name '*.xcoverage.*' \ 1393 -not -name '*/classycle/report.xml' \ 1394 -not -name '*codecov.yml' \ 1395 -not -name '*~' \ 1396 -not -name '.*coveragerc' \ 1397 -not -name '.coverage*' \ 1398 -not -name 'coverage-summary.json' \ 1399 -not -name 'createdFiles.lst' \ 1400 -not -name 'fullLocaleNames.lst' \ 1401 -not -name 'include.lst' \ 1402 -not -name 'inputFiles.lst' \ 1403 -not -name 'phpunit-code-coverage.xml' \ 1404 -not -name 'phpunit-coverage.xml' \ 1405 -not -name 'remapInstanbul.coverage*.json' \ 1406 -not -name 'scoverage.measurements.*' \ 1407 -not -name 'test_*_coverage.txt' \ 1408 -not -name 'testrunner-coverage*' \ 1409 -print 2>/dev/null" 1410 files=$(eval "$patterns" || echo '') 1411 1412 elif [ "$include_cov" != "" ]; 1413 then 1414 files=$(eval "find $search_in -type f \( ${include_cov:5} \)$exclude_cov 2>/dev/null" || echo '') 1415 elif [ "$direct_file_upload" != "" ]; 1416 then 1417 files=$direct_file_upload 1418 fi 1419 1420 num_of_files=$(echo "$files" | wc -l | tr -d ' ') 1421 if [ "$num_of_files" != '' ] && [ "$files" != '' ]; 1422 then 1423 say " ${e}->${x} Found $num_of_files reports" 1424 fi 1425 1426 # no files found 1427 if [ "$files" = "" ]; 1428 then 1429 say "${r}-->${x} No coverage report found." 1430 say " Please visit ${b}http://docs.codecov.io/docs/supported-languages${x}" 1431 exit ${exit_with}; 1432 fi 1433 1434 if [ "$ft_network" == "1" ]; 1435 then 1436 say "${e}==>${x} Detecting git/mercurial file structure" 1437 network=$(cd "$git_root" && git ls-files $git_ls_files_recurse_submodules_o 2>/dev/null || hg locate 2>/dev/null || echo "") 1438 if [ "$network" = "" ]; 1439 then 1440 network=$(find "$git_root" \( \ 1441 -name virtualenv \ 1442 -name .virtualenv \ 1443 -name virtualenvs \ 1444 -name .virtualenvs \ 1445 -name '*.png' \ 1446 -name '*.gif' \ 1447 -name '*.jpg' \ 1448 -name '*.jpeg' \ 1449 -name '*.md' \ 1450 -name .env \ 1451 -name .envs \ 1452 -name env \ 1453 -name envs \ 1454 -name .venv \ 1455 -name .venvs \ 1456 -name venv \ 1457 -name venvs \ 1458 -name .git \ 1459 -name .egg-info \ 1460 -name shunit2-2.1.6 \ 1461 -name vendor \ 1462 -name __pycache__ \ 1463 -name node_modules \ 1464 -path "*/$bower_components/*" \ 1465 -path '*/target/delombok/*' \ 1466 -path '*/build/lib/*' \ 1467 -path '*/js/generated/coverage/*' \ 1468 \) -prune -or \ 1469 -type f -print 2>/dev/null || echo '') 1470 fi 1471 1472 if [ "$network_filter_o" != "" ]; 1473 then 1474 network=$(echo "$network" | grep -e "$network_filter_o/*") 1475 fi 1476 if [ "$prefix_o" != "" ]; 1477 then 1478 network=$(echo "$network" | awk "{print \"$prefix_o/\"\$0}") 1479 fi 1480 fi 1481 1482 upload_file=$(mktemp /tmp/codecov.XXXXXX) 1483 adjustments_file=$(mktemp /tmp/codecov.adjustments.XXXXXX) 1484 1485 cleanup() { 1486 rm -f "$upload_file" "$adjustments_file" "$upload_file.gz" 1487 } 1488 1489 trap cleanup INT ABRT TERM 1490 1491 1492 if [ "$env" != "" ]; 1493 then 1494 inc_env="" 1495 say "${e}==>${x} Appending build variables" 1496 for varname in $(echo "$env" | tr ',' ' ') 1497 do 1498 if [ "$varname" != "" ]; 1499 then 1500 say " ${g}+${x} $varname" 1501 inc_env="${inc_env}${varname}=$(eval echo "\$${varname}") 1502 " 1503 fi 1504 done 1505 echo "$inc_env<<<<<< ENV" >> "$upload_file" 1506 fi 1507 1508 # Append git file list 1509 # write discovered yaml location 1510 if [ "$direct_file_upload" = "" ]; 1511 then 1512 echo "$yaml" >> "$upload_file" 1513 fi 1514 1515 if [ "$ft_network" == "1" ]; 1516 then 1517 i="woff|eot|otf" # fonts 1518 i="$i|gif|png|jpg|jpeg|psd" # images 1519 i="$i|ptt|pptx|numbers|pages|md|txt|xlsx|docx|doc|pdf|csv" # docs 1520 i="$i|.gitignore" # supporting docs 1521 1522 if [ "$ft_html" != "1" ]; 1523 then 1524 i="$i|html" 1525 fi 1526 1527 if [ "$ft_yaml" != "1" ]; 1528 then 1529 i="$i|yml|yaml" 1530 fi 1531 1532 echo "$network" | grep -vwE "($i)$" >> "$upload_file" 1533 fi 1534 echo "<<<<<< network" >> "$upload_file" 1535 1536 if [ "$direct_file_upload" = "" ]; 1537 then 1538 fr=0 1539 say "${e}==>${x} Reading reports" 1540 while IFS='' read -r file; 1541 do 1542 # read the coverage file 1543 if [ "$(echo "$file" | tr -d ' ')" != '' ]; 1544 then 1545 if [ -f "$file" ]; 1546 then 1547 report_len=$(wc -c < "$file") 1548 if [ "$report_len" -ne 0 ]; 1549 then 1550 say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" 1551 # append to to upload 1552 _filename=$(basename "$file") 1553 if [ "${_filename##*.}" = 'gcov' ]; 1554 then 1555 { 1556 echo "# path=$(echo "$file.reduced" | sed "s|^$git_root/||")"; 1557 # get file name 1558 head -1 "$file"; 1559 } >> "$upload_file" 1560 # 1. remove source code 1561 # 2. remove ending bracket lines 1562 # 3. remove whitespace 1563 # 4. remove contextual lines 1564 # 5. remove function names 1565 awk -F': *' '{print $1":"$2":"}' "$file" \ 1566 | sed '\/: *} *$/d' \ 1567 | sed 's/^ *//' \ 1568 | sed '/^-/d' \ 1569 | sed 's/^function.*/func/' >> "$upload_file" 1570 else 1571 { 1572 echo "# path=${file//^$git_root/||}"; 1573 cat "$file"; 1574 } >> "$upload_file" 1575 fi 1576 echo "<<<<<< EOF" >> "$upload_file" 1577 fr=1 1578 if [ "$clean" = "1" ]; 1579 then 1580 rm "$file" 1581 fi 1582 else 1583 say " ${r}-${x} Skipping empty file $file" 1584 fi 1585 else 1586 say " ${r}-${x} file not found at $file" 1587 fi 1588 fi 1589 done <<< "$(echo -e "$files")" 1590 1591 if [ "$fr" = "0" ]; 1592 then 1593 say "${r}-->${x} No coverage data found." 1594 say " Please visit ${b}http://docs.codecov.io/docs/supported-languages${x}" 1595 say " search for your projects language to learn how to collect reports." 1596 exit ${exit_with}; 1597 fi 1598 else 1599 cp "$direct_file_upload" "$upload_file" 1600 if [ "$clean" = "1" ]; 1601 then 1602 rm "$direct_file_upload" 1603 fi 1604 fi 1605 1606 if [ "$ft_fix" = "1" ]; 1607 then 1608 say "${e}==>${x} Appending adjustments" 1609 say " ${b}https://docs.codecov.io/docs/fixing-reports${x}" 1610 1611 empty_line='^[[:space:]]*$' 1612 # // 1613 syntax_comment='^[[:space:]]*//.*' 1614 # /* or */ 1615 syntax_comment_block='^[[:space:]]*(\/\*|\*\/)[[:space:]]*$' 1616 # { or } 1617 syntax_bracket='^[[:space:]]*[\{\}][[:space:]]*(//.*)?$' 1618 # [ or ] 1619 syntax_list='^[[:space:]]*[][][[:space:]]*(//.*)?$' 1620 # func ... { 1621 syntax_go_func='^[[:space:]]*[func].*[\{][[:space:]]*$' 1622 1623 # shellcheck disable=SC2089 1624 skip_dirs="-not -path '*/$bower_components/*' \ 1625 -not -path '*/node_modules/*'" 1626 1627 cut_and_join() { 1628 awk 'BEGIN { FS=":" } 1629 $3 ~ /\/\*/ || $3 ~ /\*\// { print $0 ; next } 1630 $1!=key { if (key!="") print out ; key=$1 ; out=$1":"$2 ; next } 1631 { out=out","$2 } 1632 END { print out }' 2>/dev/null 1633 } 1634 1635 if echo "$network" | grep -m1 '.kt$' 1>/dev/null; 1636 then 1637 # skip brackets and comments 1638 cd "$git_root" && \ 1639 find . -type f \ 1640 -name '*.kt' \ 1641 -exec \ 1642 grep -nIHE -e "$syntax_bracket" \ 1643 -e "$syntax_comment_block" {} \; \ 1644 | cut_and_join \ 1645 >> "$adjustments_file" \ 1646 || echo '' 1647 1648 # last line in file 1649 cd "$git_root" && \ 1650 find . -type f \ 1651 -name '*.kt' -exec \ 1652 wc -l {} \; \ 1653 | while read -r l; do echo "EOF: $l"; done \ 1654 2>/dev/null \ 1655 >> "$adjustments_file" \ 1656 || echo '' 1657 fi 1658 1659 if echo "$network" | grep -m1 '.go$' 1>/dev/null; 1660 then 1661 # skip empty lines, comments, and brackets 1662 cd "$git_root" && \ 1663 find . -type f \ 1664 -not -path '*/vendor/*' \ 1665 -not -path '*/caches/*' \ 1666 -name '*.go' \ 1667 -exec \ 1668 grep -nIHE \ 1669 -e "$empty_line" \ 1670 -e "$syntax_comment" \ 1671 -e "$syntax_comment_block" \ 1672 -e "$syntax_bracket" \ 1673 -e "$syntax_go_func" \ 1674 {} \; \ 1675 | cut_and_join \ 1676 >> "$adjustments_file" \ 1677 || echo '' 1678 fi 1679 1680 if echo "$network" | grep -m1 '.dart$' 1>/dev/null; 1681 then 1682 # skip brackets 1683 cd "$git_root" && \ 1684 find . -type f \ 1685 -name '*.dart' \ 1686 -exec \ 1687 grep -nIHE \ 1688 -e "$syntax_bracket" \ 1689 {} \; \ 1690 | cut_and_join \ 1691 >> "$adjustments_file" \ 1692 || echo '' 1693 fi 1694 1695 if echo "$network" | grep -m1 '.php$' 1>/dev/null; 1696 then 1697 # skip empty lines, comments, and brackets 1698 cd "$git_root" && \ 1699 find . -type f \ 1700 -not -path "*/vendor/*" \ 1701 -name '*.php' \ 1702 -exec \ 1703 grep -nIHE \ 1704 -e "$syntax_list" \ 1705 -e "$syntax_bracket" \ 1706 -e '^[[:space:]]*\);[[:space:]]*(//.*)?$' \ 1707 {} \; \ 1708 | cut_and_join \ 1709 >> "$adjustments_file" \ 1710 || echo '' 1711 fi 1712 1713 if echo "$network" | grep -m1 '\(.c\.cpp\|.cxx\|.h\|.hpp\|.m\|.swift\|.vala\)$' 1>/dev/null; 1714 then 1715 # skip brackets 1716 # shellcheck disable=SC2086,SC2090 1717 cd "$git_root" && \ 1718 find . -type f \ 1719 $skip_dirs \ 1720 \( \ 1721 -name '*.c' \ 1722 -or -name '*.cpp' \ 1723 -or -name '*.cxx' \ 1724 -or -name '*.h' \ 1725 -or -name '*.hpp' \ 1726 -or -name '*.m' \ 1727 -or -name '*.swift' \ 1728 -or -name '*.vala' \ 1729 \) -exec \ 1730 grep -nIHE \ 1731 -e "$empty_line" \ 1732 -e "$syntax_bracket" \ 1733 -e '// LCOV_EXCL' \ 1734 {} \; \ 1735 | cut_and_join \ 1736 >> "$adjustments_file" \ 1737 || echo '' 1738 1739 # skip brackets 1740 # shellcheck disable=SC2086,SC2090 1741 cd "$git_root" && \ 1742 find . -type f \ 1743 $skip_dirs \ 1744 \( \ 1745 -name '*.c' \ 1746 -or -name '*.cpp' \ 1747 -or -name '*.cxx' \ 1748 -or -name '*.h' \ 1749 -or -name '*.hpp' \ 1750 -or -name '*.m' \ 1751 -or -name '*.swift' \ 1752 -or -name '*.vala' \ 1753 \) -exec \ 1754 grep -nIH '// LCOV_EXCL' \ 1755 {} \; \ 1756 >> "$adjustments_file" \ 1757 || echo '' 1758 1759 fi 1760 1761 found=$(< "$adjustments_file" tr -d ' ') 1762 1763 if [ "$found" != "" ]; 1764 then 1765 say " ${g}+${x} Found adjustments" 1766 { 1767 echo "# path=fixes"; 1768 cat "$adjustments_file"; 1769 echo "<<<<<< EOF"; 1770 } >> "$upload_file" 1771 rm -rf "$adjustments_file" 1772 else 1773 say " ${e}->${x} No adjustments found" 1774 fi 1775 fi 1776 1777 if [ "$url_o" != "" ]; 1778 then 1779 url="$url_o" 1780 fi 1781 1782 if [ "$dump" != "0" ]; 1783 then 1784 # trim whitespace from query 1785 say " ${e}->${x} Dumping upload file (no upload)" 1786 echo "$url/upload/v4?$(echo "package=$package-$VERSION&token=$token&$query" | tr -d ' ')" 1787 cat "$upload_file" 1788 else 1789 if [ "$save_to" != "" ]; 1790 then 1791 say "${e}==>${x} Copying upload file to ${save_to}" 1792 mkdir -p "$(dirname "$save_to")" 1793 cp "$upload_file" "$save_to" 1794 fi 1795 1796 say "${e}==>${x} Gzipping contents" 1797 gzip -nf9 "$upload_file" 1798 say " $(du -h "$upload_file.gz")" 1799 1800 query=$(echo "${query}" | tr -d ' ') 1801 say "${e}==>${x} Uploading reports" 1802 say " ${e}url:${x} $url" 1803 say " ${e}query:${x} $query" 1804 1805 # Full query without token (to display on terminal output) 1806 queryNoToken=$(echo "package=$package-$VERSION&token=secret&$query" | tr -d ' ') 1807 # now add token to query 1808 query=$(echo "package=$package-$VERSION&token=$token&$query" | tr -d ' ') 1809 1810 if [ "$ft_s3" = "1" ]; 1811 then 1812 say "${e}->${x} Pinging Codecov" 1813 say "$url/upload/v4?$queryNoToken" 1814 # shellcheck disable=SC2086,2090 1815 res=$(curl $curl_s -X POST $cacert \ 1816 --retry 5 --retry-delay 2 --connect-timeout 2 \ 1817 -H 'X-Reduced-Redundancy: false' \ 1818 -H 'X-Content-Type: application/x-gzip' \ 1819 -H 'Content-Length: 0' \ 1820 --write-out "\n%{response_code}\n" \ 1821 $curlargs \ 1822 "$url/upload/v4?$query" || true) 1823 # a good reply is "https://codecov.io" + "\n" + "https://storage.googleapis.com/codecov/..." 1824 s3target=$(echo "$res" | sed -n 2p) 1825 status=$(tail -n1 <<< "$res") 1826 1827 if [ "$status" = "200" ] && [ "$s3target" != "" ]; 1828 then 1829 say "${e}->${x} Uploading to" 1830 say "${s3target}" 1831 1832 # shellcheck disable=SC2086 1833 s3=$(curl -fiX PUT \ 1834 --data-binary @"$upload_file.gz" \ 1835 -H 'Content-Type: application/x-gzip' \ 1836 -H 'Content-Encoding: gzip' \ 1837 $curlawsargs \ 1838 "$s3target" || true) 1839 1840 if [ "$s3" != "" ]; 1841 then 1842 say " ${g}->${x} Reports have been successfully queued for processing at ${b}$(echo "$res" | sed -n 1p)${x}" 1843 exit 0 1844 else 1845 say " ${r}X>${x} Failed to upload" 1846 fi 1847 elif [ "$status" = "400" ]; 1848 then 1849 # 400 Error 1850 say "${r}${res}${x}" 1851 exit ${exit_with} 1852 else 1853 say "${r}${res}${x}" 1854 fi 1855 fi 1856 1857 say "${e}==>${x} Uploading to Codecov" 1858 1859 # shellcheck disable=SC2086,2090 1860 res=$(curl -X POST $cacert \ 1861 --data-binary @"$upload_file.gz" \ 1862 --retry 5 --retry-delay 2 --connect-timeout 2 \ 1863 -H 'Content-Type: text/plain' \ 1864 -H 'Content-Encoding: gzip' \ 1865 -H 'X-Content-Encoding: gzip' \ 1866 -H 'Accept: text/plain' \ 1867 $curlargs \ 1868 "$url/upload/v2?$query&attempt=$i" || echo 'HTTP 500') 1869 # HTTP 200 1870 # http://.... 1871 status=$(echo "$res" | head -1 | cut -d' ' -f2) 1872 if [ "$status" = "" ] || [ "$status" = "200" ]; 1873 then 1874 say " Reports have been successfully queued for processing at ${b}$(echo "$res" | head -2 | tail -1)${x}" 1875 exit 0 1876 else 1877 say " ${g}${res}${x}" 1878 exit ${exit_with} 1879 fi 1880 1881 say " ${r}X> Failed to upload coverage reports${x}" 1882 fi 1883 1884 exit ${exit_with}