Appveyor: FIND: Parameter format not correct

Description

I’m trying to integrate Codecov in a series of PHP packages that belong to the Doctrine organization on Github. It seems to work great on Travis. On Appveyor, it’s another story: there seems to be an upload occuring, but there are warnings as shown in the title that makes the build fail.

Repository


The PR to add Coveralls is at https://github.com/doctrine/dbal/pull/4047
The failing job can be found at https://ci.appveyor.com/project/doctrine/dbal/builds/33275522/job/6ihlafe9pudgsdir

CI/CD

Appveyor

Uploader

Bash

Commit SHAs

af5df0949bbcf4458b553705de8cded266d3bf29

Codecov YAML

I didn’t add such a file

Codecov Output

Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
$env:APPVEYOR="true"
$env:CI="true"
bash codecov.sh -f "clover.xml"
  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                              Bash-20200602-f809a24
==> Appveyor CI detected.
    project root: C:/projects/dbal
    Fixing merge commit SHA
    Yaml not found, that's ok! Learn more at http://docs.codecov.io/docs/codecov-yaml
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + clover.xml bytes=929368
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
bash : FIND: Parameter format not correct
At line:4 char:1
+ bash codecov.sh -f "clover.xml"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (FIND: Parameter format not correct:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
FIND: Parameter format not correct
FIND: Parameter format not correct
    -> No adjustments found
==> Gzipping contents
==> Uploading reports
    url: https://codecov.io
    query: branch=2.10.x&commit=af5df0949bbcf4458b553705de8cded266d3bf29&build=6ihlafe9pudgsdir&build_url=https%3A%2F%2Fci.appveyor.com%2Fproject%2Fdoctrine%2Fdbal%2Fbuilds%2F33275522%2Fjob%2F6ihlafe9pudgsdir&name=&tag=&slug=doctrine%2Fdbal&service=appveyor&flags=&pr=4047&job=doctrine%2Fdbal%2F1.0.3589
    -> Pinging Codecov
https://codecov.io/upload/v4?package=bash-20200602-f809a24&token=secret&branch=2.10.x&commit=af5df0949bbcf4458b553705de8cded266d3bf29&build=6ihlafe9pudgsdir&build_url=https%3A%2F%2Fci.appveyor.com%2Fproject%2Fdoctrine%2Fdbal%2Fbuilds%2F33275522%2Fjob%2F6ihlafe9pudgsdir&name=&tag=&slug=doctrine%2Fdbal&service=appveyor&flags=&pr=4047&job=doctrine%2Fdbal%2F1.0.3589
    -> Uploading
    -> View reports at https://codecov.io/github/doctrine/dbal/commit/af5df0949bbcf4458b553705de8cded266d3bf29
Command executed with exception: FIND: Parameter format not correct

Steps to Reproduce

  1. Push any commit

Expected behavior: Coverage reports are uploaded and the build is green

Actual behavior: Coverage reports are uploaded and the AppVeyor job is red

Flakiness? not flaky

Hi @greg0ire, I made a small adjustment in the PR. Let me know if that fixes the issue, and if not, we can dig in a little deeper here.

Hi @tom, thanks for your answer, sadly it looks like it did not help. From the error message, I think the issues is with how FIND, a program that exists both on Linux and on Windows, but might have small variations from one OS to the other, is called. Let’ see if there are any occurrences of it in the bash script.

207:    find "$_dir" -name "*.$_type" | while read f
208-    do
209-      _proj=${f##*/}
--
857:# find branch, commit, repo from git command
858-if [ "$GIT_BRANCH" != "" ];
859-then
--
936:       || cd $proj_root && find . -maxdepth 1 -type f -name '*codecov.y*ml' 2>/dev/null \
937-       || echo '')
938-yaml=$(echo "$yaml" | head -1)
--
1021:    profdata_files=$(find "$ddp" -name '*.profdata' 2>/dev/null || echo '')
1022-    if [ "$profdata_files" != "" ];
1023-    then
--
1050:        bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" >/dev/null 2>&1 || true
1051-      else
1052:        bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" || true
1053-      fi
1054-    fi
--
1060:    plists_files=$(find "$ddp" -name '*.xccoverage' 2>/dev/null || echo '')
1061-    if [ "$plists_files" != "" ];
1062-    then
--
1081:      bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" >/dev/null 2>&1 || true
1082-    else
1083:      bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" || true
1084-    fi
1085-  else
--
1098:        dotcoverage=$(find "$git_root" -name '.coverage' -or -name '.coverage.*' | head -1 || echo '')
1099-        if [ "$dotcoverage" != "" ];
1100-        then
--
1139:  patterns="find $search_in \( \
1140-                        -name vendor \
1141-                        -or -name htmlcov \
--
1279:  files=$(eval "find $search_in -type f \( ${include_cov:5} \)$exclude_cov 2>/dev/null" || echo '')
1280-fi
1281-
--
1302:    network=$(find "$git_root" \( \
1303-                   -name virtualenv \
1304-                   -name .virtualenv \
--
1471:    find "$git_root" -type f \
1472-                     -name '*.kt' \
1473-                     -exec \
--
1481:    find "$git_root" -type f \
1482-                     -name '*.kt' -exec \
1483-      wc -l {} \; \
--
1494:    find "$git_root" -not -path '*/vendor/*' \
1495-                     -type f \
1496-                     -name '*.go' \
--
1512:    find "$git_root" -type f \
1513-                     -name '*.dart' \
1514-                     -exec \
--
1526:    find "$git_root" -not -path "*/vendor/*" \
1527-                     -type f \
1528-                     -name '*.php' \
--
1543:    find "$git_root" -type f \
1544-                     $skip_dirs \
1545-         \( \
--
1564:    find "$git_root" -type f \
1565-                     $skip_dirs \
1566-         \( \

Looks like there are occurrences, but not at line 4, which is the line the message complains about.

There is an occurence at line 4 of this function though:

swiftcov() {
  _dir=$(dirname "$1" | sed 's/\(Build\).*/\1/g')
  for _type in app framework xctest
  do
    find "$_dir" -name "*.$_type" | while read f
    do
      _proj=${f##*/}
      _proj=${_proj%."$_type"}
      if [ "$2" = "" ] || [ "$(echo "$_proj" | grep -i "$2")" != "" ];
      then
        say "    $g+$x Building reports for $_proj $_type"
        dest=$([ -f "$f/$_proj" ] && echo "$f/$_proj" || echo "$f/Contents/MacOS/$_proj")
        _proj_name=$(echo "$_proj" | sed -e 's/[[:space:]]//g')
        xcrun llvm-cov show $beta_xcode_partials -instr-profile "$1" "$dest" > "$_proj_name.$_type.coverage.txt" \
         || say "    ${r}x>${x} llvm-cov failed to produce results for $dest"
      fi
    done
  done
}

Also, it looks like parameters to find should be quoted, and in many occurrences, they are not, like at line 4 of this $() command substitution:

yaml=$(cd "$git_root" && \
          git ls-files "*codecov.yml" "*codecov.yaml" 2>/dev/null \
       || hg locate "*codecov.yml" "*codecov.yaml" 2>/dev/null \
       || cd $proj_root && find . -maxdepth 1 -type f -name '*codecov.y*ml' 2>/dev/null \
       || echo '')

When I paste this script into shellcheck, there are many suggestions that might help make it more portable: https://www.shellcheck.net/ . Consider adding it to your CI.

Thanks for this @greg0ire, I’m going to work through the Shellcheck errors this week. Feel free to follow along or help here.

I fixed my issue by switching the download program to appveyor DownloadFile https://codecov.io/bash -FileName codecov.sh