From 525b89a3ec471120dd00650453796967a8a6e083 Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Tue, 7 Oct 2025 22:09:32 +0200 Subject: [PATCH 1/2] Simplify dynamic method generation The Elixir side can be written using normal unquoting. --- lib/desktop/wx.ex | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/desktop/wx.ex b/lib/desktop/wx.ex index a4eebc6..db6fbf0 100644 --- a/lib/desktop/wx.ex +++ b/lib/desktop/wx.ex @@ -25,13 +25,9 @@ defmodule Desktop.Wx do """ ) - for wx_constant <- @constants do - Code.eval_quoted( - Code.string_to_quoted(""" - def wx#{wx_constant}, do: :desktop_wx.get(:wx#{wx_constant}) - """), - [], - module: __MODULE__ - ) - end + @constants + |> Enum.map(&String.to_atom("wx" <> &1)) + |> Enum.each(fn prefixed_constant -> + def unquote(prefixed_constant)(), do: :desktop_wx.get(unquote(prefixed_constant)) + end) end From e7ef7b9d425e9283569c964e69a98acf4a57136a Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Wed, 28 Sep 2022 19:40:10 +0200 Subject: [PATCH 2/2] Provision Erlang/OTP and Elixir from a version matrix Run on every supported version of elixir having > OTP 24 --- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++-------- mix.exs | 2 +- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56a4b4e..e58ca1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,27 +3,58 @@ on: ["push", "pull_request"] jobs: test_and_build: - name: "Compile & Lint" - runs-on: "ubuntu-latest" + name: >- + Test on + Elixir ${{ matrix.elixir }} and Erlang/OTP ${{ matrix.otp }} + ${{ matrix.update-deps && 'with the latest dependencies' }} + runs-on: "ubuntu-22.04" + strategy: + fail-fast: false + matrix: + include: + # Test on all supported releases. Compatibility matrix from + # https://hexdocs.pm/elixir/compatibility-and-deprecations.html + # + # These pin to the lowest supported OTP for each elixir release. + - { elixir: '1.15', otp: '24' } + - { elixir: '1.16', otp: '24' } + - { elixir: '1.17', otp: '25' } + - { elixir: '1.18', otp: '25' } + - { elixir: '1.18', otp: '25', update-deps: true } steps: - name: Setup elixir uses: erlef/setup-beam@v1 with: - otp-version: 24.3.3 - elixir-version: 1.16.3 + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} - - uses: actions/checkout@v1 - - run: mix deps.get + - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - name: Setup dependency cache + uses: actions/cache@v3 id: mix-cache + with: + path: | + deps + key: mix-${{ hashFiles('mix.lock') }} + + - name: Setup binary cache + uses: actions/cache@v3 with: path: | ./_build ./priv/plts - key: deps-${{ hashFiles('**/mix.lock') }} + key: ${{ matrix.elixir }}-${{ matrix.otp }} + + - name: Unlock dependencies to get latest + if: ${{ matrix.update-deps }} + run: mix deps.unlock --all - - if: steps.mix-cache.outputs.cache-hit != 'true' + - name: Fetch dependencies + run: mix deps.get + + - name: Rebuild dependencies + if: steps.mix-cache.outputs.cache-hit != 'true' run: | mkdir -p priv/plts mix local.rebar --force @@ -31,5 +62,13 @@ jobs: mix deps.compile mix dialyzer --plt - - run: | - mix lint + - name: Run linters + run: mix lint + +# - name: Install wx support packages +# run: sudo apt install -y libwxgtk3.0-gtk3-0v5 + +# FIXME: tests currently require an X display. +# - name: Run test +# run: | +# mix test diff --git a/mix.exs b/mix.exs index 8a7b2e7..3b70cec 100644 --- a/mix.exs +++ b/mix.exs @@ -14,7 +14,7 @@ defmodule Desktop.MixProject do version: @version, source_url: @url, description: @description, - elixir: "~> 1.11", + elixir: "~> 1.14", elixirc_paths: elixirc_paths(Mix.env()), compilers: Mix.compilers(), aliases: aliases(),