From 4040c1400ace8ce5abc9b3c28d1cd67bd8f137d1 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Sat, 26 Dec 2020 13:59:27 +0000 Subject: Improve CI --- .gitlab-ci.yml | 111 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 17 deletions(-) (limited to '.gitlab-ci.yml') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d6c6d8..6233c52 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,38 @@ stages: - - static_analysis - - deploy + - setup + - test + - format + - credo + - dialyzer + - docs -image: elixir:latest +image: bitwalker/alpine-elixir:1.10.4 -before_script: - - mix local.rebar --force - - mix local.hex --force - - mix deps.get +cache: &global_cache + key: cache-test + when: always + policy: pull + paths: + - _build + - deps + +variables: + MIX_ENV: test + + +prepare_test: + stage: setup + script: + - mix deps.get + - mix compile + cache: + <<: *global_cache + policy: pull-push test: - stage: static_analysis + stage: test + needs: + - prepare_test services: - postgres:latest variables: @@ -19,10 +41,11 @@ test: POSTGRES_PASSWORD: postgres POSTGRES_HOST: postgres POSTGRES_HOST_AUTH_METHOD: trust + MIX_ENV: test + before_script: + - mix ecto.create + - mix ecto.migrate script: - - MIX_ENV=test mix compile - - MIX_ENV=test mix ecto.create - - MIX_ENV=test mix ecto.migrate - mix test --cover artifacts: when: always @@ -33,16 +56,70 @@ test: cobertura: coverage.xml format: - stage: static_analysis + stage: format + needs: + - prepare_test script: - mix format --check-formatted -pages: - stage: deploy +credo: + stage: credo + needs: + - prepare_test script: - - mix docs -o public + - mix credo suggest --only readability | tee credo.log artifacts: + when: always paths: - - public + - "credo.log" + +## this should be uncommented when +## https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27172 +## is fixed +# dialyzer: +# stage: dialyzer +# needs: +# - prepare_test +# script: +# - mix dialyzer +# cache: +# <<: *global_cache +# policy: pull-push +# paths: +# - _build +# - deps +# - priv/plts + + +# Doc generation + +prepare_dev: + stage: setup only: - - master + - master + variables: + MIX_ENV: test + script: + - mix deps.get + - mix compile + cache: + <<: *global_cache + policy: pull-push + key: cache-dev + +pages: + stage: docs + only: + - master + needs: + - prepare_dev + variables: + MIX_ENV: dev + script: + - mix docs -o public + cache: + <<: *global_cache + key: cache-dev + artifacts: + paths: + - public -- cgit v1.2.3