Add CI files
This commit is contained in:
parent
571aa90d6a
commit
52f0cf9111
|
@ -0,0 +1,61 @@
|
|||
# SPDX-FileCopyrightText: 2021 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
stages:
|
||||
- build
|
||||
- check
|
||||
- test
|
||||
- deploy
|
||||
|
||||
.with_rust_image:
|
||||
image: ${CI_REGISTRY_IMAGE}/rust:latest
|
||||
needs:
|
||||
- job: docker:build
|
||||
optional: true
|
||||
|
||||
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:check:
|
||||
extends: .with_rust_image
|
||||
stage: check
|
||||
variables:
|
||||
CARGO_COMMON_ARGS: --workspace --no-default-features
|
||||
script:
|
||||
- reuse lint
|
||||
- cargo fmt -- --check
|
||||
- cargo deny check
|
||||
|
||||
cargo:test:
|
||||
extends: .with_rust_image
|
||||
stage: test
|
||||
artifacts:
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: cobertura.xml
|
||||
junit: junit.xml
|
||||
variables:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_COMMON_ARGS: --workspace --no-default-features
|
||||
script:
|
||||
- mkdir -p .git/hooks # for rusty-hook
|
||||
- cargo tarpaulin ${CARGO_COMMON_ARGS} --locked -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} # DISABLED UNTIL WE HAVE BENCH TESTS
|
|
@ -0,0 +1,28 @@
|
|||
# SPDX-FileCopyrightText: 2022 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
FROM docker.io/rust:latest@sha256:df962ca4f985f8f6b81b7c02f66348d294974d8cafc2d0f15104c472623d433e
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y \
|
||||
libssl-dev \
|
||||
pkg-config \
|
||||
python3-pip \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip3 install reuse
|
||||
|
||||
RUN rustup component add rustfmt
|
||||
|
||||
RUN cargo install --locked -f -- \
|
||||
cargo-tarpaulin \
|
||||
cargo-deny \
|
||||
cargo2junit \
|
||||
&& \
|
||||
rm -rf "${HOME}/.cargo/registry" "${HOME}/.cargo/git"
|
||||
|
||||
ENTRYPOINT []
|
||||
CMD ["/bin/bash"]
|
Loading…
Reference in New Issue