From 2d3d955c02dcd00fb1aa3d2aa7d356eab51c3c50 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sat, 27 May 2023 14:08:47 +0200 Subject: [PATCH 1/5] 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 From 8af60d204659e49b43e05d1ceaefe37af2a1e1e9 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sat, 27 May 2023 14:18:58 +0200 Subject: [PATCH 2/5] Installation de rustfmt dans la CI --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0858f3f..9af08f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,7 @@ cargo-fmt: stage: checks before_script: - rustup install nightly + - rustup component add rustfmt script: - cargo +nightly fmt --check rules: From 5af4f69e7d91028cc1bcf0482096861a4e8803c2 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sat, 27 May 2023 14:19:20 +0200 Subject: [PATCH 3/5] =?UTF-8?q?V=C3=A9rification=20de=20la=20pr=C3=A9sence?= =?UTF-8?q?=20du=20fichier=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9af08f6..7cd2d81 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,7 +45,7 @@ development-image: - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG rules: - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH - - exists: + exists: - Dockerfile production-image: @@ -59,5 +59,5 @@ production-image: - docker push $CI_REGISTRY_IMAGE:latest rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - exists: + exists: - Dockerfile From cfdd18be67997627b3052f06e2b483a9571424a9 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sat, 27 May 2023 14:35:14 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Ajout=20des=20d=C3=A9pendances=20n=C3=A9ces?= =?UTF-8?q?saire=20=C3=A0=20la=20compilation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7cd2d81..ee05eb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,8 @@ stages: cargo-test: image: rust:latest stage: checks + before_script: + - apt-get update && apt-get install libasound2-dev libudev-dev -y script: - cargo test --workspace rules: @@ -15,6 +17,7 @@ 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: - cargo clippy --workspace @@ -26,8 +29,7 @@ cargo-fmt: image: rust:latest stage: checks before_script: - - rustup install nightly - - rustup component add rustfmt + - rustup install nightly --profile complete script: - cargo +nightly fmt --check rules: From 4f60170c19772d27a6017d0f8ed299735c2c6a12 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sat, 27 May 2023 14:38:56 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Acc=C3=A9l=C3=A9ration=20de=20l'installatio?= =?UTF-8?q?n=20de=20rustfmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee05eb8..90017b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,8 @@ cargo-fmt: image: rust:latest stage: checks before_script: - - rustup install nightly --profile complete + - rustup install nightly --profile minimal + - rustup component add rustfmt --toolchain nightly script: - cargo +nightly fmt --check rules: