noughts-and-crosses-console 0.1.1

RustGame.

image: "rust:latest"

stages:
  - check
  - test
  - deploy
  - publish
  - post-run

cache:
  key: "${CI_JOB_NAME}"
  paths:
    - ${CI_PROJECT_DIR}/target/

clean-code:
  stage: check
  script:
    - rustup default nightly
    - rustup update
    - rustup component add rustfmt-preview
    - cargo fmt --all -- --check
  allow_failure: true

build-noughts-and-crosses-console:
  stage: check
  script:
    - rustup default nightly
    - rustup update
    - cargo build


unittests:
  stage: test
  script:
    - rustup default nightly
    - rustup update
    - cargo test

benchmarktests:
  stage: test
  script:
    - rustup default nightly
    - rustup update
    - cargo bench


nightly-linux-optimized:
  stage: deploy
  cache: {}
  script:
    - apt-get update
    - rustup default nightly
    - rustup update
    - cargo build --release
    - rm -r -f files
    - mkdir files
    - cp target/release/noughts-and-crosses-console files
  when: on_success
  artifacts:
    paths:
      - files
    expire_in: 2 weeks
  only:
    refs:
      - master
      - dev

nightly-windows-optimized:
  stage: deploy
  cache: {}
  script:
    - apt-get update
    - rustup default nightly
    - rustup update
    - apt-get install gcc -y
    - apt-get install gcc-mingw-w64-x86-64 -y
    - rustup component add rust-std --target=x86_64-pc-windows-gnu
    - mkdir .cargo
    - touch .cargo/config
    - echo [target.x86_64-pc-windows-gnu] >> .cargo/config
    - echo     linker = \"x86_64-w64-mingw32-gcc\" >> .cargo/config
    - echo     ar = \"x86_64-w64-mingw32-gcc-ar\" >> .cargo/config
    - cargo build --release --target=x86_64-pc-windows-gnu
    - rm -r -f files
    - mkdir files
    - cp target/x86_64-pc-windows-gnu/release/noughts-and-crosses-console.exe files
  when: on_success
  artifacts:
    paths:
      - files
    expire_in: 2 weeks
  only:
    refs:
      - master
      - dev


cratesio:
  stage: publish
  cache: {}
  script:
    - rm -r -f files
    - apt-get update
    - rustup default nightly
    - rustup update
    - cargo login $CARGO_LOGIN
    - cargo package
    - cargo publish
  when: on_success
  only:
    refs:
      - master
      - dev
  allow_failure: true


clippy:
  stage: post-run
  script:
    - rustup default nightly
    - rustup update
    - rustup component add clippy-preview
    - cargo clippy --all -- -D clippy::all
  allow_failure: true