Skip to content
Snippets Groups Projects
.travis.yml 7.62 KiB
Newer Older
Diggory Hardy's avatar
Diggory Hardy committed
language: rust
os: linux
dist: focal
Diggory Hardy's avatar
Diggory Hardy committed

env:
  global:
    # All of the supported x86 Linux targets
    - LINUX_TARGETS="x86_64-unknown-linux-gnu x86_64-unknown-linux-musl i686-unknown-linux-gnu i686-unknown-linux-musl"
    # Targets that we just build (rather than run and test)
    - STD_TARGETS="x86_64-sun-solaris x86_64-unknown-freebsd x86_64-fuchsia x86_64-unknown-netbsd x86_64-unknown-redox x86_64-fortanix-unknown-sgx"
    - NO_STD_TARGETS="x86_64-unknown-cloudabi x86_64-unknown-uefi x86_64-unknown-hermit x86_64-unknown-l4re-uclibc x86_64-uwp-windows-gnu x86_64-wrs-vxworks"
Diggory Hardy's avatar
Diggory Hardy committed
  include:
Joe Richey's avatar
Joe Richey committed
    - name: "Linux, 1.34.0"
      rust: 1.34.0
Joe Richey's avatar
Joe Richey committed
    - name: "OSX, 1.34.0"
      rust: 1.34.0
Diggory Hardy's avatar
Diggory Hardy committed
      os: osx

    - name: "Linux, stable"
      rust: stable
    - name: "OSX+iOS, stable"
      rust: stable
Diggory Hardy's avatar
Diggory Hardy committed
      os: osx
      install:
        - rustup target add aarch64-apple-ios
      script:
        - cargo test
        - cargo build --target aarch64-apple-ios
    - name: "Linux, beta"
      rust: beta
Joe Richey's avatar
Joe Richey committed
    - name: "WASM via stdweb, wasm-bindgen and WASI"
      rust: stable
        # firefox: latest
        chrome: stable
        - rustup target add wasm32-unknown-unknown
        - rustup target add wasm32-wasi
Joe Richey's avatar
Joe Richey committed
        # Get latest geckodriver
        - export VERSION=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ".tag_name")
        - wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/$VERSION/geckodriver-$VERSION-linux64.tar.gz
        - tar -xzf geckodriver.tar.gz -C $HOME
