From e8ac93af5844fb1a60ba067a403a97cd6ffe595f Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 20:30:34 +0200 Subject: [PATCH 01/12] feat: added test for circle --- .circleci/config.yml | 17 +++++++++++++++++ README.md | 22 ++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aa3efe3fe..79bcb5785 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -93,6 +93,19 @@ jobs: - run: name: Deploy command: scripts/deploy/stacks-deploy $CIRCLE_TAG + test: + docker: + - image: heathmont/elixir-ci:1.12.3-otp-24-alpine + steps: + - checkout + - restore_cache: + keys: + - v5-build-{{ checksum "mix.lock" }}-{{ .Revision }} + - v5-build-{{ checksum "mix.lock" }}- + - v5-build- + - run: + name: Mix test + command: mix test check_formatted: docker: - image: heathmont/elixir-ci:1.12.3-otp-24-alpine @@ -134,6 +147,10 @@ workflows: jobs: - otp_release: context: global + - test: + context: global + - check_formatted: + context: global - docker_image: context: global filters: diff --git a/README.md b/README.md index 11ab224ca..61f3d4b9f 100644 --- a/README.md +++ b/README.md @@ -29,21 +29,8 @@ In writing code try to remember following rules: 1. Code should be as short and simple as possible (less lines is better) 2. Code should be as explicit as possible (and compiler should catch as many errors as possible) - -So as an example, when considering following code approaches, which one you should pick? - -``` -alias Moon.Components.TextInput - - -``` - -or +3. Use slots +4. Run tests ``` alias Moon.Components.TextInput @@ -60,4 +47,7 @@ alias Moon.Assets.Icons.IconZoom ``` -Second example is a bit longer, but has much better compiler error checks. +```bash +mix test +``` + From d190a367fd2bb2675f2c88c4b977e9d49379f04d Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 20:34:08 +0200 Subject: [PATCH 02/12] fix: circle steps test and check formatted require otp build first --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 79bcb5785..fcd6da5ea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,8 +149,12 @@ workflows: context: global - test: context: global + requires: + - otp_release - check_formatted: context: global + requires: + - otp_release - docker_image: context: global filters: From a7dd1db54404812a334ae0e4984ad107383422e1 Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 20:44:26 +0200 Subject: [PATCH 03/12] fix: cleaned up circle config --- .circleci/config.yml | 62 +++++--------------------------------------- 1 file changed, 7 insertions(+), 55 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fcd6da5ea..f1aca7322 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,6 +44,12 @@ jobs: - run: name: "Build apps assets" command: mix assets.deploy + - run: + name: Surface format + command: mix surface.format --check-formatted + - run: + name: Mix test + command: mix test - run: name: Build release command: scripts/deploy/build-release @@ -93,53 +99,7 @@ jobs: - run: name: Deploy command: scripts/deploy/stacks-deploy $CIRCLE_TAG - test: - docker: - - image: heathmont/elixir-ci:1.12.3-otp-24-alpine - steps: - - checkout - - restore_cache: - keys: - - v5-build-{{ checksum "mix.lock" }}-{{ .Revision }} - - v5-build-{{ checksum "mix.lock" }}- - - v5-build- - - run: - name: Mix test - command: mix test - check_formatted: - docker: - - image: heathmont/elixir-ci:1.12.3-otp-24-alpine - steps: - - checkout - - restore_cache: - keys: - - v5-build-{{ checksum "mix.lock" }}-{{ .Revision }} - - v5-build-{{ checksum "mix.lock" }}- - - v5-build- - - run: - name: Mix format - command: mix format --check-formatted - - run: - name: Update git submodules - command: git submodule update --init --recursive - - run: - name: Hex auth - command: mix hex.organization auth coingaming --key $HEX_API_KEY - - run: - name: ExEnv - command: mix archive.install hex ex_env 0.3.1 --force - - run: - name: Fetch dependencies - command: mix deps.get - - run: - name: Surface format - command: mix surface.format --check-formatted - - save_cache: - key: v5-build-{{ checksum "mix.lock" }}-{{ .Revision }} - paths: - - .cache - - deps - - ~/.mix + workflows: version: 2 @@ -147,14 +107,6 @@ workflows: jobs: - otp_release: context: global - - test: - context: global - requires: - - otp_release - - check_formatted: - context: global - requires: - - otp_release - docker_image: context: global filters: From 8e35289e1ecb5ae9c3df76467042e0de79bc4d2a Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:06:04 +0200 Subject: [PATCH 04/12] fix: circle config for code quality --- .circleci/config.yml | 42 +++++++++++++++++++++++++++++++++++++++--- mix.exs | 4 ++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f1aca7322..af5dad49c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,9 +44,6 @@ jobs: - run: name: "Build apps assets" command: mix assets.deploy - - run: - name: Surface format - command: mix surface.format --check-formatted - run: name: Mix test command: mix test @@ -63,6 +60,43 @@ jobs: root: ./ paths: - release.tar.gz + check_code_quality: + docker: + - image: heathmont/elixir-ci:1.12.3-otp-24-alpine + environment: + MIX_ENV: dev + steps: + - checkout + - run: + name: Check variables + command: ./scripts/deploy/check-vars "in system" "ROBOT_SSH_KEY" "DOCKER_EMAIL" "DOCKER_ORG" "DOCKER_PASS" "DOCKER_USER" "HEX_API_KEY" + - run: + name: Setup robot SSH key + command: echo "$ROBOT_SSH_KEY" | base64 -d > $HOME/.ssh/id_rsa.robot && chmod 600 $HOME/.ssh/id_rsa.robot && ssh-add $HOME/.ssh/id_rsa.robot + - run: + name: Setup SSH config + command: echo -e "Host *\n IdentityFile $HOME/.ssh/id_rsa.robot\n IdentitiesOnly yes" > $HOME/.ssh/config + - restore_cache: + keys: + - v5-build-{{ checksum "mix.lock" }}-{{ .Revision }} + - v5-build-{{ checksum "mix.lock" }}- + - v5-build- + - run: + command: git submodule update --init --recursive + - run: + command: mix hex.organization auth coingaming --key $HEX_API_KEY + - run: + command: mix archive.install hex ex_env 0.3.1 --force + - run: + command: mix setup + - run: + command: mix assets.setup + - run: + command: mix format --check-formatted + - run: + command: mix credo --strict + - run: + command: mix surface.format --check-formatted docker_image: docker: - image: heathmont/elixir-ci:1.12.3-otp-24-alpine @@ -107,6 +141,8 @@ workflows: jobs: - otp_release: context: global + - check_code_quality: + context: global - docker_image: context: global filters: diff --git a/mix.exs b/mix.exs index 6f7137f93..89e2d459d 100644 --- a/mix.exs +++ b/mix.exs @@ -64,8 +64,8 @@ defmodule Moon.MixProject do # dev {:phoenix_live_reload, "~> 1.2", only: :dev}, - {:surface_formatter, "~> 0.6", only: :dev}, - {:dialyxir, "~> 1.0", only: :dev, runtime: false} + {:surface_formatter, "~> 0.6", only: :dev, runtime: false}, + {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}, ] end From e1aa0d6be1c93f587bca55f1882c97409ef0848f Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:07:32 +0200 Subject: [PATCH 05/12] fix: formatter error in mix.exs --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 89e2d459d..21e8d52e8 100644 --- a/mix.exs +++ b/mix.exs @@ -65,7 +65,7 @@ defmodule Moon.MixProject do # dev {:phoenix_live_reload, "~> 1.2", only: :dev}, {:surface_formatter, "~> 0.6", only: :dev, runtime: false}, - {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}, + {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false} ] end From 7bf935f4e10d57fa14b4d3c5078fe61fe1926c98 Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:15:53 +0200 Subject: [PATCH 06/12] fix: fixed credo error --- lib/moon_web/pages/assets/currencies_page.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/moon_web/pages/assets/currencies_page.ex b/lib/moon_web/pages/assets/currencies_page.ex index 482774c0a..1883129d9 100644 --- a/lib/moon_web/pages/assets/currencies_page.ex +++ b/lib/moon_web/pages/assets/currencies_page.ex @@ -3,8 +3,8 @@ defmodule MoonWeb.Pages.Assets.CurrenciesPage do use MoonWeb, :live_view - alias Moon.Assets.Currency alias Moon.Assets.Currencies + alias Moon.Assets.Currency alias Moon.Autolayouts.TopToDown alias Moon.Components.CodePreview alias Moon.Components.Heading From 4fc9a296077f1b26dae88725980a44d59f43e008 Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:19:46 +0200 Subject: [PATCH 07/12] fix: removed strict from credo because our code is not ready for that --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index af5dad49c..92ddf3704 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,7 +94,7 @@ jobs: - run: command: mix format --check-formatted - run: - command: mix credo --strict + command: mix credo - run: command: mix surface.format --check-formatted docker_image: From fd70f218c26672ac8c3a76c75f1ba3c453d7de93 Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:32:51 +0200 Subject: [PATCH 08/12] fix: moved mix test to quality check in circle --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92ddf3704..caf2acec8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,9 +44,6 @@ jobs: - run: name: "Build apps assets" command: mix assets.deploy - - run: - name: Mix test - command: mix test - run: name: Build release command: scripts/deploy/build-release @@ -97,6 +94,8 @@ jobs: command: mix credo - run: command: mix surface.format --check-formatted + - run: + command: mix test docker_image: docker: - image: heathmont/elixir-ci:1.12.3-otp-24-alpine From a7271f48e00d94980612ff02da236486c0bec71d Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:44:19 +0200 Subject: [PATCH 09/12] fix: add temporary inotify tools for mix test --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index caf2acec8..c12278ded 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,6 +94,8 @@ jobs: command: mix credo - run: command: mix surface.format --check-formatted + - run: + command: apk --no-cache add inotify-tools - run: command: mix test docker_image: From c150a0e88ea76456aaad062738cc5edd780086c8 Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:54:09 +0200 Subject: [PATCH 10/12] fix: failing circle --- .circleci/config.yml | 2 +- lib/moon_web/pages/example_pages/shared/top_menu/search.ex | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c12278ded..4794b8d66 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,7 +61,7 @@ jobs: docker: - image: heathmont/elixir-ci:1.12.3-otp-24-alpine environment: - MIX_ENV: dev + MIX_ENV: test steps: - checkout - run: diff --git a/lib/moon_web/pages/example_pages/shared/top_menu/search.ex b/lib/moon_web/pages/example_pages/shared/top_menu/search.ex index 83867c8b9..2247e7250 100644 --- a/lib/moon_web/pages/example_pages/shared/top_menu/search.ex +++ b/lib/moon_web/pages/example_pages/shared/top_menu/search.ex @@ -25,7 +25,6 @@ defmodule MoonWeb.Pages.ExamplePages.Shared.TopMenu.Search do class="w-128 max-w-md" > <:left_icon> - <:right_icon :if={should_show_close_search(@search_map)}> + <:right_icon :if={should_show_close_search(@search_map)}> From bed9a3ab9d1e8847dd82558efe7a4604d5e58b24 Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 21:57:54 +0200 Subject: [PATCH 11/12] fix: added surface formatter to test env --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 21e8d52e8..985736f09 100644 --- a/mix.exs +++ b/mix.exs @@ -64,7 +64,7 @@ defmodule Moon.MixProject do # dev {:phoenix_live_reload, "~> 1.2", only: :dev}, - {:surface_formatter, "~> 0.6", only: :dev, runtime: false}, + {:surface_formatter, "~> 0.6", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false} ] end From 2130aa077cc1b2e5a85b714a75830b9fb6759beb Mon Sep 17 00:00:00 2001 From: Margus Part Date: Thu, 4 Nov 2021 22:02:31 +0200 Subject: [PATCH 12/12] fix: removed unneeded package --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4794b8d66..5db1e3d83 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,8 +94,6 @@ jobs: command: mix credo - run: command: mix surface.format --check-formatted - - run: - command: apk --no-cache add inotify-tools - run: command: mix test docker_image: