80 lines
1.9 KiB
YAML
80 lines
1.9 KiB
YAML
name: Code Quality
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
|
|
jobs:
|
|
code-quality:
|
|
runs-on: ubuntu-22.04
|
|
name: Code Quality (Elixir ${{matrix.elixir}} OTP ${{matrix.otp}})
|
|
strategy:
|
|
matrix:
|
|
otp: ['26.2']
|
|
elixir: ['1.15.7']
|
|
|
|
services:
|
|
db:
|
|
image: postgres:15
|
|
ports: ['5432:5432']
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libssl-dev libncurses5-dev
|
|
|
|
- name: Set up Elixir
|
|
uses: erlef/setup-beam@v1
|
|
with:
|
|
elixir-version: ${{matrix.elixir}}
|
|
otp-version: ${{matrix.otp}}
|
|
|
|
- name: Restore dependencies cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: deps
|
|
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
|
|
restore-keys: ${{ runner.os }}-mix-
|
|
|
|
- name: Restore compiled code cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: _build
|
|
key: ${{ runner.os }}-build-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ matrix.otp }}-${{ matrix.elixir }}-
|
|
|
|
- name: Install dependencies
|
|
run: mix deps.get
|
|
|
|
- name: Check for unused dependencies
|
|
run: mix deps.unlock --check-unused
|
|
|
|
- name: Compile with warnings as errors
|
|
run: mix compile --warnings-as-errors
|
|
|
|
- name: Check code formatting
|
|
run: mix format --check-formatted
|
|
|
|
- name: Run tests
|
|
run: mix test
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
- name: Run precommit (should pass if all above passed)
|
|
run: mix precommit
|
|
env:
|
|
POSTGRES_PASSWORD: postgres |