【问题标题】:Travis CI fails to parse .travis.ymlTravis CI 无法解析 .travis.yml
【发布时间】:2019-10-05 15:18:45
【问题描述】:

我有这个travis.yml travis-ci.org 抱怨它无法解析。

language: rust
rust:
  - 1.31.0
  - stable
  - beta
  - nightly
matrix:
  allow_failures:
    - rust: nightly
sudo: false
before_script:
  - rustup component add rustfmt
  - rustup target add thumbv7em-none-eabihf     # Any target that does not have a standard library will do
script:
  - cargo fmt --all -- --check
  - (rustup component add clippy && cargo clippy --all -- -D clippy::all) || true
  - cargo build
  - cargo test
  - cargo build --no-default-features --features alloc --target thumbv7em-none-eabihf # Test we can build a platform that does not have std.
  - cargo test --no-default-features --lib --tests # Run no_std tests
  - [[ $TRAVIS_RUST_VERSION != "1.31.0" ]] && cargo build --no-default-features --features alloc
  - cargo build --features unsealed_read_write # The crate should still build when the unsealed_read_write feature is enabled.
  - cargo build --no-default-features --features unsealed_read_write # The crate should still build when the unsealed_read_write feature is enabled and std disabled.

此文件属于https://github.com/pyfisch/cbor,显然导致解析失败的行是- [[ $TRAVIS_RUST_VERSION != "1.31.0" ]] && cargo build --no-default-features --features alloc

Online Travis.yml validation 不太有用(已弃用并删除,无需替换)。

需要进行哪些更改才能让 Travis 再次构建?

【问题讨论】:

    标签: yaml travis-ci


    【解决方案1】:

    [ 字符在 YAML 中很特殊,就像其他几个字符一样。 如果你的字符串以它开头,你需要引用它。

    我建议对更长的字符串使用块标量。您可以使用文字块标量,按原样使用:

    - |
      [[ $TRAVIS_RUST_VERSION != "1.31.0" ]] && cargo build --no-default-features --features alloc
    

    或折叠块标量,它允许您将行拆分为多行。它将与空格一起折叠:

    - >
      [[ $TRAVIS_RUST_VERSION != "1.31.0" ]]
      && cargo build --no-default-features --features alloc
    

    如果您想了解更多关于在 YAML 中引用字符串的信息,我可以推荐 my article on this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-06
      • 1970-01-01
      相关资源
      最近更新 更多