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
51 changes: 51 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=dev_secret_123
###< symfony/framework-bundle ###

###> app ###
MOCK_USER_ID=a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
###< app ###

###> symfony/routing ###
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
DEFAULT_URI=http://localhost
###< symfony/routing ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="postgresql://user:password@db:5432/seatlock?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###

###> symfony/messenger ###
# Default Outbox (Doctrine)
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
# RabbitMQ (Async)
RABBITMQ_DSN=amqp://user:password@rabbitmq:5672/%2f/messages
###< symfony/messenger ###
47 changes: 43 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI Pipeline

env:
IMAGE_REPO: ghcr.io/alisolphp/seatlock

on:
push:
branches: [ main, develop ]
Expand All @@ -9,16 +12,46 @@ on:
jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
env:
POSTGRES_DB: seatlock
POSTGRES_USER: user
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U user -d seatlock"
--health-interval 10s
--health-timeout 5s
--health-retries 5

env:
DATABASE_URL: "postgresql://user:password@127.0.0.1:5432/seatlock?serverVersion=16&charset=utf8"

steps:
- uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: xdebug

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Prepare test database
run: |
php bin/console doctrine:database:drop --if-exists --force
php bin/console doctrine:database:create
php bin/console doctrine:migrations:migrate --no-interaction
php bin/console doctrine:fixtures:load --no-interaction

- name: Run tests with coverage
run: ./vendor/bin/pest --coverage --min=90
run: XDEBUG_MODE=coverage ./vendor/bin/pest --coverage --min=90

analyse:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -73,20 +106,26 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
docker build -t ghcr.io/${{ github.repository }}:latest -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
docker push ghcr.io/${{ github.repository }} --all-tags
docker build -t $IMAGE_REPO:latest -t $IMAGE_REPO:${{ github.sha }} .
docker push $IMAGE_REPO --all-tags

security-scan:
runs-on: ubuntu-latest
needs: build-and-push
permissions:
contents: read
packages: read
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: ghcr.io/${{ github.repository }}:latest
image-ref: ${{ env.IMAGE_REPO }}:latest
format: table
exit-code: '1'
ignore-unfixed: true
vuln-type: os,library
severity: CRITICAL,HIGH
env:
TRIVY_USERNAME: ${{ github.actor }}
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/public/build/

### Docker ###
.env
docker-compose.override.yml

### IDEs ###
Expand Down Expand Up @@ -45,3 +44,4 @@ docker-compose.override.yml
###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
/node_modules/
20 changes: 20 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @type {import('@commitlint/types').UserConfig} */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'docs',
'style',
'refactor',
'perf',
'test',
'chore',
],
],
},
};
Loading