.gitlab-ci.yml 1.6 KB
Newer Older
1 2 3
stages:
    - test
    - lint
4
    - pages
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

.cargo_test_template: &cargo_test
    stage: test

    variables:
        RUST_BACKTRACE: "FULL"

    before_script:
        - mkdir -p .cargo_cache
        # Only stuff inside the repo directory can be cached
        # Override the CARGO_HOME variable to force it location
        - export CARGO_HOME="${PWD}/.cargo_cache"
    script:
        - rustc -Vv && cargo -Vv
        - cargo build
        - cargo test
        # - cargo test -- --ignored

    cache:
        # JOB_NAME - Each job will have it's own cache
25 26 27
        # COMMIT_REF_SLUG = Lowercase name of the branch
        # ^ Keep diffrerent caches for each branch
        key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
        paths:
            - target/
            - .cargo_cache/

# stable:test:
#     # https://hub.docker.com/_/rust/
#     image: "rust"
#     <<: *cargo_test

nightly:test:
    # https://hub.docker.com/r/rustlang/rust/
    image: "rustlang/rust:nightly"
    <<: *cargo_test

# Configure and run rustfmt on nightly
# Exits and builds fails if on bad format
44
.rustfmt:
45 46 47 48 49
    image: "registry.gitlab.com/alatiera/rustfmt-oci-image/rustfmt:nightly"
    stage: lint
    script:
        - rustc -Vv && cargo -Vv
        - cargo fmt --version
50
        - cargo fmt --all
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

pages:
  # https://hub.docker.com/r/rustlang/rust/
  image: "rustlang/rust:nightly"
  stage: pages
  script:
    - mkdir public
    - cargo install mdbook --no-default-features
    - mdbook build ./doc-internals
    - cp -r ./doc-internals/book/* ./public
    - find $PWD/public | grep "\.html\$"

  artifacts:
    paths:
      - public

  only:
    - master