freedomlayer / offset

Offset payment engine
https://www.offsetcredit.org
Other
164 stars 20 forks source link

Having rust nightly version pinned in a single place #209

Closed realcr closed 5 years ago

realcr commented 5 years ago

We currently have the pinned rust nightly version in use scattered in a few places. (1) The file: rust-toolchain (See here: https://github.com/rust-lang/rustup.rs#the-toolchain-file) (2) .travis.yml contains the used nightly version in three places (See snippet below).

This means that every time we bump rust nightly's version we have to modify all those places at the same time. Is it somehow possible for us to make .travis.yml find the pinned rust nightly version from the rust-toolchain file automatically?

Snippet from .travis.yml (Containing rust nightly version 3 times):

  - env: TARGET=x86_64-unknown-linux-gnu CC=gcc-6 CXX=g++-6 RUSTFLAGS="-C link-dead-code"
    os: linux
    dist: trusty
    rust: nightly-2019-06-07
    addons:
      apt:
        packages:
        - gcc-6
        - g++-6
        sources:
        - ubuntu-toolchain-r-test
    script:
    - travis/trusty/pre/cargo-config.sh
    - travis/trusty/pre/capnp.sh
    - cargo fmt --all -- --check
      # TODO: Enable these two lints when clippy bugs are solved:
    - cargo clippy -- -A clippy::needless_lifetimes -A clippy::identity_conversion
      # We add target dir so that kcov can find the test files to run:
    - cargo test --target ${TARGET}
    - travis/trusty/post/kcov/try-install.sh
    - travis/trusty/post/kcov/run.sh

  - env: TARGET=x86_64-apple-darwin
    os: osx
    rust: nightly-2019-06-07
    osx_image: xcode9.4.1
    before_script:
    - brew install capnp
    script:
    - cargo test

  - env: TARGET=x86_64-pc-windows-msvc
    os: windows
    # Used as a temporary fix for windows CI issue in travis.
    # See: https://travis-ci.community/t/windows-instances-hanging-before-install/250/25
    filter_secrets: false
    rust: nightly-2019-06-07
    ...

EDIT: See: https://github.com/travis-ci/travis-build/pull/1513

pzmarzly commented 5 years ago

Looking at Travis rust.rb, it appears it's using rust: value just for TRAVIS_RUST_VERSION and for rustup-init.sh --default-toolchain parameter.

When rustup-init.sh is called with --default-toolchain=none, it doesn't install any toolchains, but it does create cargo and rustc files that just print error: no default toolchain configured unless they find rust-toolchain file. So, setting rust: none could be perfect for us.

TRAVIS_RUST_VERSION is used only in cargo-sweep.sh right now, and could easily be eliminated from there. We would just need to remember not to use it.

Alternatively, we could stop using Travis Rust integration. Then in our .travis.yml we would need:

By the way, it seems like we have redundant .cargo caching settings in .travis.yml right now. Seems harmless.