Skip to content
Closed
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
131 changes: 131 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: CI

on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]

jobs:
php-tests:
name: PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['8.1', '8.2', '8.3', '8.4']
symfony: ['^7.0', '^8.0']
exclude:
# PHP 8.1 doesn't support Symfony 8.0
- php: '8.1'
symfony: '^8.0'

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, pdo, pdo_mysql, pdo_pgsql, intl, mbstring
coverage: xdebug
tools: composer:v2

- name: Validate composer.json
run: composer validate --strict

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-

- name: Install dependencies
run: |
composer require --no-update "symfony/framework-bundle:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/translation:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/form:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/validator:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/twig-bundle:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/asset:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/security-csrf:${{ matrix.symfony }}" --dev
composer require --no-update "symfony/yaml:${{ matrix.symfony }}" --dev
composer install --prefer-dist --no-progress

- name: Run PHPUnit tests
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: php-${{ matrix.php }}-symfony-${{ matrix.symfony }}
name: php-${{ matrix.php }}-symfony-${{ matrix.symfony }}
continue-on-error: true

frontend:
name: Frontend Build
runs-on: ubuntu-latest

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

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Type check
run: pnpm run type-check

- name: Build assets
run: pnpm run build

- name: Check build output
run: |
test -f Resources/public/js/translation.js || exit 1
echo "βœ… Build successful"

code-style:
name: Code Style
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer:v2

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

- name: Check code style (PHP-CS-Fixer if available)
run: |
if [ -f .php_cs ] || [ -f .php-cs-fixer.php ]; then
vendor/bin/php-cs-fixer fix --dry-run --diff || true
else
echo "No PHP-CS-Fixer config found, skipping"
fi
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:
release:
name: Create Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: Build frontend assets
run: |
pnpm install --frozen-lockfile
pnpm run build

- name: Create release archive
run: |
mkdir -p release
# Exclude development files
tar --exclude='.git' \
--exclude='node_modules' \
--exclude='.vite' \
--exclude='assets' \
--exclude='.github' \
--exclude='Tests' \
--exclude='.php_cs' \
--exclude='phpunit.xml.dist' \
--exclude='vite.config.ts' \
--exclude='tsconfig.json' \
--exclude='package.json' \
--exclude='pnpm-lock.yaml' \
--exclude='.npmrc' \
-czf release/lexik-translation-bundle-${{ steps.version.outputs.version }}.tar.gz .

- name: Extract CHANGELOG
id: changelog
run: |
if [ -f CHANGELOG.md ]; then
# Extract version section from CHANGELOG
VERSION=${{ steps.version.outputs.version }}
awk "/^## \[$VERSION\]/,/^## \[/" CHANGELOG.md | sed '$d' > release-notes.md
elif [ -f docs/CHANGELOG.md ]; then
VERSION=${{ steps.version.outputs.version }}
awk "/^## \[$VERSION\]/,/^## \[/" docs/CHANGELOG.md | sed '$d' > release-notes.md
else
echo "## Release ${{ steps.version.outputs.version }}" > release-notes.md
echo "" >> release-notes.md
echo "See commit history for changes." >> release-notes.md
fi

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: release/*.tar.gz
body_path: release-notes.md
draft: false
prerelease: ${{ contains(github.ref, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# Stage 1: Build frontend assets
FROM node:20-alpine AS frontend-builder

# Install pnpm
RUN npm install -g pnpm

WORKDIR /app

# Copy package files
COPY package.json pnpm-lock.yaml* ./

# Install dependencies
RUN pnpm install --frozen-lockfile

# Copy source files
COPY assets/ ./assets/
COPY vite.config.ts tsconfig.json ./

# Build assets
RUN pnpm run build

# Stage 2: PHP environment for tests
FROM php:8.4-cli-bullseye

ENV COMPOSER_ALLOW_SUPERUSER=1
Expand All @@ -21,8 +43,13 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /app

# Copy all files
COPY . .

# Copy compiled assets from frontend-builder stage
COPY --from=frontend-builder /app/Resources/public/ ./Resources/public/

# Instalar dependencias PHP
RUN composer install --prefer-dist --no-progress

CMD ["composer", "test"]
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
lexik_translation:
build: .
Expand Down
Loading