Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

### Testing
- [ ] Unit tests added / updated
- [ ] New/changed code is covered by tests — SonarCloud Quality Gate (coverage on new code) passes on the `sonarcloud` CI job

### Security & Ops
- [ ] No sensitive data or secrets introduced
Expand Down
73 changes: 71 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,82 @@ jobs:
with:
symfony-versions: '["7.3"]'

# -----------------------------------------------------------------------
# COVERAGE — generates a Clover coverage report (PCOV) for SonarCloud to
# ingest. Kept separate from the reusable sylius_phpunit matrix (which
# runs with coverage: none) so coverage generation stays this repo's
# own concern, same as payplug/unified-plugin-core's ci.yml.
# -----------------------------------------------------------------------
coverage:
name: Coverage
if: github.base_ref == 'develop'
runs-on: ubuntu-latest
env:
APP_ENV: test
services:
mariadb:
image: 'mariadb:10.4.11'
ports:
- '3306:3306'
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
options: '--health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3'
steps:
-
uses: actions/checkout@v4
-
name: 'Setup PHP 8.2'
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
ini-values: date.timezone=UTC
extensions: intl
tools: symfony
coverage: pcov
-
name: 'Setup Node 20.x'
uses: actions/setup-node@v4
with:
node-version: '20.x'
-
name: 'Composer - Get Cache Directory'
id: composer-cache
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
-
name: 'Composer - Set cache'
uses: actions/cache@v4
with:
path: '${{ steps.composer-cache.outputs.dir }}'
key: 'php-8.2-sylius-2.1.0-symfony-7.3-coverage-composer-${{ hashFiles(''**/composer.json'') }}'
restore-keys: 'php-8.2-sylius-2.1.0-symfony-7.3-coverage-composer-'
-
name: 'Composer - Github Auth'
run: 'composer config -g github-oauth.github.com ${{ github.token }}'
-
name: 'Install Sylius-Standard and Plugin'
run: 'make install -e SYLIUS_VERSION=2.1.0 SYMFONY_VERSION=7.3'
id: end-of-setup-sylius
-
name: 'Run tests with coverage'
run: 'composer test-coverage'
if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
-
name: 'Upload coverage report'
uses: actions/upload-artifact@v4
with:
name: clover-coverage
path: build/logs/clover.xml
retention-days: 1

sonarcloud:
if: always() && !failure() && !cancelled() && github.base_ref == 'develop'
needs: [sylius-matrix]
uses: payplug/template-ci/.github/workflows/sonarcloud.yml@main
needs: [sylius-matrix, coverage]
uses: payplug/template-ci/.github/workflows/sonarcloud-coverage.yml@main
with:
project-name: 'github-payplug-payplug-syliuspayplugplugin'
src-folder: 'src/'
coverage-report-artifact: 'clover-coverage'
enforce-quality-gate: true
secrets:
sonar-orga: ${{ secrets.SONAR_ORGA }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ CLAUDE.md
.claude
.review
.phpunit.result.cache
docs/
build/
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM composer:2 AS composer

FROM php:8.2-cli

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
unzip \
libicu-dev \
libzip-dev \
libonig-dev \
libxml2-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libsodium-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
intl \
gd \
sodium \
pdo_mysql \
mbstring \
xml \
dom \
simplexml \
xmlwriter \
zip \
&& pecl install pcov \
&& docker-php-ext-enable pcov \
&& rm -rf /var/lib/apt/lists/*

COPY --from=composer /usr/bin/composer /usr/local/bin/composer

RUN useradd --create-home --uid 1000 appuser

WORKDIR /app

USER appuser
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ SYLIUS_VERSION=2.1.0
SYMFONY_VERSION=6.4
PLUGIN_NAME=payplug/sylius-payplug-plugin

# Coverage runs inside Docker (PHP 8.2 + PCOV) instead of the host PHP, since the host's default
# `php`/`composer` may resolve to an unrelated version with no coverage driver installed. Assumes
# `vendor/` (and the Sylius test-application) is already installed on the host via `make install`.
IMAGE_DEV := sylius-payplug-plugin-dev
DOCKER_RUN := docker run --rm -v $(CURDIR):/app -w /app -u "$$(id -u):$$(id -g)" -e COMPOSER_HOME=/tmp/composer $(IMAGE_DEV)

###
### DEVELOPMENT
### ¯¯¯¯¯¯¯¯¯¯¯
Expand All @@ -23,6 +29,14 @@ phpunit: ## Run PHPUnit tests
./vendor/bin/phpunit
.PHONY: phpunit

build-dev: ## Build the Docker image used to run coverage
docker build -t $(IMAGE_DEV) .
.PHONY: build-dev

coverage: build-dev ## Run PHPUnit tests with a Clover coverage report (build/logs/clover.xml), via Docker
$(DOCKER_RUN) composer test-coverage
.PHONY: coverage

###
### OTHER
### ¯¯¯¯¯¯
Expand All @@ -36,8 +50,6 @@ install-sylius:
${COMPOSER} require --dev sylius/test-application:"^${SYLIUS_VERSION}@alpha" -n -W # TODO: Remove alpha when stable
${COMPOSER} test-application:install



behat-configure: ## Configure Behat
(cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml)
(cd ${TEST_DIRECTORY} && sed -i "s#vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml#vendor/${PLUGIN_NAME}/tests/Behat/Resources/suites.yml#g" behat.yml)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=github-payplug-payplug-syliuspayplugplugin&metric=alert_status&token=af29f9f3fbb3a74caff4e4a4d168bddab858f4dc)](https://sonarcloud.io/summary/new_code?id=github-payplug-payplug-syliuspayplugplugin)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=github-payplug-payplug-syliuspayplugplugin&metric=duplicated_lines_density&token=af29f9f3fbb3a74caff4e4a4d168bddab858f4dc)](https://sonarcloud.io/summary/new_code?id=github-payplug-payplug-syliuspayplugplugin)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=github-payplug-payplug-syliuspayplugplugin&metric=code_smells&token=af29f9f3fbb3a74caff4e4a4d168bddab858f4dc)](https://sonarcloud.io/summary/new_code?id=github-payplug-payplug-syliuspayplugplugin)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=github-payplug-payplug-syliuspayplugplugin&metric=coverage&token=af29f9f3fbb3a74caff4e4a4d168bddab858f4dc)](https://sonarcloud.io/summary/new_code?id=github-payplug-payplug-syliuspayplugplugin)
[![Version](https://img.shields.io/packagist/v/payplug/sylius-payplug-plugin.svg)](https://packagist.org/packages/payplug/sylius-payplug-plugin)
[![Total Downloads](https://poser.pugx.org/payplug/sylius-payplug-plugin/downloads)](https://packagist.org/packages/payplug/sylius-payplug-plugin)

Expand Down
7 changes: 7 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true
}
},
"hosted-fields": {
"enabled": true,
"fetch": "lazy",
"autoimport": {
"@payplug/sylius-payplug-plugin/shop/dist/payment/hosted-fields.css": true
}
},
"oney-payment": {
"enabled": true,
"fetch": "lazy"
Expand Down
9 changes: 9 additions & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
"@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true
}
},
"hosted-fields": {
"main": "shop/controllers/hosted-fields_controller.js",
"webpackMode": "lazy",
"fetch": "lazy",
"enabled": true,
"autoimport": {
"@payplug/sylius-payplug-plugin/shop/dist/payment/hosted-fields.css": true
}
},
"oney-payment": {
"main": "shop/controllers/oney-payment_controller.js",
"webpackMode": "lazy",
Expand Down
Loading
Loading