Skip to content

CI with both old and new elixir #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 56 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
name: "CI"
on: ["push", "pull_request"]
on:
- push
- pull_request

jobs:
test_and_build:
name: "Build mix release"
runs-on: "ubuntu-latest"
runs-on: "ubuntu-20.04"
name: >-
Test on
Elixir ${{ matrix.elixir }} and Erlang/OTP ${{ matrix.otp }}
${{ matrix.update-deps && 'with the latest dependencies' }}
strategy:
fail-fast: false
matrix:
include:
# Test on all supported releases.
- { elixir: '1.11', otp: '24' }
- { elixir: '1.12', otp: '24' }
- { elixir: '1.13', otp: '24' }
- { elixir: '1.13', otp: '25' }
- { elixir: '1.14', otp: '24' }
- { elixir: '1.14', otp: '25' }
- { elixir: '1.14', otp: '25', update-deps: true }
steps:
- run: |
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt-get update
sudo apt-get install --allow-downgrades esl-erlang=1:24.3.3-1 inotify-tools
mkdir $HOME/elixir && cd $HOME/elixir
wget https://github.com/elixir-lang/elixir/releases/download/v1.11.4/Precompiled.zip
unzip Precompiled.zip
echo "$HOME/elixir/bin" >> $GITHUB_PATH
- uses: actions/checkout@v1
- run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
mix lint
# mix test
- uses: actions/checkout@v3

- name: Setup dependency cache
uses: actions/cache@v3
with:
path: |
deps
key: mix-${{ hashFiles('mix.lock') }}

- name: Setup binary cache
uses: actions/cache@v3
with:
path: |
_build
priv/plts
key: ${{ matrix.elixir }}-${{ matrix.otp }}

- name: Setup beam
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Unlock dependencies to get latest
if: ${{ matrix.update-deps }}
run: mix deps.unlock --all

- name: Fetch dependencies
run: mix deps.get

- name: Run linters
run: mix lint

# TODO: Tests should pass on the main branch.
# - name: Run tests
# run: mix test
15 changes: 6 additions & 9 deletions lib/desktop/menu.ex
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,16 @@ defmodule Desktop.Menu do

@impl true
def handle_cast({:set_icon, icon}, menu) do
with {:ok, menu} <- set_adapter_icon(menu, icon) do
{:noreply, menu}
else
case set_adapter_icon(menu, icon) do
{:ok, menu} -> {:noreply, menu}
_error -> {:noreply, menu}
end
end

def handle_cast({:trigger_event, event}, menu = %{module: module}) do
menu =
with {:ok, {:noreply, menu}} <- invoke_module_func(module, :handle_event, [event, menu]) do
update_dom(menu)
else
case invoke_module_func(module, :handle_event, [event, menu]) do
{:ok, {:noreply, menu}} -> update_dom(menu)
_ -> menu
end

Expand Down Expand Up @@ -419,9 +417,8 @@ defmodule Desktop.Menu do
end

defp proxy_handle_info(msg, menu = %Menu{module: module}) do
with {:ok, {:noreply, menu}} <- invoke_module_func(module, :handle_info, [msg, menu]) do
update_dom(menu)
else
case invoke_module_func(module, :handle_info, [msg, menu]) do
{:ok, {:noreply, menu}} -> update_dom(menu)
_ -> menu
end
end
Expand Down
26 changes: 13 additions & 13 deletions lib/desktop/menu/adapters/wx.ex
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,21 @@ defmodule Desktop.Menu.Adapter.Wx do
end

defp create_taskbar_icon(fn_create_popup, icon) do
with {:ok, taskbar_icon = %TaskBarIcon{wx_taskbar_icon: wx_taskbar_icon}} <-
TaskBarIcon.create(fn_create_popup) do
TaskBarIcon.connect(taskbar_icon)
TaskBarIcon.set_icon(taskbar_icon, icon)

if OS.type() == Windows do
# This links the taskbar icon and the application itself on Windows
if Code.ensure_loaded?(:wxNotificationMessage) &&
Kernel.function_exported?(:wxNotificationMessage, :useTaskBarIcon, 1) do
:wxNotificationMessage.useTaskBarIcon(wx_taskbar_icon)
case TaskBarIcon.create(fn_create_popup) do
{:ok, taskbar_icon = %TaskBarIcon{wx_taskbar_icon: wx_taskbar_icon}} ->
TaskBarIcon.connect(taskbar_icon)
TaskBarIcon.set_icon(taskbar_icon, icon)

if OS.type() == Windows do
# This links the taskbar icon and the application itself on Windows
if Code.ensure_loaded?(:wxNotificationMessage) &&
Kernel.function_exported?(:wxNotificationMessage, :useTaskBarIcon, 1) do
:wxNotificationMessage.useTaskBarIcon(wx_taskbar_icon)
end
end
end

taskbar_icon
else
taskbar_icon

error ->
Logger.warning("Failed to create TaskBar Icon: #{inspect(error)}")
nil
Expand Down
4 changes: 1 addition & 3 deletions lib/desktop/window.ex
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ defmodule Desktop.Window do
case Enum.find(noties, fn {_, {wx_ref, _callback}} -> wx_ref == obj end) do
nil ->
Logger.error(
"Received unhandled notification event #{inspect(obj)}: #{inspect(action)} (#{
inspect(noties)
})"
"Received unhandled notification event #{inspect(obj)}: #{inspect(action)} (#{inspect(noties)})"
)

{_, {_ref, nil}} ->
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ defmodule Desktop.MixProject do
description: """
Write Desktop Apps with Elixir.
""",
elixir: "~> 1.10",
elixir: "~> 1.11",
# TODO: Also requires otp: "~> 24"
elixirc_paths: elixirc_paths(Mix.env()),
compilers: Mix.compilers(),
aliases: aliases(),
Expand Down