Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.67 KiB
Newer Older
.push-zamok: &push-zamok
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  - \[ -d ${ZAMOK_SOURCE} \] && 
        rsync -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -rqz ${ZAMOK_SOURCE}/. v-lafeychine@zamok.crans.org:www/proost/${ZAMOK_TARGET} || true

default:
  image: vlafeychine/rust
  interruptible: true
  cache:
    paths:
      - .cache/cargo/
      - target/
variables:
  CARGO_HOME: "$CI_PROJECT_DIR/.cache/cargo/"
  RUSTFLAGS: "-D warnings"
stages: [ check, build, tests, docs ]
  stage: check
    - cargo deny check
    - cargo fmt --check

lint:
  stage: check
    - cargo clippy --all-targets --all-features
  stage: build
  script:
    - cargo build

tests:
  stage: tests
  variables:
    CARGO_INCREMENTAL: 0
    EXCL_LINE: "#\\[|use|unreachable!|^(pub |pub(crate) )?(enum|struct)"
    EXCL_START: "^(pub |pub(crate) )?(enum|struct) ([[:alpha:]]|[[:space:]]|[<>',])+\\{"
    EXCL_STOP: "^\\}"
    EXCL_BR_LINE: "#\\[|assert(_eq)?!|^(pub |pub(crate) )?(enum|struct)|^[[:space:]]*\\}(,)?$"
    EXCL_BR_START: "#\\[no_coverage\\]|^mod tests \\{|^(pub |pub(crate) )?(enum|struct) ([[:alpha:]]|[[:space:]]|[<>',])+\\{"
    EXCL_BR_STOP: "^\\}"
    RUSTDOCFLAGS: "${RUSTFLAGS}"
    RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
    ZAMOK_SOURCE: coverage
    ZAMOK_TARGET: coverage/${CI_COMMIT_REF_SLUG}
  script:
    - cargo test
    - grcov . -s . -b ./target/debug/ --branch --llvm --ignore-not-existing --excl-line "${EXCL_LINE}" --excl-start "${EXCL_START}" --excl-stop "${EXCL_STOP}" --excl-br-line "${EXCL_BR_LINE}" --excl-br-start "${EXCL_BR_START}" --excl-br-stop "${EXCL_BR_STOP}" --ignore "*cargo*" -t cobertura -o ./coverage_raw.xml &&
        xsltproc --novalid --output ./coverage.xml ./.gitlab-cov.xsl ./coverage_raw.xml || true
    - grcov . -s . -b ./target/debug/ --branch --llvm --ignore-not-existing --excl-line "${EXCL_LINE}" --excl-start "${EXCL_START}" --excl-stop "${EXCL_STOP}" --excl-br-line "${EXCL_BR_LINE}" --excl-br-start "${EXCL_BR_START}" --excl-br-stop "${EXCL_BR_STOP}" --ignore "*cargo*" -t lcov -o ./coverage.lcov &&
        genhtml --branch --no-function-coverage --precision 2 ./coverage.lcov -o ./coverage || true

  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura

  coverage: '/^  branches...: \d+.\d+%/'
  variables:
    ZAMOK_SOURCE: target/doc
    ZAMOK_TARGET: doc