diff --git a/.github/workflows/app_test/action.yml b/.github/workflows/app_test/action.yml new file mode 100644 index 0000000..3346e08 --- /dev/null +++ b/.github/workflows/app_test/action.yml @@ -0,0 +1,12 @@ +name: App Tests +description: "Run Elixir tests" +runs: + using: "composite" + steps: + - name: Run elixir tests + shell: bash + run: | + cd test_pass + mix test + cd ../test_fail + mix test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b982b46 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: push + +jobs: + app-test: + name: Run Application Tests + runs-on: ubuntu-20.04 + env: + MIX_ENV: test + + services: + db: + image: postgres + ports: ["5432:5432"] + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTRGES_DB: excessibility_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - name: Checkout Project + uses: actions/checkout@v3 + - name: Setup App + uses: ./.github/workflows/setup + - name: Run Application Tests + uses: ./.github/workflows/app_test diff --git a/.github/workflows/setup/action.yml b/.github/workflows/setup/action.yml new file mode 100644 index 0000000..cf8c519 --- /dev/null +++ b/.github/workflows/setup/action.yml @@ -0,0 +1,40 @@ +nGame: Build App +description: "Build the app" +runs: + using: "composite" + steps: + - name: Checkout Project + uses: actions/checkout@v3 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + otp-version: "25.1" # Define the OTP version [required] + elixir-version: "1.14.0" # Define the elixir version [required] + - name: Store/Retrieve Mix Dependencies Cache + uses: actions/cache@v3 + id: mix-cache # id to use in retrieve action + with: + path: | + deps + _build + test_pass/deps + test_pass/_build + test_fail/deps + test_fail/_build + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + - name: Clean deps to rule out incremental build as a source of flakiness + if: github.run_attempt != '1' + run: | + mix deps.clean --all && mix clean + cd test_pass && mix deps.clean --all && mix clean + cd ../test_fail && mix deps.clean --all && mix clean + shell: sh + - name: Install Elixir Dependencies + if: steps.mix-cache.outputs.cache-hit != 'true' || github.run_attempt != '1' + run: | + mix deps.get && mix deps.compile + cd test_pass && mix deps.get && mix compile + cd ../test_fail && mix deps.get && mix compile + shell: sh diff --git a/lib/mix/tasks/excessibility.ex b/lib/mix/tasks/excessibility.ex index caf7ddd..861366a 100644 --- a/lib/mix/tasks/excessibility.ex +++ b/lib/mix/tasks/excessibility.ex @@ -1,7 +1,7 @@ defmodule Mix.Tasks.Excessibility do @moduledoc "Library to aid in testing your application for WCAG compliance automatically using Pa11y and Wallaby." @shortdoc "Runs pally against generated snapshots" - @requirements ["app.config"] + @requirements ["app.config", "app.start"] @assets_task Application.compile_env(:excessibility, :assets_task, "assets.deploy") @pally_path Application.compile_env( :excessibility, diff --git a/mix.exs b/mix.exs index 87930f6..7a739b2 100644 --- a/mix.exs +++ b/mix.exs @@ -9,6 +9,7 @@ defmodule Excessibility.MixProject do start_permanent: false, description: description(), package: package(), + aliases: aliases(), deps: deps() ] end @@ -47,4 +48,13 @@ defmodule Excessibility.MixProject do {:wallaby, ">= 0.25.0"} ] end + + defp aliases do + [ + "assets.deploy": [ + "cmd --cd assets node build.mjs --deploy", + "phx.digest" + ] + ] + end end diff --git a/test_fail/mix.exs b/test_fail/mix.exs index edab706..3993a73 100644 --- a/test_fail/mix.exs +++ b/test_fail/mix.exs @@ -34,7 +34,7 @@ defmodule TestFail.MixProject do [ {:ecto_sql, "~> 3.6"}, {:esbuild, "~> 0.5", runtime: Mix.env() == :dev}, - {:excessibility, "~> 0.2.0", only: [:dev, :test], path: "../"}, + {:excessibility, "~> 0.3.0", only: [:dev, :test], path: "../"}, {:finch, "~> 0.13"}, {:floki, ">= 0.30.0", only: [:dev, :test]}, {:gettext, "~> 0.20"}, diff --git a/test_pass/mix.exs b/test_pass/mix.exs index bdce408..f4c8b1d 100644 --- a/test_pass/mix.exs +++ b/test_pass/mix.exs @@ -34,7 +34,7 @@ defmodule TestPass.MixProject do [ {:ecto_sql, "~> 3.6"}, {:esbuild, "~> 0.5", runtime: Mix.env() == :dev}, - {:excessibility, "~> 0.2.0", only: [:dev, :test], path: "../"}, + {:excessibility, "~> 0.3.0", only: [:dev, :test], path: "../"}, {:finch, "~> 0.13"}, {:floki, ">= 0.30.0", only: [:dev, :test]}, {:gettext, "~> 0.20"},