Skip to content

Commit

Permalink
initial test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lessthanseventy committed Apr 21, 2023
1 parent 0db6bde commit 0ef243c
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/app_test/action.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/mix/tasks/excessibility.ex
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 10 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule Excessibility.MixProject do
start_permanent: false,
description: description(),
package: package(),
aliases: aliases(),
deps: deps()
]
end
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion test_fail/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion test_pass/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 0ef243c

Please sign in to comment.