TravisCI / Coverity:警告 - 未发出任何文件

TravisCI / Coverity: Warning - No files were emitted

我有一个中等大小的 github 存储库,我为其配置了 Travis-CI/Coverity 工具。大约一个月前,我的设置工作得很好:Travis 编译并构建了我的应用程序,然后执行了 Coverity 扫描,我可以在我的 Coverity 页面上看到结果。

但是,最近 Coverity 分析停止工作了。我查看了 Travis 日志文件,并与构建成功时的旧日志进行了比较,这就是我发现的:

在日志末尾,失败的版本包含下一个警告:

[WARNING] No files were emitted. This may be due to a problem with your configuration or because no files were actually compiled by your build command.

Please make sure you have configured the compilers actually used in the compilation.

For more details, please look at: /home/travis/build/name/repo-name/build/cov-int/build-log.txt

Extracting SCM data for 0 files...

...

因此,Travis 构建通过了,但没有为 Coverity 生成任何内容。我检查了我的 Travis 配置文件,它与 Coverity 构建成功时的提交相同。

为了实验,我克隆了我的项目存储库,回滚到构建成功时的版本并为它们设置 Travis/Coverity。你猜怎么着?同样的警告!因此,过去(大约 35 天前)有效的相同设置不再有效。因此,我得出结论,Travis 发生了一些变化,因为它不生成某些文件。

我想知道是否有人遇到过这个问题?它可能是关于什么的?我需要更改一些 Travis 设置吗?

一些附加信息:我使用 CMake 构建我的项目,它有两个依赖项:Qt 和 OpenSceneGraph(我必须为 Travis 安装)。

这是我的 .travis.yml 在我的 coverity_scan 分支上的大概脚本:

language: cpp
os: linux
compiler: gcc
sudo: required
dist: trusty

addons:
  apt:
    packages:
      - cmake
      - g++-4.8
  coverity_scan:
    project:
      name: "name/project"
      description: "Build submitted via Travis CI"
    notification_email: email@domain.com
    build_command:   "make -j2 VERBOSE=1"
    branch_pattern: coverity_scan

env:
  global:
    - PROJECT_SOURCE=${TRAVIS_BUILD_DIR}/src/
    - PROJECT_BUILD=${TRAVIS_BUILD_DIR}/build/
    # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
    #   via the "travis encrypt" command using the project repo's public key
   - secure: "...secure..."

before_install:
  # download Qt
  # ...
  # download OpenSceneGraph
  # ...
  # imitate x server
  - export DISPLAY=:99.0
  - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
  - sleep 3

install:
  # install Qt
  - sudo apt-get --yes install qt55base qt55imageformats qt55svg 
  # compiler
  - export CXX="g++-4.8"
  - export CC="gcc-4.8"
  # install OpenSceneGraph
  # ...

before_script:
  # Qt location
  # ...
  # OpenSceneGraph variables
  # ...

  # create build folder
  - mkdir $PROJECT_BUILD
  - cd $PROJECT_BUILD 
  # cmake command
  - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/qt54/lib/cmake -DProject_BUILD_TEST=ON -DProject_VERSION=0.0.0 $PROJECT_SOURCE

script:
  - if [[ "${COVERITY_SCAN_BRANCH}" == 1 ]];
    then
      echo "Don't build on coverty_scan branch.";
      exit 0;
    fi
  # compile everything, if not coverity branch
  - make -j2
  # run unit tests
  # ...

经过一些研究和查看现有示例后,我终于让它工作了。要修复警告,并因此确保发出文件以供分析,有必要 明确地 指定编译器二进制文件(根据评论更新)。在我的 .travis.yml 中,我必须在 coverity_scan 附加组件的 build_command 之前添加一个 build_command_prepend。该块的最终外观示例如下:

# ... 
coverity_scan:
    project:
      name: "name/project"
      description: "Build submitted via Travis CI"
    notification_email: name@domain.com

# ! have to specify the binary (updated, thanks to Caleb)
    build_command_prepend: "cov-configure --comptype gcc --compiler gcc-4.8 --template"

    build_command:   "make VERBOSE=1"
    branch_pattern: coverity_scan

# ...