diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 21abc83..90017b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,66 @@ stages: - checks + - build 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: + - 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 --profile minimal + - rustup component add rustfmt --toolchain 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