diff --git a/.github/workflows/fcx-web.yml b/.github/workflows/fcx-web.yml new file mode 100644 index 0000000..0126578 --- /dev/null +++ b/.github/workflows/fcx-web.yml @@ -0,0 +1,107 @@ +name: fcx-web + +on: + push: + pull_request: + +# Cancel superseded runs on the same ref so rapid pushes don't pile up. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + MIX_ENV: test + +jobs: + # Formatting is version-independent, so check it once instead of per matrix cell. + lint: + name: Lint + runs-on: ubuntu-latest + env: + ELIXIR_VERSION: "1.15" + OTP_VERSION: "25" + defaults: + run: + working-directory: fcx-web + steps: + - uses: actions/checkout@v6 + + - name: Set up Elixir / OTP + uses: erlef/setup-beam@v1 + with: + otp-version: ${{ env.OTP_VERSION }} + elixir-version: ${{ env.ELIXIR_VERSION }} + + - name: Cache deps and _build + uses: actions/cache@v5 + with: + path: | + fcx-web/deps + fcx-web/_build + key: ${{ runner.os }}-mix-lint-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ hashFiles('fcx-web/mix.lock') }} + restore-keys: ${{ runner.os }}-mix-lint-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}- + + - name: Install dependencies + run: mix deps.get + + # Compile before format so all dependency apps are loaded. + - name: Compile + run: mix compile + + - name: Check formatting + run: mix format --check-formatted + + test: + name: fcx-web tests (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }}) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - elixir: "1.15" + otp: "25" + - elixir: "1.16" + otp: "26" + - elixir: "1.17" + otp: "27" + - elixir: "1.18" + otp: "27" + - elixir: "1.19" + otp: "28" + + defaults: + run: + working-directory: fcx-web + + steps: + - uses: actions/checkout@v6 + + - name: Set up Elixir / OTP + uses: erlef/setup-beam@v1 + with: + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} + + - name: Cache deps and _build + uses: actions/cache@v5 + with: + path: | + fcx-web/deps + fcx-web/_build + key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('fcx-web/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}- + + - name: Install dependencies + run: mix deps.get + + - name: Compile (warnings as errors) + run: mix compile --warnings-as-errors + + # SQLite test DB — no database service required. + - name: Run tests + run: mix test diff --git a/fcx-web/config/config.exs b/fcx-web/config/config.exs index ea016ae..c26cfca 100644 --- a/fcx-web/config/config.exs +++ b/fcx-web/config/config.exs @@ -11,7 +11,8 @@ config :fullcontrol_x, namespace: FullControlX, ecto_repos: [FullControlX.Repo], fcxd_path: "../zig-out/bin/FullControlX", - files_path: "priv/static/assets" + files_path: "priv/static/assets", + start_driver: true # Configures the endpoint config :fullcontrol_x, FullControlXWeb.Endpoint, diff --git a/fcx-web/config/prod.exs b/fcx-web/config/prod.exs index 160d44d..0b88d7f 100644 --- a/fcx-web/config/prod.exs +++ b/fcx-web/config/prod.exs @@ -9,7 +9,8 @@ import Config # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. -config :fullcontrol_x, FullControlXWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" +config :fullcontrol_x, FullControlXWeb.Endpoint, + cache_static_manifest: "priv/static/cache_manifest.json" # Do not print debug messages in production config :logger, level: :info diff --git a/fcx-web/config/test.exs b/fcx-web/config/test.exs index 9555d0d..a4c5371 100644 --- a/fcx-web/config/test.exs +++ b/fcx-web/config/test.exs @@ -17,8 +17,11 @@ config :fullcontrol_x, FullControlXWeb.Endpoint, secret_key_base: "EgTKrB+SZcnfHfZUYem501WigH0KvvCe5J6YSP6JfwxM7aKjQ2BQWw2SaCUegyhS", server: false +# No native fcxd binary in test; don't start the driver. +config :fullcontrol_x, start_driver: false + # Print only warnings and errors during test -config :logger, level: :warn +config :logger, level: :warning # Initialize plugs at runtime for faster test compilation config :phoenix, :plug_init_mode, :runtime diff --git a/fcx-web/lib/fullcontrol_x/application.ex b/fcx-web/lib/fullcontrol_x/application.ex index b4fd541..85eaab8 100644 --- a/fcx-web/lib/fullcontrol_x/application.ex +++ b/fcx-web/lib/fullcontrol_x/application.ex @@ -9,20 +9,17 @@ defmodule FullControlX.Application do def start(_type, _args) do FullControlX.print_connection_qrcode() - children = [ - # Start the Ecto repository - FullControlX.Repo, - # Start the Telemetry supervisor - FullControlXWeb.Telemetry, - # Start the PubSub system - {Phoenix.PubSub, name: FullControlX.PubSub}, - # Start the Endpoint (http/https) - FullControlXWeb.Endpoint, - # Start a worker by calling: FullControlX.Worker.start_link(arg) - # {FullControlX.Worker, arg} - {FullControlX.Driver, - name: FullControlX.Driver, fcxd_path: Application.get_env(:fullcontrol_x, :fcxd_path)} - ] + children = + [ + # Start the Ecto repository + FullControlX.Repo, + # Start the Telemetry supervisor + FullControlXWeb.Telemetry, + # Start the PubSub system + {Phoenix.PubSub, name: FullControlX.PubSub}, + # Start the Endpoint (http/https) + FullControlXWeb.Endpoint + ] ++ driver_children() # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options @@ -30,6 +27,18 @@ defmodule FullControlX.Application do Supervisor.start_link(children, opts) end + # Skip the driver where its native fcxd binary isn't built (e.g. test). + defp driver_children do + if Application.get_env(:fullcontrol_x, :start_driver, true) do + [ + {FullControlX.Driver, + name: FullControlX.Driver, fcxd_path: Application.get_env(:fullcontrol_x, :fcxd_path)} + ] + else + [] + end + end + # Tell Phoenix to update the endpoint configuration # whenever the application is updated. @impl true diff --git a/fcx-web/lib/fullcontrol_x_web/commands_live.ex b/fcx-web/lib/fullcontrol_x_web/commands_live.ex index fa10715..9164b91 100644 --- a/fcx-web/lib/fullcontrol_x_web/commands_live.ex +++ b/fcx-web/lib/fullcontrol_x_web/commands_live.ex @@ -12,10 +12,11 @@ defmodule FullControlXWeb.CommandsLive do ~H""" <.header title="FullControlX" />
+ diff --git a/fcx-web/lib/fullcontrol_x_web/components.ex b/fcx-web/lib/fullcontrol_x_web/components.ex index c4fb5a8..f3c68d6 100644 --- a/fcx-web/lib/fullcontrol_x_web/components.ex +++ b/fcx-web/lib/fullcontrol_x_web/components.ex @@ -32,8 +32,7 @@ defmodule FullControlXWeb.Components do def switch(assigns) do ~H""" """ end diff --git a/fcx-web/lib/fullcontrol_x_web/info_live.ex b/fcx-web/lib/fullcontrol_x_web/info_live.ex index e23e454..4f3004f 100644 --- a/fcx-web/lib/fullcontrol_x_web/info_live.ex +++ b/fcx-web/lib/fullcontrol_x_web/info_live.ex @@ -21,31 +21,49 @@ defmodule FullControlXWeb.InfoLive do<%= @url_in_qrcode %>
+ +{@url_in_qrcode}
FullControlX is the official Open Source "spinoff" of the commercial app FullControl.
-Developed and maintained by Francesco Burelli. More info at Github Project Homepage.
+ ++ FullControlX is the official Open Source "spinoff" of the commercial app FullControl. +
+ ++ Developed and maintained by Francesco Burelli. More info at Github Project Homepage. +
Left click: one tap
+Right click: one tap with two fingers
+Scroll: drag with two fingers
+Drag: one tap and drag or drag with three fingers