.gitlab-ci.yml 5.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
before_script:
    - apt-get update -yqq
    - export CARGO_HOME=.cargo-cache
    - rustc --version
    - cargo --version

.rust_tags: &rust_tags
    - rust
    - docker
    - ghostflow
    - linux

.cargo_update: &cargo_update
    - cargo generate-lockfile $GENERATE_LOCKFILE_ARGS
    - cargo fetch --locked
16 17
    - mkdir .cargo
    - cargo vendor > .cargo/config
18

19
.cargo_clippy: &cargo_clippy
Ben Boeckel's avatar
Ben Boeckel committed
20 21 22
    # Only use it if it's available; no need to fail the build due to something
    # gone wrong here.
    - .gitlab/ci/sccache.sh && export RUSTC_WRAPPER=$PWD/.gitlab/sccache
23 24
    - rustup component add clippy
    - cargo clippy --frozen --tests --all --verbose -- -D warnings
Ben Boeckel's avatar
Ben Boeckel committed
25
    - ".gitlab/sccache --show-stats || :"
26

27
.cargo_build: &cargo_build
Ben Boeckel's avatar
Ben Boeckel committed
28 29 30
    # Only use it if it's available; no need to fail the build due to something
    # gone wrong here.
    - .gitlab/ci/sccache.sh && export RUSTC_WRAPPER=$PWD/.gitlab/sccache
31 32
    - cargo build $CARGO_BUILD_FROZEN --all --verbose
    - cargo test --frozen --all --no-run --verbose
Ben Boeckel's avatar
Ben Boeckel committed
33
    - ".gitlab/sccache --show-stats || :"
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

.cargo_test: &cargo_test
    - apt-get install -yqq --no-install-recommends git
    - git config --global user.name "Ghostflow Testing"
    - git config --global user.email "ghostflow@example.invalid"
    - cargo test --frozen --all --verbose

.rust_minimum: &rust_minimum
    image: "rust:1.32.0"

    variables:
        # Not supported yet here? If updating to a version where this works,
        # remove this variable.
        #CARGO_BUILD_FROZEN: --frozen
        CARGO_UPDATE_POLICY: newest
Ben Boeckel's avatar
Ben Boeckel committed
49
        SCCACHE_REDIS: redis://minmus:6379
50 51 52 53 54 55 56

.rust_stable: &rust_stable
    image: "rust:latest"

    variables:
        CARGO_BUILD_FROZEN: --frozen
        CARGO_UPDATE_POLICY: newest
Ben Boeckel's avatar
Ben Boeckel committed
57
        SCCACHE_REDIS: redis://minmus:6379
58 59 60 61 62 63 64 65 66 67 68 69 70

.rust_nightly: &rust_nightly
    extends: .rust_stable

    image: "rustlang/rust:nightly"

.cargo_fetch_job: &cargo_fetch_job
    stage: prepare
    tags: *rust_tags
    script: *cargo_update
    artifacts:
        expire_in: 60m
        paths:
71 72
            - vendor
            - .cargo
73 74 75 76 77 78 79
            - Cargo.lock
    cache:
        key: cargo-cache-$CARGO_UPDATE_POLICY
        paths:
            - .cargo-cache
    interruptible: true

80 81 82 83 84 85
.cargo_clippy_job: &cargo_clippy_job
    stage: build
    tags: *rust_tags
    script: *cargo_clippy
    interruptible: true

86 87 88 89 90 91 92
.cargo_build_job: &cargo_build_job
    stage: build
    tags: *rust_tags
    script: *cargo_build
    artifacts:
        expire_in: 60m
        paths:
93 94
            - vendor
            - .cargo
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
            - Cargo.lock
            - target
    interruptible: true

.cargo_test_job: &cargo_test_job
    stage: test
    tags: *rust_tags
    script: *cargo_test
    interruptible: true

stages:
    - prepare
    - build
    - test

prepare:cargo-cache-newest:
    <<:
        - *cargo_fetch_job
        - *rust_stable

prepare:cargo-cache-mindeps:
    <<:
        - *cargo_fetch_job
        - *rust_nightly
    variables:
        GENERATE_LOCKFILE_ARGS: "-Z minimal-versions"
        CARGO_UPDATE_POLICY: mindeps

.cargo_cache_newest: &cargo_cache_newest
    dependencies:
        - prepare:cargo-cache-newest
    needs:
        - prepare:cargo-cache-newest

build:cargo-clippy:
    <<:
131
        - *cargo_clippy_job
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
        - *rust_stable
        - *cargo_cache_newest

build:cargo-minimum:
    <<:
        - *cargo_build_job
        - *rust_minimum
        - *cargo_cache_newest

test:cargo-minimum:
    <<:
        - *cargo_test_job
        - *rust_minimum
    dependencies:
        - build:cargo-minimum
    needs:
        - build:cargo-minimum

build:cargo-stable:
    <<:
        - *cargo_build_job
        - *rust_stable
        - *cargo_cache_newest

test:cargo-stable:
    <<:
        - *cargo_test_job
        - *rust_stable
    dependencies:
        - build:cargo-stable
    needs:
        - build:cargo-stable

build:cargo-nightly:
    <<:
        - *cargo_build_job
        - *rust_nightly
        - *cargo_cache_newest

test:cargo-nightly:
    <<:
        - *cargo_test_job
        - *rust_nightly
    dependencies:
        - build:cargo-nightly
    needs:
        - build:cargo-nightly

build:cargo-mindeps:
    <<:
        - *cargo_build_job
        - *rust_minimum
    dependencies:
        - prepare:cargo-cache-mindeps
    needs:
        - prepare:cargo-cache-mindeps

test:cargo-mindeps:
    <<:
        - *cargo_test_job
        - *rust_minimum
    dependencies:
        - build:cargo-mindeps
    needs:
        - build:cargo-mindeps

prepare:git:
    image: "rust:latest"

    stage: prepare
    tags: *rust_tags
    script:
        - export GIT_ROOT=$PWD/git/root
        - "[ -d git ] || git clone https://github.com/git/git.git git/src"
        - pushd git/src
        - git reset --hard
        - git pull
        - make prefix=$GIT_ROOT NO_GETTEXT=1 NO_TCLTK=1 NO_INSTALL_HARDLINKS=1 -j`nproc` install
        - popd
    variables:
        GIT_STRATEGY: none
    artifacts:
        expire_in: 60m
        paths:
            - git/root
    cache:
        key: git-master
        paths:
            - git/src
    interruptible: true

test:git-master:
    <<:
        - *cargo_test_job
        - *rust_stable
    script:
        - git config --global user.name "Ghostflow Testing"
        - git config --global user.email "ghostflow@example.invalid"
        - PATH=$PWD/git/root/bin:$PATH cargo test --frozen --all --verbose
    dependencies:
        - prepare:git
        - build:cargo-stable
    needs:
        - prepare:git
        - build:cargo-stable