From 64a9a7f0632c23ba912cd7ff4e8cc3f9f0be5630 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Wed, 6 Nov 2024 16:10:25 +0000 Subject: [PATCH 1/5] Add GH action to run tests --- .github/workflows/elixir_tests.yml | 76 ++++++++++++++++++++++++++++++ .tool-versions | 2 + 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/elixir_tests.yml create mode 100644 .tool-versions diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml new file mode 100644 index 0000000..0022fd3 --- /dev/null +++ b/.github/workflows/elixir_tests.yml @@ -0,0 +1,76 @@ +name: Elixir CI + +on: + push: + branches: ["main"] + paths-ignore: + - "**/README.md" + pull_request: + paths-ignore: + - "**/README.md" + +permissions: + contents: read + +jobs: + build: + name: Build and test with PostgreSQL 14 + 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@v3 + 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: 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: Compiles without warnings + run: mix compile --force --all-warnings --warnings-as-errors + + - name: Run tests + run: mix test + formatting: + name: Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + version-type: strict + version-file: ".tool-versions" + - name: Cache dependencies + id: cache-deps + uses: actions/cache@v4 + with: + path: deps + key: ${{ runner.os }}-mixdeps-${{ hashFiles('mix.lock') }} + - run: mix deps.get + - run: mix format --check-formatted diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..b7c4c5b --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +elixir 1.17.2-otp-27 +erlang 27.0.1 From 4e35a6467e1957bbe18620efa0ae6f29ee604f80 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Wed, 6 Nov 2024 16:14:00 +0000 Subject: [PATCH 2/5] hide spurious errors from log --- .github/workflows/elixir_tests.yml | 2 +- config/test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml index 0022fd3..189772a 100644 --- a/.github/workflows/elixir_tests.yml +++ b/.github/workflows/elixir_tests.yml @@ -56,7 +56,7 @@ jobs: run: mix compile --force --all-warnings --warnings-as-errors - name: Run tests - run: mix test + run: mix test --trace formatting: name: Check formatting runs-on: ubuntu-latest diff --git a/config/test.exs b/config/test.exs index e5b5459..fa877c1 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,6 +1,6 @@ import Config -config :logger, level: :warning +config :logger, level: :critical config :electric_phoenix, Electric.Phoenix.LiveViewTest.Endpoint, [] From 5fc8caf75209a0789c3843aed1b512fb021489f1 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Wed, 6 Nov 2024 16:16:14 +0000 Subject: [PATCH 3/5] fix caching --- .github/workflows/elixir_tests.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml index 189772a..3415cc9 100644 --- a/.github/workflows/elixir_tests.yml +++ b/.github/workflows/elixir_tests.yml @@ -27,7 +27,7 @@ jobs: version-file: ".tool-versions" - name: Restore dependencies cache - uses: actions/cache@v3 + uses: actions/cache/restore@v4 with: path: deps key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }} @@ -44,6 +44,13 @@ jobs: - 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: Save compiled code uses: actions/cache/save@v4 with: @@ -66,11 +73,11 @@ jobs: with: version-type: strict version-file: ".tool-versions" - - name: Cache dependencies - id: cache-deps - uses: actions/cache@v4 + - name: Restore dependencies cache + uses: actions/cache/restore@v4 with: path: deps - key: ${{ runner.os }}-mixdeps-${{ hashFiles('mix.lock') }} + key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }} + restore-keys: ${{ runner.os }}-mix- - run: mix deps.get - run: mix format --check-formatted From 77f547808fe71799df90c8bfb8f1c55fa6a6e514 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Wed, 6 Nov 2024 16:21:20 +0000 Subject: [PATCH 4/5] caching... --- .github/workflows/elixir_tests.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml index 3415cc9..74a6ac5 100644 --- a/.github/workflows/elixir_tests.yml +++ b/.github/workflows/elixir_tests.yml @@ -13,8 +13,8 @@ permissions: contents: read jobs: - build: - name: Build and test with PostgreSQL 14 + test: + name: mix test runs-on: ubuntu-latest env: MIX_ENV: test @@ -51,6 +51,9 @@ jobs: 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: @@ -59,14 +62,14 @@ jobs: !_build/*/lib/electric_phoenix key: ${{ runner.os }}-build-test-${{ hashFiles('mix.lock') }} - - name: Compiles without warnings - run: mix compile --force --all-warnings --warnings-as-errors - - name: Run tests run: mix test --trace + formatting: name: Check formatting runs-on: ubuntu-latest + env: + MIX_ENV: test steps: - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 From 76ea9c0046f60ba26e6debe6afc5d9a8c82aaaa2 Mon Sep 17 00:00:00 2001 From: Garry Hill Date: Wed, 6 Nov 2024 16:23:03 +0000 Subject: [PATCH 5/5] rename job --- .github/workflows/elixir_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/elixir_tests.yml b/.github/workflows/elixir_tests.yml index 74a6ac5..8550e3d 100644 --- a/.github/workflows/elixir_tests.yml +++ b/.github/workflows/elixir_tests.yml @@ -66,7 +66,7 @@ jobs: run: mix test --trace formatting: - name: Check formatting + name: mix format --check-formatted runs-on: ubuntu-latest env: MIX_ENV: test