cache: cargo
before_cache:
    - find ./target/debug -maxdepth 1 -type f -delete
    - rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*heavy_test*,*gen_lsp*,*thread_worker*}
    - rm -f  ./target/.rustc_info.json

matrix:
    include:
        - name: "Rust Tests"
          os: linux
          dist: xenial
          language: rust
          rust: stable
          script:
              - rustup component add rustfmt
              - rustup component add rust-src
              - printf "\n\n[profile.dev]\ndebug = false\n" >> Cargo.toml
              - cargo test --no-run  # let's measure compile time separately
              - cargo test
          env:
              - RUSTFLAGS="-D warnings", CARGO_INCREMENTAL=0

        - name: "Rust Docs"
          os: linux
          if: branch = master AND type = push
          before_script:
              - DEPLOY_DOCS=1
          language: rust
          rust: stable
          script:
              - cargo build-website
          env:
              - RUSTFLAGS="-D warnings", CARGO_INCREMENTAL=0

        - name: "VS Code Tests"
          os: linux
          language: node_js
          dist: xenial
          node_js: node
          services:
            - xvfb
          before_install: cd editors/code
          install:
            - npm ci
            - npm run vscode:prepublish
          script:
            - npm run travis
          env:
            - CXX="g++-4.9", CC="gcc-4.9"

branches:
    only:
        - staging
        - master
        - trying

deploy:
    provider: pages
    skip-cleanup: true
    github-token: $DOCS_TOKEN  # Set in the settings page of your repository, as a secure variable
    keep-history: true
    local-dir: target/website/
    on:
        branch: master
        condition: $DEPLOY_DOCS = 1