From 372083a9ee062159e26d9582c3c3c6f8dd5c2849 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 24 Apr 2022 11:29:12 +0000 Subject: [PATCH 01/13] chore: remove github actions We're sticking with drone for now. --- .github/workflows/ci.yml | 142 --------------------------------------- 1 file changed, 142 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 35b0579..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,142 +0,0 @@ ---- -# based on: -# 1. https://dev.to/mnishiguchi/basic-github-actions-setup-for-phoenix-apps-m3g -# 2. https://www.jonathanyeong.com/garden/how-to-setup-ci-with-phoenix-github-actions/ -name: CI - -on: - push: - branches: [main] - pull_request: - brances: [main] - -env: - MIX_ENV: test - -jobs: - dependencies: - runs-on: ubuntu-20.04 - strategy: - matrix: - elixir: ['1.12.1'] - otp: ['24.0.2'] - steps: - - name: cancel previous execution - uses: styfle/cancel-workflow-action@0.9.0 - with: - access_token: ${{ github.token }} - - name: checkout repo - uses: actions/checkout@v2 - - name: setup erlang/elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: ${{ matrix.elixir }} - otp-version: ${{ matrix.otp }} - - name: fecth cached dependencies - uses: actions/cache@v2 - id: mix-cache - with: - path: | - deps - _build - priv/plts - key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} - - name: install dependencies - if: steps.mix-cache.outputs.cache-hit != 'true' - run: | - mkdir -p priv/plts - mix local.rebar --force - mix local.hex --force - mix deps.get - mix deps.compile - mix dialyzer --plt - static-code-analysis: - needs: dependencies - runs-on: ubuntu-20.04 - strategy: - matrix: - elixir: ['1.12.1'] - otp: ['24.0.2'] - steps: - - name: cancel previous execution - uses: styfle/cancel-workflow-action@0.9.0 - with: - access_token: ${{ github.token }} - - name: checkout repo - uses: actions/checkout@v2 - - name: setup erlang/elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: ${{ matrix.elixir }} - otp-version: ${{ matrix.otp }} - - name: fecth cached dependencies - uses: actions/cache@v2 - id: mix-cache - with: - path: | - deps - _build - priv/plts - key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} - - run: mix format --check-formatted - - name: credo analysis - uses: red-shirts/reviewdog-action-credo@v1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review - - run: mix dialyzer --no-check --quiet --ignore-exit-status --format short - test: - needs: dependencies - runs-on: ubuntu-20.04 - strategy: - matrix: - elixir: ['1.12.1'] - otp: ['24.0.2'] - services: - db: - image: 'postgres:13.3-alpine' - ports: - - '5432:5432' - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - - name: cancel previous execution - uses: styfle/cancel-workflow-action@0.9.0 - with: - access_token: ${{ github.token }} - - name: checkout repo - uses: actions/checkout@v2 - - name: setup erlang/elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: ${{ matrix.elixir }} - otp-version: ${{ matrix.otp }} - - name: fecth cached dependencies - uses: actions/cache@v2 - id: mix-cache - with: - path: | - deps - _build - priv/plts - key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} - - run: mix test --cover --trace --slowest 10 - env: - POSTGRES_USER: postgres - POSTGRES_PASS: postgres - - name: publish test results - uses: EnricoMi/publish-unit-test-result-action/composite@v1 - if: always() - with: - files: 'report/test/*.xml' - - name: publish coverage report - uses: romeovs/lcov-reporter-action@v0.2.16 - if: always() - with: - lcov-file: 'cover/lcov.info' -- 2.47.2 From 4aea4ffc75e1099c27aeaeccb0eb64d61777fdae Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 24 Apr 2022 11:30:18 +0000 Subject: [PATCH 02/13] wip: experiment with drone cache Try to make builds faster --- .drone.yml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 68c2ec9..1c16b87 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,7 +5,6 @@ name: test trigger: event: - - push - pull_request steps: @@ -17,6 +16,23 @@ steps: PGHOST: db commands: - while ! pg_isready; do sleep 1; done + + - name: restore cache + image: 'meltwater/drone-cache:dev' + pull: true + settings: + archive_format: gzip + backend: filesystem + cache_key: volume + mount: + - _build + - deps + restore: true + exit_code: true + volumes: + - name: cache + path: /tmp/cache + - name: test image: 'elixir:1.13.4' environment: @@ -28,9 +44,29 @@ steps: - mix do local.rebar --force, local.hex --force, deps.get, deps.compile - mix test --cover --trace --slowest 10 + - name: rebuild cache + image: 'meltwater/drone-cache:dev' + pull: true + settings: + archive_format: gzip + backend: filesystem + cache_key: volume + mount: + - _build + - deps + rebuild: true + exit_code: true + volumes: + - name: cache + path: /tmp/cache + services: - name: db image: 'postgres:14.2-alpine' environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + +volumes: + - name: cache + temp: {} -- 2.47.2 From afface58082f0b6d731346a2dc2cacda938b644a Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 24 Apr 2022 11:37:28 +0000 Subject: [PATCH 03/13] fix: fail silently when restoring cache --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 1c16b87..e2a8efd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,7 +28,6 @@ steps: - _build - deps restore: true - exit_code: true volumes: - name: cache path: /tmp/cache -- 2.47.2 From f37942da6fcb6a78a2192137124e87b2c80448fa Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 24 Apr 2022 12:33:07 +0000 Subject: [PATCH 04/13] wip: pin drone-cache version --- .drone.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index e2a8efd..0febd83 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,8 +18,7 @@ steps: - while ! pg_isready; do sleep 1; done - name: restore cache - image: 'meltwater/drone-cache:dev' - pull: true + image: 'meltwater/drone-cache:v1.3.0' settings: archive_format: gzip backend: filesystem @@ -44,8 +43,7 @@ steps: - mix test --cover --trace --slowest 10 - name: rebuild cache - image: 'meltwater/drone-cache:dev' - pull: true + image: 'meltwater/drone-cache:v1.3.0' settings: archive_format: gzip backend: filesystem -- 2.47.2 From d22d93ed6caee1351c84cf42ac34468de54d22dc Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 24 Apr 2022 12:33:31 +0000 Subject: [PATCH 05/13] wip: set custom cache key --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0febd83..8ce7902 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,7 +22,7 @@ steps: settings: archive_format: gzip backend: filesystem - cache_key: volume + cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' mount: - _build - deps @@ -47,7 +47,7 @@ steps: settings: archive_format: gzip backend: filesystem - cache_key: volume + cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' mount: - _build - deps -- 2.47.2 From fa674ceb36394ee48424c8d53cec30bad1346d2f Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Sun, 24 Apr 2022 12:43:31 +0000 Subject: [PATCH 06/13] chore: add lint step In this step we check: 1. format 2. credo 3. dialyzer --- .drone.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 8ce7902..5d1a62e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -40,7 +40,13 @@ steps: POSTGRES_PASS: postgres commands: - mix do local.rebar --force, local.hex --force, deps.get, deps.compile - - mix test --cover --trace --slowest 10 + - make test + + - name: lint + image: 'elixir:1.13.4' + commands: + - mix do local.rebar --force, local.hex --force, deps.get, deps.compile + - make static_code_analysis - name: rebuild cache image: 'meltwater/drone-cache:v1.3.0' -- 2.47.2 From 6ee89e38b49f8cf66c7dc17aaf0f7834b233aba2 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 14:13:58 +0000 Subject: [PATCH 07/13] fix: spec for serialize_range method --- lib/wabanex_web/schema/types/custom/date_range.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wabanex_web/schema/types/custom/date_range.ex b/lib/wabanex_web/schema/types/custom/date_range.ex index c32d58e..45e2dd3 100644 --- a/lib/wabanex_web/schema/types/custom/date_range.ex +++ b/lib/wabanex_web/schema/types/custom/date_range.ex @@ -17,7 +17,7 @@ defmodule WabanexWeb.Schema.Types.Custom.DateRange do end @spec serialize_range(PgRanges.DateRange.t()) :: String.t() - @spec serialize_range(list(String.t())) :: String.t() + @spec serialize_range(list(DateTime.t() | nil)) :: String.t() defp serialize_range(%PgRanges.DateRange{lower: start_range, upper: end_range}), do: serialize_range([start_range, end_range]) -- 2.47.2 From 6bf5e51493c8110bf123f60234e771bbc2b770d8 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 14:15:21 +0000 Subject: [PATCH 08/13] chore: minor change in lock file --- mix.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.lock b/mix.lock index 7c8db84..399b62d 100644 --- a/mix.lock +++ b/mix.lock @@ -40,7 +40,7 @@ "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "postgrex": {:hex, :postgrex, "0.16.2", "0f83198d0e73a36e8d716b90f45f3bde75b5eebf4ade4f43fa1f88c90a812f74", [:mix], [{:connection, "~> 1.1", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "a9ea589754d9d4d076121090662b7afe155b374897a6550eb288f11d755acfa0"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, - "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, + "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, "telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"}, "telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"}, } -- 2.47.2 From b205d979ae9cfe7be8caec4e4fd7c143f285c29b Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 17:20:22 +0000 Subject: [PATCH 09/13] wip: use minio to cache dependencies --- .drone.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5d1a62e..929f247 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,17 +19,20 @@ steps: - name: restore cache image: 'meltwater/drone-cache:v1.3.0' + environment: + AWS_ACCESS_KEY_ID: + from_secret: minio_user + AWS_SECRET_ACCESS_KEY: + from_secret: minio_password settings: archive_format: gzip - backend: filesystem + bucket: trainlog_cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' + endpoint: minio:9000 mount: - _build - deps restore: true - volumes: - - name: cache - path: /tmp/cache - name: test image: 'elixir:1.13.4' @@ -50,18 +53,21 @@ steps: - name: rebuild cache image: 'meltwater/drone-cache:v1.3.0' + environment: + AWS_ACCESS_KEY_ID: + from_secret: minio_user + AWS_SECRET_ACCESS_KEY: + from_secret: minio_password settings: archive_format: gzip - backend: filesystem + bucket: trainlog_cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' + endpoint: minio:9000 mount: - _build - deps rebuild: true exit_code: true - volumes: - - name: cache - path: /tmp/cache services: - name: db -- 2.47.2 From c5b96629e680b076de9d70ecf9553a1df3a14390 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 17:29:55 +0000 Subject: [PATCH 10/13] wip: configure region for deps cache --- .drone.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 929f247..3e7f58a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,6 +32,7 @@ steps: mount: - _build - deps + region: us-east-1 restore: true - name: test @@ -67,6 +68,7 @@ steps: - _build - deps rebuild: true + region: us-east-1 exit_code: true services: @@ -75,7 +77,3 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - -volumes: - - name: cache - temp: {} -- 2.47.2 From 9596a3cc662626fccf59e3c90a7344471a87420a Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 17:35:01 +0000 Subject: [PATCH 11/13] wip: fix bucket for deps cache --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3e7f58a..58a2266 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,7 +26,7 @@ steps: from_secret: minio_password settings: archive_format: gzip - bucket: trainlog_cache + bucket: trainlog-cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' endpoint: minio:9000 mount: @@ -61,7 +61,7 @@ steps: from_secret: minio_password settings: archive_format: gzip - bucket: trainlog_cache + bucket: trainlog-cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' endpoint: minio:9000 mount: -- 2.47.2 From f7ced0fcba805b022988f81b6afc29c9fd36fa2c Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 23:13:32 +0000 Subject: [PATCH 12/13] wip: use fqdn for minio --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 58a2266..8f80e46 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,7 +28,7 @@ steps: archive_format: gzip bucket: trainlog-cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' - endpoint: minio:9000 + endpoint: https://minio.dubas.dev mount: - _build - deps @@ -63,7 +63,7 @@ steps: archive_format: gzip bucket: trainlog-cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' - endpoint: minio:9000 + endpoint: https://minio.dubas.dev mount: - _build - deps -- 2.47.2 From 8af0be6631a125bebaea076544e3338f9a9c766a Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Mon, 25 Apr 2022 23:26:22 +0000 Subject: [PATCH 13/13] wip: fix configuration for minio --- .drone.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8f80e46..2d13a2e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,10 +28,11 @@ steps: archive_format: gzip bucket: trainlog-cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' - endpoint: https://minio.dubas.dev + endpoint: minio:9000 mount: - _build - deps + path_style: true region: us-east-1 restore: true @@ -63,13 +64,14 @@ steps: archive_format: gzip bucket: trainlog-cache cache_key: '{{ .Repo.Name }}-{{ checksum "mix.lock" }}' - endpoint: https://minio.dubas.dev + endpoint: minio:9000 + exit_code: true mount: - _build - deps + path_style: true rebuild: true region: us-east-1 - exit_code: true services: - name: db -- 2.47.2