From 2d3d955c02dcd00fb1aa3d2aa7d356eab51c3c50 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sat, 27 May 2023 14:08:47 +0200 Subject: [PATCH] Nouvelle CI permettant de faire plus de tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .gitlab-ci.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++++--- rustfmt.toml | 19 +++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 rustfmt.toml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 21abc83..0858f3f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..ab63a20 --- /dev/null +++ b/rustfmt.toml @@ -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