From 9636f51b83237abce3c04aef93f9bfc7a27a87ec Mon Sep 17 00:00:00 2001 From: Steffen Beyer Date: Sat, 14 Mar 2026 19:18:38 +0100 Subject: [PATCH] ci: GitHub action --- .github/workflows/ci.yaml | 116 ++++++++++++++++++++++++++++++++++++++ mix.exs | 2 +- 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..20afee9 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,116 @@ +name: CI + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +env: + MIX_ENV: test + +permissions: + contents: read + +jobs: + test: + name: ${{ matrix.name }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + include: + - name: Test (OTP 27.2 / Elixir 1.18.2) + otp: "27.2" + elixir: "1.18.2" + main: false + - name: Test (OTP 28.4 / Elixir 1.19.4 + Marmot E2E) + otp: "28.4" + elixir: "1.19.4" + main: true + + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: app_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + env: + PGHOST: localhost + PGPORT: 5432 + PGUSER: postgres + PGPASSWORD: postgres + PGDATABASE: app_test + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Elixir + OTP + uses: erlef/setup-beam@v1 + with: + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + # Cache deps/ directory — keyed on mix.lock + - name: Cache Mix deps + uses: actions/cache@v4 + id: deps-cache + with: + path: deps + key: ${{ runner.os }}-mix-deps-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-deps- + + # Cache _build/ — keyed on mix.lock + OTP/Elixir versions + - name: Cache _build + uses: actions/cache@v4 + with: + path: _build + key: ${{ runner.os }}-mix-build-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-build-${{ matrix.otp }}-${{ matrix.elixir }}- + + - name: Install Mix dependencies + if: steps.deps-cache.outputs.cache-hit != 'true' + run: mix deps.get + + - name: Compile (warnings as errors) + if: ${{ matrix.main }} + run: mix compile --warnings-as-errors + + - name: Check formatting + if: ${{ matrix.main }} + run: mix format --check-formatted + + - name: Credo + if: ${{ matrix.main }} + run: mix credo --strict --all + + - name: Run tests + run: mix test --color + + - name: Run Marmot E2E + run: mix test.marmot_e2e + + - name: Check for unused locked deps + if: ${{ matrix.main }} + run: | + mix deps.unlock --unused + git diff --exit-code -- mix.lock diff --git a/mix.exs b/mix.exs index 484db2a..1533ded 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule Parrhesia.MixProject do [ app: :parrhesia, version: "0.4.0", - elixir: "~> 1.19", + elixir: "~> 1.18", start_permanent: Mix.env() == :prod, deps: deps(), aliases: aliases()