Joe Richey's avatar
Joe Richey committed
        # Get latest chromedirver
        - export VERSION=$(wget -q -O - https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
        - wget -O chromedriver.zip https://chromedriver.storage.googleapis.com/$VERSION/chromedriver_linux64.zip
        - unzip chromedriver.zip -d $HOME
        # Get cargo-web
        # - export VERSION=0.6.26 # Pin version for stability
        # - wget -O cargo-web.gz https://github.com/koute/cargo-web/releases/download/$VERSION/cargo-web-x86_64-unknown-linux-gnu.gz
        # - gunzip cargo-web.gz
        # - chmod +x cargo-web
        # Get wasmtime
        - export VERSION=v0.19.0 # Pin version for stability
Joe Richey's avatar
Joe Richey committed
        - wget -O wasmtime.tar.xz https://github.com/CraneStation/wasmtime/releases/download/$VERSION/wasmtime-$VERSION-x86_64-linux.tar.xz
        - tar -xf wasmtime.tar.xz --strip-components=1
Joe Richey's avatar
Joe Richey committed
        # Get wasm-bindgen-test-runner which matches our wasm-bindgen version
        - export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version')
        - wget -O wasm-bindgen.tar.gz https://github.com/rustwasm/wasm-bindgen/releases/download/$VERSION/wasm-bindgen-$VERSION-x86_64-unknown-linux-musl.tar.gz
        - tar -xzf wasm-bindgen.tar.gz --strip-components=1
        # Place the runner binaries in our PATH
        - mv wasmtime wasm-bindgen-test-runner $HOME/.cargo/bin
        - cargo test --target wasm32-wasi
        # stdweb (wasm32-unknown-unknown) tests are currently broken (see https://github.com/koute/cargo-web/issues/243)
        # - cargo web test --features js --nodejs
        # - cargo web test --features js
        - cargo build --features js
        # wasm-bindgen (wasm32-unknown-unknown) tests (Node, Firefox, Chrome)
        - cargo test --target wasm32-unknown-unknown --features js
        - GECKODRIVER=$HOME/geckodriver
          cargo test --target wasm32-unknown-unknown --features js,test-in-browser
        - CHROMEDRIVER=$HOME/chromedriver
          cargo test --target wasm32-unknown-unknown --features js,test-in-browser
Joe Richey's avatar
Joe Richey committed
    - name: "WASM via Emscripten"
      rust: stable
      env:
        - CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node
        - CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node
      install:
        - rustup target add wasm32-unknown-emscripten
        - rustup target add asmjs-unknown-emscripten
        - export VERSION=2.0.2 # Pin version for stability
Joe Richey's avatar
Joe Richey committed
        - git clone https://github.com/emscripten-core/emsdk.git
        - ./emsdk/emsdk install $VERSION
        - ./emsdk/emsdk activate $VERSION
        - source ./emsdk/emsdk_env.sh
      script:
        - cargo test --target wasm32-unknown-emscripten
        # Prevent 'wasm2js does not support source maps yet' error.
        - RUSTFLAGS='-C debuginfo=0' cargo test --target asmjs-unknown-emscripten


    - &nightly_and_docs
      name: "Linux, nightly, docs"
      rust: nightly
Diggory Hardy's avatar
Diggory Hardy committed
      install:
        - rustup target add wasm32-unknown-unknown
Diggory Hardy's avatar
Diggory Hardy committed
        - cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
        - cargo deadlinks -V
      script:
        # Check that setting various features does not break the build
        - cargo build --features=std
        - cargo build --features=custom
Diggory Hardy's avatar
Diggory Hardy committed
        # remove cached documentation, otherwise files from previous PRs can get included
        - rm -rf target/doc
        - cargo doc --no-deps --features=std,custom
Diggory Hardy's avatar
Diggory Hardy committed
        - cargo deadlinks --dir target/doc
        # Check that our tests pass in the default/minimal configuration
        - cargo test --tests --benches --features=std,custom
        - cargo generate-lockfile -Z minimal-versions
        - cargo test --tests --benches
    - <<: *nightly_and_docs
      name: "OSX, nightly, docs"
Diggory Hardy's avatar
Diggory Hardy committed
      os: osx

    - name: "cross-platform tests"
      rust: nightly
      addons:
        apt:
          packages:
          - gcc-multilib
      install:
        - echo $LINUX_TARGETS | xargs -n1 rustup target add
      script:
        # We run tests for all supported x86 Linux targets
        - echo $LINUX_TARGETS | xargs -t -n1 cargo test --target

    - name: "cross-platform build only"
      rust: nightly
Diggory Hardy's avatar
Diggory Hardy committed
      install:
        - echo $STD_TARGETS | xargs -n1 rustup target add
Joe Richey's avatar
Joe Richey committed
        # For no_std targets
        - rustup component add rust-src
        - cargo --list | egrep "^\s*xbuild$" -q || cargo install cargo-xbuild
Diggory Hardy's avatar
Diggory Hardy committed
      script:
        # We test that getrandom builds for all targets
        - echo $STD_TARGETS | xargs -t -n1 cargo build --target
        - echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=rdrand --target
        # also test minimum dependency versions are usable
        - cargo generate-lockfile -Z minimal-versions
        - echo $STD_TARGETS | xargs -t -n1 cargo build --target
        - echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=rdrand --target
Diggory Hardy's avatar
Diggory Hardy committed

    # Trust cross-built/emulated targets. We must repeat all non-default values.
    - name: "Linux (MIPS, big-endian)"
      env: TARGET=mips-unknown-linux-gnu
      rust: stable
Diggory Hardy's avatar
Diggory Hardy committed
      dist: trusty
      services: docker
      install:
        - sh utils/ci/install.sh
        - source ~/.cargo/env || true
      script:
        - bash utils/ci/script.sh
    - name: "Android (ARMv7)"
      env: TARGET=armv7-linux-androideabi
      rust: stable
Diggory Hardy's avatar
Diggory Hardy committed
      dist: trusty
      services: docker
      install:
        - sh utils/ci/install.sh
        - source ~/.cargo/env || true
      script:
        - bash utils/ci/script.sh

    - name: "rustfmt"
      rust: stable
      install:
        - rustup component add rustfmt
      script:
        - cargo fmt --all -- */*.rs --check

  allow_failures:
    # Formatting errors should appear in Travis, but not break the build.
    - name: "rustfmt"
Diggory Hardy's avatar
Diggory Hardy committed
before_install:
  - set -e
  - rustup self update

before_script:
  - export RUSTFLAGS="-D warnings"

Diggory Hardy's avatar
Diggory Hardy committed
script:
  - cargo test

after_script: set +e

cache:
  cargo: true
  directories:
    - .local/share/cargo-web

before_cache:
  # Travis can't cache files that are not readable by "others"
  - chmod -R a+r $HOME/.cargo

notifications:
  email:
    on_success: never

branches:
  only:
    - master