Update github cache action to v4 #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: | |
- '**/*' | |
workflow_dispatch: | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-24.04 | |
env: | |
ERLANG_VERSION: 26.2.5.5 | |
ELIXIR_VERSION: 1.17.3 | |
MINESWEEPER_DATABASE_URL: ecto://minesweeper:minesweeper@localhost/minesweeper | |
MINESWEEPER_SECRET_KEY_BASE: secret | |
strategy: | |
matrix: | |
postgres: [12, 13, 14, 15, 16, 17] | |
services: | |
postgres: | |
image: postgres:${{ matrix.postgres }} | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: minesweeper | |
POSTGRES_USER: minesweeper | |
POSTGRES_PASSWORD: minesweeper | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
# https://github.com/actions/checkout | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
# https://github.com/actions/cache | |
- name: Cache build | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build | |
key: ${{ runner.os }}-mix-erlang-${{ env.ERLANG_VERSION }}-elixir-${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }} | |
restore-keys: | | |
${{ runner.os }}-mix-erlang-${{ env.ERLANG_VERSION }}-elixir-${{ env.ELIXIR_VERSION }}- | |
# https://github.com/erlef/setup-beam | |
- name: Install Erlang/OTP & Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.ERLANG_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
# https://github.com/asdf-vm/actions#setup | |
- name: Install asdf | |
uses: asdf-vm/actions/setup@v3 | |
with: | |
asdf_branch: v0.14.1 | |
- name: Install Node.js with asdf | |
run: | | |
asdf plugin add nodejs | |
asdf install nodejs | |
node --version | |
- name: Install backend dependencies | |
run: | | |
mix deps.get | |
- name: Install frontend dependencies | |
run: | | |
npm ci | |
- name: Compile the application | |
run: | | |
mix compile | |
- name: Create and migrate the database | |
run: | | |
mix ecto.create | |
mix ecto.migrate | |
- name: Run automated tests & measure code coverage for the backend | |
id: tests | |
run: | | |
mix coveralls.html --raise | |
- name: Check backend code formatting | |
run: | | |
mix format --check-formatted | |
- name: Check for unused dependencies | |
run: | | |
mix deps.unlock --check-unused | |
- name: Show retired dependencies | |
run: | | |
mix hex.audit | |
- name: Ensure there are no uncommitted changes | |
run: | | |
git status --porcelain | |
test -z "$(git status --porcelain)" |