我有一个 Travis CI 构建矩阵,旨在测试最近的 g++ 和 clang。除了这两个预期的条目之外,我还看到一个条目 AFAIK,未在包含矩阵中指定。我怎样才能抑制或删除这第三个构建配置?
.travis.yml
:
language: generic
os: linux
script: ./bootstrap && ./configure && make all && make check && make distcheck
matrix:
include:
- env: COMPILER_NAME=gcc CXX=g++-5 CC=gcc-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- autotools-dev
- g++-5
- env: COMPILER_NAME=clang CXX=clang++-3.8 CC=clang-3.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages:
- autotools-dev
- clang-3.8
Travis 的输出片段取自 full details :
最佳答案
从文档中,“os 键也乘以矩阵”:
If your code is used on multiple operating systems it probably should be tested on multiple operating systems. Travis CI can test on Linux and OS X.
To enable testing on multiple operating systems add the os key to your .travis.yml:
os:
- linux
- osx
$TRAVIS_OS_NAME 变量的值设置为 linux 或 osx 根据运行特定构建的操作系统,所以 您可以使用它来条件化您的构建脚本。
如果您已经在使用构建矩阵来测试多个版本,则 os 键也乘以矩阵。
来源:https://docs.travis-ci.com/user/multi-os/
使用多个 os
键构建:
例如,对于每个单独的“os”键,它会创建另一个构建。看这里:https://github.com/jaredsburrows/cplusplus-cmake-template/blob/master/.travis.yml#L3或 https://github.com/jaredsburrows/open-virus/blob/master/.travis.yml#L3 .
由于默认的“os”是 linux,因此在您自己的问题中暗示您有 3 个独立的构建,它们都使用“os: linux”。
使用不同的 os
键构建矩阵:
例如,现在每个键都在矩阵中的不同行中指定。看这里:https://github.com/jaredsburrows/cs-interview-questions/blob/master/.travis.yml#L3和 https://github.com/jaredsburrows/android-gif-example/blob/master/.travis.yml#L8 .
在您的问题中,您不仅指定了“矩阵”构建,还指定了具有不同操作系统的普通构建。指定“矩阵”时,您将覆盖默认的“操作系统”构建。但是你明确地写了“os”和“matrix”,暗示你想要 3 个单独的构建。
关于c++ - Travis CI 构建矩阵包含虚假条目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39682792/