Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,90 @@ jobs:

- name: Run tests with coverage
run: pnpm test:coverage

ci-backend:
runs-on: ubuntu-latest

services:
mariadb:
image: mariadb:10.11
env:
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: consonum_test
MARIADB_USER: consonum
MARIADB_PASSWORD: mariadb
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=5

defaults:
run:
working-directory: backend

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP 8.2 with PCOV
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: pdo, pdo_mysql, pcov
coverage: pcov

- name: Create .env file
run: |
echo "APP_ENV=test" > .env
echo "APP_SECRET=test_secret" >> .env
echo "DEFAULT_URI=http://localhost" >> .env
echo "KERNEL_CLASS=App\Kernel" >> .env
echo "DATABASE_URL=mysql://consonum:mariadb@127.0.0.1:3306/consonum_test?serverVersion=mariadb-10.11.6" >> .env
echo "JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem" >> .env
echo "JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem" >> .env
echo "JWT_PASSPHRASE=" >> .env
echo "MAILER_DSN=null://null" >> .env
echo "FRONTEND_URL=http://localhost:3000" >> .env
echo "CORS_ALLOW_ORIGIN=http://localhost:3000" >> .env

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('backend/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Generate JWT keys
run: |
mkdir -p config/jwt
openssl genrsa -out config/jwt/private.pem 2048
openssl rsa -in config/jwt/private.pem -pubout -out config/jwt/public.pem

- name: Setup test environment
run: |
echo "DATABASE_URL=mysql://consonum:mariadb@127.0.0.1:3306/consonum_test?serverVersion=mariadb-10.11.6" >> .env.test
echo "JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem" >> .env.test
echo "JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem" >> .env.test
echo "JWT_PASSPHRASE=" >> .env.test
echo "MAILER_DSN=null://null" >> .env.test
echo "FRONTEND_URL=http://localhost:3000" >> .env.test

- name: Create database schema
run: php bin/console doctrine:schema:create --env=test

- name: Run PHPStan
run: composer phpstan

- name: Run tests with coverage
run: php bin/phpunit --coverage-text


deploy-staging:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
/phpunit.xml
/.phpunit.cache/
###< phpunit/phpunit ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
5 changes: 5 additions & 0 deletions backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"config": {
"allow-plugins": {
"php-http/discovery": true,
"phpstan/extension-installer": true,
"symfony/flex": true,
"symfony/runtime": true
},
Expand Down Expand Up @@ -65,6 +66,7 @@
"symfony/polyfill-php82": "*"
},
"scripts": {
"phpstan": "phpstan analyse src --level=5 --memory-limit=512M",
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
Expand All @@ -87,6 +89,9 @@
},
"require-dev": {
"dama/doctrine-test-bundle": "^8.6",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^11.5.55",
"symfony/browser-kit": "7.3.*",
"symfony/css-selector": "7.3.*"
Expand Down
179 changes: 177 additions & 2 deletions backend/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading