Nouvelle CI permettant de faire plus de tests

La CI teste si le formatage est correcte et construit une image
docker si un fichier Dockerfile est présent dans le dossier. De
plus, elle execute les jobs en paralelle pour que l'execution soit
plus rapide
This commit is contained in:
Tipragot 2023-05-27 14:08:47 +02:00
parent 5328810623
commit 2d3d955c02
2 changed files with 71 additions and 3 deletions

View file

@ -1,13 +1,62 @@
stages:
- checks
- build
cargo-test:
image: rust:latest
stage: checks
script:
- cargo test --workspace
rules:
- exists:
- Cargo.toml
cargo-clippy:
image: rust:latest
stage: checks
before_script:
- apt-get update && apt-get install libasound2-dev libudev-dev -y
- rustup component add clippy
script:
- rustc --version && cargo --version
- cargo clippy --workspace
- cargo test --workspace
rules:
- exists:
- Cargo.toml
cargo-fmt:
image: rust:latest
stage: checks
before_script:
- rustup install nightly
script:
- cargo +nightly fmt --check
rules:
- exists:
- Cargo.toml
development-image:
image: docker:latest
stage: build
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
- exists:
- Dockerfile
production-image:
image: docker:latest
stage: build
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- exists:
- Dockerfile

19
rustfmt.toml Normal file
View file

@ -0,0 +1,19 @@
use_try_shorthand = true
use_field_init_shorthand = true
use_small_heuristics = "Max"
version = "Two"
error_on_line_overflow = true
error_on_unformatted = true
format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true
format_strings = true
imports_granularity = "Module"
group_imports = "StdExternalCrate"
normalize_doc_attributes = true
normalize_comments = true
wrap_comments = true