image: rust:latest

cache:
  key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
  paths:
      # Don't include `incremental` to save space
      # Debug
      - target/debug/build/
      - target/debug/deps/
      - target/debug/.fingerprint/
      - target/debug/.cargo-lock
      - target/debug/df_storyteller
      # Release
      - target/release/build/
      - target/release/deps/
      - target/release/.fingerprint/
      - target/release/.cargo-lock

before_script:
  - apt-get update -qq && apt-get install -y -qq libudev-dev libgtk-3-dev grep

stages:
    - format
    - check
    - test
    - release

format:
  except:
    - tags
  script:
    - echo "nightly" > rust-toolchain
    - rustup component add rustfmt
    - cargo fmt --check

check:
  except:
    - tags
  script:
    - rustup component add clippy
    - cargo check
    # deny currently catches too much
    #- cargo install cargo-deny && cargo deny
    - cargo install cargo-cranky && cargo cranky

test:
  except:
    - tags
  script:
    - cargo test

release:
  only:
    - tags
  script:
    - make && make vendor
  artifacts:
    paths:
    - vendor_asusctl_*.tar.xz
    - cargo-config

variables:
  GIT_SUBMODULE_STRATEGY: normal
