rraallvv
rraallvv

Reputation: 2933

How to prevent Travis-CI to terminate a job?

I have a bunch of files that need to be copied over to a tmp/ directory and then compressed.

I tried cp -rf $SRC $DST but the job is terminated before the command is complete. The verbose option int help either because the log file exceeds the size limit.

I wrote a small function to print only a percentage bar, but I get the same problem with the log size limit so maybe I need to redirect stdout to stderr but I'm not sure.

This is the snippet with the function:

function cp_p() {
  local files=0
  while IFS= read -r -d '' file; do ((files++)); done < <(find -L $1 -mindepth 1 -name '*.*' -print0)
  local duration=$(tput cols)
  duration=$(($duration<80?$duration:80-8))
  local count=1
  local elapsed=1
  local bar=""

  already_done() {
    bar="\r|"
    for ((done=0; done<$(( ($elapsed)*($duration)/100 )); done++)); do
      printf -v bar "$bar▇"
    done
  }
  remaining() {
    for ((remain=$(( ($elapsed)*($duration)/100 )); remain<$duration; remain++)); do
      printf -v bar "$bar "
    done
    printf -v bar "$bar|"
  }
  percentage() {
    printf -v bar "$bar%3d%s" $elapsed '%%'
  }

  mkdir -p "$2/$1"
  chmod `stat -f %A "$1"` "$2/$1"

  while IFS= read -r -d '' file; do
    file=$(echo $file | sed 's|^\./\(.*\)|"\1"|')
    elapsed=$(( (($count)*100)/($files) ))
    already_done
    remaining
    percentage
    printf "$bar"
    if [[ -d "$file" ]]; then
      dst=$2/$file
      test -d "$dst" || (mkdir -p "$dst" && chmod `stat -f %A "$file"` "$dst")
    else
      src=${file%/*}
      dst=$2/$src
      test -d "$dst" || (mkdir -p "$dst" && chmod `stat -f %A "$src"` "$dst")
      cp -pf "$file" "$2/$file"
    fi
    ((count++))
  done < <(find -L $1 -mindepth 1 -name '*.*' -print0)

  printf "\r"
}

This is the error I get

packaging files (this may take several minutes) ...

|▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ | 98%

The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).

The job has been terminated

Upvotes: 0

Views: 241

Answers (1)

joepd
joepd

Reputation: 4841

Have you tried travis_wait cp -rf $SRC $DST? See https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received for details.

Also, I believe that generally disk operations are rather slow on macOS builds. You might be better off compressing the file structure while the files are touched. Assuming you want to gzip the thing:

travis_wait tar -zcf $DST.tar.gz $SRC

Upvotes: 1

Related Questions