103 lines
2.6 KiB
YAML
103 lines
2.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- prod
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- prod
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
APP_ENV: test
|
|
APP_SECRET: ci-secret
|
|
DATABASE_DRIVER: sqlite
|
|
DATABASE_SQLITE_PATH: ${{ github.workspace }}/var/data/database.test.sqlite
|
|
|
|
jobs:
|
|
php-tests:
|
|
name: PHPUnit + migrations
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.2'
|
|
extensions: intl, mbstring, pdo_pgsql, pdo_sqlite, zip, gd
|
|
coverage: none
|
|
ini-values: memory_limit=512M
|
|
tools: composer:v2
|
|
|
|
- name: Validate Composer manifest
|
|
run: composer validate --strict
|
|
|
|
- name: Cache Composer downloads
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/composer/files
|
|
~/.cache/composer/vcs
|
|
key: composer-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
composer-${{ runner.os }}-
|
|
|
|
- name: Install Composer dependencies
|
|
run: composer install --prefer-dist --no-interaction --no-progress
|
|
|
|
- name: Prepare SQLite database
|
|
run: |
|
|
mkdir -p "$(dirname "$DATABASE_SQLITE_PATH")"
|
|
touch "$DATABASE_SQLITE_PATH"
|
|
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
|
|
|
|
- name: Run PHPUnit
|
|
run: vendor/bin/phpunit --colors=always
|
|
|
|
docker-image:
|
|
name: Build production image
|
|
needs: php-tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build prod image
|
|
id: build-prod
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/php/Dockerfile
|
|
target: prod
|
|
load: true
|
|
push: false
|
|
tags: tonehaus-app:ci
|
|
|
|
- name: Verify baked APP_ENV
|
|
run: docker run --rm --entrypoint sh tonehaus-app:ci -c 'test "$APP_ENV" = "prod"'
|
|
|
|
- name: Verify Symfony artifacts exist
|
|
run: |
|
|
docker run --rm --entrypoint sh tonehaus-app:ci -c 'test -f /var/www/html/public/index.php'
|
|
docker run --rm --entrypoint sh tonehaus-app:ci -c 'test -f /var/www/html/bin/console'
|
|
|
|
- name: Smoke-test entrypoint & migrations
|
|
run: docker run --rm -e APP_SECRET=test-secret --entrypoint /entrypoint.sh tonehaus-app:ci true
|
|
|