2022-07-01 22:36:04 +02:00
|
|
|
# SPDX-FileCopyrightText: 2021 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
|
|
|
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
- test
|
|
|
|
- deploy
|
|
|
|
|
|
|
|
.with_rust_image:
|
|
|
|
image: ${CI_REGISTRY_IMAGE}/rust:latest
|
|
|
|
needs:
|
|
|
|
- job: docker:build
|
|
|
|
optional: true
|
|
|
|
|
|
|
|
.cargo_test_template:
|
|
|
|
extends: .with_rust_image
|
|
|
|
stage: test
|
|
|
|
artifacts:
|
|
|
|
reports:
|
2022-07-01 22:42:41 +02:00
|
|
|
coverage_report:
|
|
|
|
coverage_format: cobertura
|
|
|
|
path: cobertura.xml
|
2022-07-01 22:36:04 +02:00
|
|
|
junit: junit.xml
|
|
|
|
variables:
|
|
|
|
RUST_BACKTRACE: 1
|
|
|
|
CARGO_COMMON_ARGS: --workspace --no-default-features
|
|
|
|
script:
|
|
|
|
- mkdir -p .git/hooks # for cargo-husky
|
|
|
|
- cargo tarpaulin ${CARGO_COMMON_ARGS} --locked --verbose -o Xml
|
|
|
|
- cargo test ${CARGO_COMMON_ARGS} -- -Z unstable-options --format json | tee test-results.json
|
|
|
|
- cargo2junit < test-results.json > junit.xml
|
|
|
|
- cargo bench ${CARGO_COMMON_ARGS}
|
|
|
|
|
|
|
|
docker:build:
|
|
|
|
stage: build
|
|
|
|
variables:
|
|
|
|
CI_TAGGED_IMAGE: ${CI_REGISTRY_IMAGE}/rust:latest
|
|
|
|
before_script:
|
|
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
|
|
|
|
- echo "Operating on registry ${CI_REGISTRY} and image ${CI_TAGGED_IMAGE}"
|
|
|
|
script:
|
|
|
|
- docker build --tag ${CI_TAGGED_IMAGE} .
|
|
|
|
- docker push ${CI_TAGGED_IMAGE}
|
|
|
|
when: manual
|
|
|
|
rules:
|
|
|
|
- if: $CI_PIPELINE_SOURCE == "web" && $FORCE_DOCKER_BUILD == "true"
|
|
|
|
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"
|
|
|
|
changes:
|
|
|
|
- Dockerfile
|
|
|
|
allow_failure: true
|
|
|
|
|
|
|
|
cargo:test:
|
|
|
|
extends: .cargo_test_template
|
|
|
|
|
|
|
|
cargo:doc: # pages: in the future
|
|
|
|
extends: .with_rust_image
|
|
|
|
stage: deploy
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == "master"
|
|
|
|
script:
|
|
|
|
- mkdir public
|
|
|
|
- cargo doc --workspace --no-deps --all-features
|
|
|
|
- cp -R target/doc/* public
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- public
|