From 9b7d407315c663bd81a0c983363b11f7001053f4 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 30 Nov 2023 04:50:45 +0800 Subject: [PATCH 1/5] Remove old Supervisor.Spec implementation --- lib/cadet/application.ex | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/cadet/application.ex b/lib/cadet/application.ex index f2249418a..b1618c45e 100644 --- a/lib/cadet/application.ex +++ b/lib/cadet/application.ex @@ -6,21 +6,21 @@ defmodule Cadet.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications def start(_type, _args) do - import Supervisor.Spec - # Define workers and child supervisors to be supervised + # No need to distinguish between workers and supervisors anymore + # https://kobrakai.de/kolumne/child-specs-in-elixir/ children = [ # Start the Ecto repository - supervisor(Cadet.Repo, []), + {Cadet.Repo, []}, # Start the endpoint when the application starts - supervisor(CadetWeb.Endpoint, []), + {CadetWeb.Endpoint, []}, {Phoenix.PubSub, [name: Cadet.PubSub, adapter: Phoenix.PubSub.PG2]}, # Start your own worker by calling: Cadet.Worker.start_link(arg1, arg2, arg3) # worker(Cadet.Worker, [arg1, arg2, arg3]), # Start the GuardianDB sweeper - worker(Guardian.DB.Token.SweeperServer, []), + {Guardian.DB.Token.SweeperServer, []}, # Start the Quantum scheduler - worker(Cadet.Jobs.Scheduler, []), + {Cadet.Jobs.Scheduler, []}, # Start the Oban instance {Oban, Application.fetch_env!(:cadet, Oban)} ] @@ -28,7 +28,7 @@ defmodule Cadet.Application do children = case Application.get_env(:cadet, :openid_connect_providers) do nil -> children - providers -> children ++ [worker(OpenIDConnect.Worker, [providers])] + providers -> children ++ [{OpenIDConnect.Worker, [providers]}] end {:ok, _} = Logger.add_backend(Sentry.LoggerBackend) From 9d6e5acc7dd717a12109a92cac71a619589ddc0f Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 30 Nov 2023 04:51:44 +0800 Subject: [PATCH 2/5] Update comment --- lib/cadet/application.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cadet/application.ex b/lib/cadet/application.ex index b1618c45e..098af1bcb 100644 --- a/lib/cadet/application.ex +++ b/lib/cadet/application.ex @@ -16,7 +16,7 @@ defmodule Cadet.Application do {CadetWeb.Endpoint, []}, {Phoenix.PubSub, [name: Cadet.PubSub, adapter: Phoenix.PubSub.PG2]}, # Start your own worker by calling: Cadet.Worker.start_link(arg1, arg2, arg3) - # worker(Cadet.Worker, [arg1, arg2, arg3]), + # {Cadet.Worker, [arg1, arg2, arg3]}, # Start the GuardianDB sweeper {Guardian.DB.Token.SweeperServer, []}, # Start the Quantum scheduler From 4686cd15796840682813357af2b83e16a02e1821 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 30 Nov 2023 04:53:16 +0800 Subject: [PATCH 3/5] Remove unnecessary preload --- lib/cadet/accounts/accounts.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/cadet/accounts/accounts.ex b/lib/cadet/accounts/accounts.ex index 92ea72577..049b03ae7 100644 --- a/lib/cadet/accounts/accounts.ex +++ b/lib/cadet/accounts/accounts.ex @@ -55,9 +55,8 @@ defmodule Cadet.Accounts do CourseRegistration |> where([cr], cr.course_id == ^course_id) |> join(:inner, [cr], u in assoc(cr, :user)) - |> preload([cr, u], user: u) |> join(:left, [cr, u], g in assoc(cr, :group)) - |> preload([cr, u, g], group: g) + |> preload([cr, u, g], user: u, group: g) |> get_users_helper(filter) end From 8a7073895f5d523216a489bd10959480aaed13d3 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 30 Nov 2023 05:12:42 +0800 Subject: [PATCH 4/5] Update GitHub Actions workflows * Update dependency versions, action names * Remove unnecessary string formatting in cache key * Remove restore-keys argument * Update caching behaviour --- .github/workflows/cd.yml | 15 ++++++--------- .github/workflows/ci.yml | 18 ++++++++---------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ed8b74088..0f0f9c3a2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -30,23 +30,20 @@ jobs: - uses: rlespinasse/github-slug-action@v3.x - uses: actions/checkout@v2 - name: Cache deps - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: deps - key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-mix- + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} - name: Cache _build - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | _build !_build/prod/cadet-0.0.1.tar.gz - key: cd-${{ env.GITHUB_REF_SLUG }}-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }}-${{ github.sha }} - restore-keys: | - cd-${{ env.GITHUB_REF_SLUG }}-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }}- + # Elixir is smart enough to know what needs to be recompiled automatically + key: cd-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }} - name: Setup Elixir - uses: erlef/setup-elixir@v1 + uses: erlef/setup-beam@v1 with: elixir-version: ${{ env.ELIXIR_VERSION }} otp-version: ${{ env.OTP_VERSION }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d09f8588..ea649291d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,25 +37,23 @@ jobs: # needed because the postgres container does not provide a healthcheck options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v4 - name: Cache deps - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: deps - key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-mix- + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} - name: Cache _build - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | _build priv/plts - key: 1-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }}-${{ github.sha }} - restore-keys: | - 1-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }}- + # Elixir is smart enough to know what needs to be recompiled + key: 1-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }} - name: Setup Elixir - uses: erlef/setup-elixir@v1 + uses: erlef/setup-beam@v1 with: elixir-version: ${{ env.ELIXIR_VERSION }} otp-version: ${{ env.OTP_VERSION }} From 2afa719bd1b2b031e0a0d636a2a71337398f3cd6 Mon Sep 17 00:00:00 2001 From: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Date: Thu, 30 Nov 2023 05:19:45 +0800 Subject: [PATCH 5/5] Update comment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea649291d..48eb1e6c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: path: | _build priv/plts - # Elixir is smart enough to know what needs to be recompiled + # Elixir is smart enough to know what needs to be recompiled automatically key: 1-${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-elixir-${{ env.ELIXIR_VERSION }} - name: Setup Elixir uses: erlef/setup-beam@v1