Skip to content
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

Add GH action to run tests #6

Merged
merged 5 commits into from
Nov 6, 2024
Merged
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
86 changes: 86 additions & 0 deletions .github/workflows/elixir_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Elixir CI

on:
push:
branches: ["main"]
paths-ignore:
- "**/README.md"
pull_request:
paths-ignore:
- "**/README.md"

permissions:
contents: read

jobs:
test:
name: mix test
runs-on: ubuntu-latest
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: ".tool-versions"

- name: Restore dependencies cache
uses: actions/cache/restore@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }}
restore-keys: ${{ runner.os }}-mix-

- name: Restore compiled code
uses: actions/cache/restore@v4
with:
path: |
_build/*/lib
!_build/*/lib/electric_phoenix
key: ${{ runner.os }}-build-test-${{ hashFiles('mix.lock') }}

- name: Install dependencies
run: mix deps.get && mix deps.compile

- name: Cache dependencies
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }}
restore-keys: ${{ runner.os }}-mix-

- name: Compiles without warnings
run: mix compile --force --all-warnings --warnings-as-errors

- name: Save compiled code
uses: actions/cache/save@v4
with:
path: |
_build/*/lib
!_build/*/lib/electric_phoenix
key: ${{ runner.os }}-build-test-${{ hashFiles('mix.lock') }}

- name: Run tests
run: mix test --trace

formatting:
name: mix format --check-formatted
runs-on: ubuntu-latest
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: ".tool-versions"
- name: Restore dependencies cache
uses: actions/cache/restore@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- run: mix deps.get
- run: mix format --check-formatted
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
elixir 1.17.2-otp-27
erlang 27.0.1
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Config

config :logger, level: :warning
config :logger, level: :critical

config :electric_phoenix, Electric.Phoenix.LiveViewTest.Endpoint, []

Expand Down
Loading