Travis CI fails to parse .travis.yml

I have this travis.yml which travis-ci.org complains it can’t parse.

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.

Online Travis.yml validation is less than helpful (deprecated and removed without a replacement).

What changes are needed so Travis does build again?

Hey @OliBarrington,

The [ character is special in YAML, like a few others. If your string starts with it, you need to quote it.

I recommend using a block scalar for longer strings. You can either use a literal block scalar, which will be taken as it is:

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

or a folded block scalar which allows you to split the line over multiple lines. It will be folded together with spaces:

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

I hope this helps Oli, if you need any more help with anything, be sure to post back here!

-Montana

1 Like

That seemed to do the trick. Thanks a bunch!

Glad I could be of help, be sure to post back if you have any more problems.

-Montana

Imprint