mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Add CI workflow with test and release build (#127)
This commit is contained in:
@@ -0,0 +1,96 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
env:
|
||||||
|
MIX_ENV: test
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:18.0
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U postgres"
|
||||||
|
--health-interval 5s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 10
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: jdx/mise-action@v2
|
||||||
|
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
deps
|
||||||
|
_build
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-mix-test-${{ hashFiles('mix.lock', 'mise.toml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-mix-test-
|
||||||
|
|
||||||
|
- run: mix local.hex --force
|
||||||
|
- run: mix local.rebar --force
|
||||||
|
- run: mix deps.get
|
||||||
|
- run: mix format --check-formatted
|
||||||
|
- run: mix precommit
|
||||||
|
|
||||||
|
build-release:
|
||||||
|
name: Build release
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
env:
|
||||||
|
MIX_ENV: prod
|
||||||
|
SECRET_KEY_BASE: build-only-secret-key-base-build-only-secret-key-base-build-only-secret-key-base
|
||||||
|
DATABASE_URL: ecto://postgres:postgres@127.0.0.1:5432/chesstrainer_build
|
||||||
|
SES_REGION: eu-north-1
|
||||||
|
SES_ACCESS_KEY_ID: build
|
||||||
|
SES_SECRET_ACCESS_KEY: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: jdx/mise-action@v2
|
||||||
|
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
deps
|
||||||
|
_build
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-mix-prod-${{ hashFiles('mix.lock', 'mise.toml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-mix-prod-
|
||||||
|
|
||||||
|
- run: mix local.hex --force
|
||||||
|
- run: mix local.rebar --force
|
||||||
|
- run: mix deps.get --only prod
|
||||||
|
- run: mix assets.setup
|
||||||
|
- run: mix assets.deploy
|
||||||
|
- run: mix release
|
||||||
|
- run: tar -czf chesstrainer-release.tar.gz -C _build/prod/rel/chesstrainer .
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: chesstrainer-release
|
||||||
|
path: chesstrainer-release.tar.gz
|
||||||
|
retention-days: 7
|
||||||
Reference in New Issue
Block a user