bintray:
  repository:
    type: rpm
    name: el7
    description: Performance Co-Pilot for EL7

container:
  containerfile: |
    FROM registry.centos.org/centos:7
    RUN yum install -y sudo
    RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # libuv-devel
    RUN useradd --create-home pcpbuild
    RUN echo 'pcpbuild ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pcpbuild

tasks:
  update: |
    sudo yum update -y
  install_build_dependencies: |
    sudo yum install -y which
    sudo yum -y install $(./pcp/qa/admin/list-packages -m -v -x cpan -x pip3 -x not4ci)
  build: |
    cd ./pcp
    ./Makepkgs --verbose
    rpm -qp --requires $(echo ./pcp-*/build/rpm/pcp-*.src.rpm | sed 's/src/x86_64/') | grep -q libuv.so
  copy_build_artifacts: |
    cp ./pcp/pcp-*/build/rpm/*.rpm ./artifacts/build
  install: |
    sudo rpm -iv ./pcp/pcp-*/build/rpm/*.rpm
    echo 'pcpqa ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/pcpqa
  init_qa: |
    sudo -i -u pcpqa ./check 002
  qa_sanity: |
    set -o pipefail
    if [ "$runner" = "container" ]; then
      sudo -i -u pcpqa ./check -TT -g sanity -x not_in_ci -x not_in_container |& tee ./artifacts/test/test.log
    else
      sudo -i -u pcpqa ./check -TT -g sanity -x not_in_ci |& tee ./artifacts/test/test.log
    fi
  qa: |
    set -o pipefail
    if [ "$runner" = "container" ]; then
      sudo -i -u pcpqa ./check -TT -x x11 -x remote -x not_in_ci -x not_in_container |& tee ./artifacts/test/test.log
    else
      sudo -i -u pcpqa ./check -TT -x x11 -x remote -x not_in_ci |& tee ./artifacts/test/test.log
    fi
  copy_test_artifacts: |
    cp /var/lib/pcp/testsuite/check.timings ./artifacts/test
    [ $(awk 'END{print NF}' ./artifacts/test/check.timings) = 2 ] && date '+%s' >> ./artifacts/test/check.timings
    shopt -s nullglob
    for test in /var/lib/pcp/testsuite/*.out.bad; do cp $test ${test/.out.bad/.full} ./artifacts/test || true; done
