Skip to content

Commit

Permalink
Update to php8.1 symfony 6.4 (#141)
Browse files Browse the repository at this point in the history
* change branch name

Signed-off-by: Xheni Myrtaj <[email protected]>

* Disable REST API by default

Signed-off-by: Xheni Myrtaj <[email protected]>

* Change path

Signed-off-by: Xheni Myrtaj <[email protected]>

* Remove prefix

Signed-off-by: Xheni Myrtaj <[email protected]>

* [FEATURE] Get the number of subscribers of list and added tests (#116)

Closes #115

* [BUGFIX] Fix the expected number in an integration test (#119)

Signed-off-by: Xheni Myrtaj <[email protected]>

* [CLEANUP] Fix a warning with newer PHPMD versions (#125)

* update php dependencies

* update to pass building

* ISSUE-337: update package versions

* ISSUE-337: use local

* ISSUE-337: symfony 6.4

* ISSUE-337: test fix

* ISSUE-337: fix the rest of tests

* GitHub actions (#132)

* added github workflow(action) for build and test ci tasks

Signed-off-by: fenn-cs <[email protected]>

* updated php_codesniffer dep

Signed-off-by: fenn-cs <[email protected]>

* removed travis ci config file

Signed-off-by: fenn-cs <[email protected]>

(cherry picked from commit 70d45ad)

* ISSUE-337: add pipeline

* ISSUE-337: fix phpstan

* ISSUE-337: fix phpstmd

* ISSUE-337: openapi docs

* ISSUE-337: move to bundle file

* ISSUE-337: changelog

* ISSUE-337: update core

* ISSUE-337: fix phpstan

* ISSUE-337: fix phpcs

* ISSUE-337: force push

* ISSUE-337: name fix

---------

Signed-off-by: Xheni Myrtaj <[email protected]>
Co-authored-by: Xheni Myrtaj <[email protected]>
Co-authored-by: Oliver Klee <[email protected]>
Co-authored-by: Michiel Dethmers <[email protected]>
Co-authored-by: Tatevik <[email protected]>
Co-authored-by: F. E Noel Nfebe <[email protected]>
  • Loading branch information
6 people authored Jan 15, 2025
1 parent 5307afd commit 789315a
Show file tree
Hide file tree
Showing 30 changed files with 1,451 additions and 1,254 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0']
# dependencies: ['latest', 'oldest'] # Only latest/upwards dependencies supported currently.
php-versions: ['8.1']
dependencies: ['latest', 'oldest']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -48,18 +48,15 @@ jobs:
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
# - name: Install the lowest dependencies
# run: composer update --with-dependencies --prefer-stable --prefer-dist --prefer-lowest
# if: ${{ matrix.dependencies }} == "latest"
- name: Install dependencies
run: composer update --with-dependencies --prefer-stable --prefer-dist
if: ${{ matrix.dependencies }} == "latest"
- name: Install current dependencies from composer.lock
run: composer install
continue-on-error: ${{matrix.php-versions == '8.0' }} # Temporal until full support for php8 === [temp-php8]
- name: Set up database schema
run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} ${{ env.DB_DATABASE }} < vendor/phplist/core/resources/Database/Schema.sql
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Validating composer.json
run: composer validate --no-check-all --no-check-lock --strict;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Linting all php files
run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l;
- name: Running unit tests
Expand All @@ -76,10 +73,7 @@ jobs:
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running static analysis
run: vendor/bin/phpstan analyse -l 5 src/ tests/;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running PHPMD
run: vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running PHP_CodeSniffer
run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
132 changes: 76 additions & 56 deletions .github/workflows/restapi-docs.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,93 @@
name: Publish REST API Docs
on: [push, pull_request]
name: Publish REST API Docs
on:
push:
branches:
- main
pull_request:

jobs:
make-restapi-docs:
name: Checkout phpList rest-api and generate docs specification (OpenAPI latest-restapi.json)
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup PHP with Composer and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
extensions: mbstring, dom, fileinfo, mysql
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2

- name: Cache Composer Dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install current dependencies from composer.lock
run: composer install
- name: Generate OpenAPI Specification JSON for REST API
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: composer install --no-interaction --prefer-dist

- name: Generate OpenAPI Specification JSON
run: vendor/bin/openapi -o docs/latest-restapi.json --format json src
- name: Upload REST API(latest-restapi.json) Spec
uses: actions/upload-artifact@v2

- name: Upload REST API Specification
uses: actions/upload-artifact@v3
with:
name: restapi-json
path: docs/latest-restapi.json

deploy-docs:
name: Deploy REST API specification.
name: Deploy REST API Specification
runs-on: ubuntu-20.04
needs: make-restapi-docs
steps:
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install openapi-checker
run: npm install -g openapi-checker
- name: Checkout phplist/restapi-docs
uses: actions/checkout@v2
with:
repository: phpList/restapi-docs
fetch-depth: 0
token: ${{ secrets.PUSH_REST_API_DOCS }}
- name: Restore REST API Spec
uses: actions/download-artifact@v2
with:
name: restapi-json
- name: Validate latest-restapi.json
run: openapi-checker latest-restapi.json
- name: Get difference between latest-restapi.json and restapi.json
# `|| true` to supress exit code 1 [git diff exits with 1 when there is a difference between the two files and 0 for the reverse.
run: git diff --no-index --output=restapi-diff.txt latest-restapi.json restapi.json || true
- name: Verify difference latest-restapi.json and restapi.json
id: allow-deploy
run: |
if [ -s restapi-diff.txt ]; then echo "Updates made to restapi.json deployment proceeding."; echo '::set-output name=DEPLOY::true'; else echo "No updates made to restapi.json deployment would be skipped."; echo '::set-output name=DEPLOY::false'; fi
- name: Commit and changes and deply
if: ${{ steps.allow-deploy.outputs.DEPLOY == 'true' }}
run: |
mv latest-restapi.json restapi.json
git config user.name "github-actions"
git config user.email "[email protected]"
git add restapi.json
git commit -s -m "phplist/rest-api docs deployment `date`"
git push
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install openapi-checker
run: npm install -g swagger-cli

- name: Checkout REST API Docs Repository
uses: actions/checkout@v3
with:
repository: phpList/restapi-docs
fetch-depth: 0
token: ${{ secrets.PUSH_REST_API_DOCS }}

- name: Download Generated REST API Specification
uses: actions/download-artifact@v3
with:
name: restapi-json
path: docs

- name: Validate OpenAPI Specification
run: swagger-cli validate docs/latest-restapi.json

- name: Compare Specifications
run: git diff --no-index --output=restapi-diff.txt docs/latest-restapi.json restapi.json || true

- name: Check Differences and Decide Deployment
id: allow-deploy
run: |
if [ -s restapi-diff.txt ]; then
echo "Updates detected in the REST API specification. Proceeding with deployment.";
echo 'DEPLOY=true' >> $GITHUB_ENV;
else
echo "No changes detected in the REST API specification. Skipping deployment.";
echo 'DEPLOY=false' >> $GITHUB_ENV;
fi
- name: Commit and Deploy Updates
if: env.DEPLOY == 'true'
run: |
mv docs/latest-restapi.json docs/restapi.json
git config user.name "github-actions"
git config user.email "[email protected]"
git add docs/restapi.json
git commit -m "Update REST API documentation `date`"
git push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
/public/
/var/
/vendor/
.phpunit.result.cache
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Fixed

## 5.0.0-alpha1

### Changed
- php version 8.1

## 4.0.0-alpha2

### Added
Expand Down
67 changes: 16 additions & 51 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@
"source": "https://github.com/phpList/rest-api"
},
"require": {
"php": "^7.2|^8.0",
"phplist/core": "^v4.0.0-alpha5",
"friendsofsymfony/rest-bundle": "^2.8.6",
"sensio/framework-extra-bundle": "5.1.0",
"zircote/swagger-php": "^3.1"
"php": "^8.1",
"phplist/core": "dev-ISSUE-337",
"friendsofsymfony/rest-bundle": "*",
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
"zircote/swagger-php": "^4.11"
},
"require-dev": {
"phpunit/phpunit": "^6.5.14",
"phpunit/phpunit-mock-objects": "^5.0.6",
"phpunit/dbunit": "^3.0.3",
"guzzlehttp/guzzle": "^6.5.5",
"squizlabs/php_codesniffer": "^3.5.8",
"phpstan/phpstan": "^0.7.0",
"nette/caching": "^3.1.0",
"nikic/php-parser": "^3.1.0",
"phpmd/phpmd": "^2.9.1"
"phpunit/phpunit": "^10.0",
"guzzlehttp/guzzle": "^6.3.0",
"squizlabs/php_codesniffer": "^3.2.0",
"phpstan/phpstan": "^1.10",
"nette/caching": "^3.0.0",
"nikic/php-parser": "^4.19.1",
"phpmd/phpmd": "^2.6.0",
"doctrine/instantiator": "^2.0."
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -86,7 +86,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
"dev-ISSUE-337": "5.0.x-dev"
},
"symfony-app-dir": "bin",
"symfony-bin-dir": "bin",
Expand All @@ -101,44 +101,9 @@
"routes": {
"rest-api": {
"resource": "@PhpListRestBundle/Controller/",
"type": "rest",
"type": "attribute",
"prefix": "/api/v2"
}
},
"configuration": {
"fos_rest": {
"routing_loader": {
"include_format": false
},
"format_listener": {
"enabled": true,
"rules": [
{
"path": "^/api/v2/",
"fallback_format": "json"
},
{
"path": "^/",
"fallback_format": "html"
}
]
},
"view": {
"view_response_listener": {
"enabled": true
}

},
"exception": {
"enabled": true,
"messages": {
"Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException": true
}
},
"service": {
"view_handler": "my.secure_view_handler"
}
}
}
}
}
Expand Down
31 changes: 27 additions & 4 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
services:
Psr\Container\ContainerInterface:
alias: 'service_container'

PhpList\RestBundle\Controller\:
resource: '../src/Controller'
public: true
autowire: true
tags: ['controller.service_arguments']

# Symfony\Component\Serializer\SerializerInterface:
# autowire: true
# autoconfigure: true

my.secure_handler:
class: \PhpList\RestBundle\ViewHandler\SecuredViewHandler
class: \PhpList\RestBundle\ViewHandler\SecuredViewHandler

my.secure_view_handler:
parent: fos_rest.view_handler.default
calls:
- ['registerHandler', [ 'json', ['@my.secure_handler', 'createResponse'] ] ]
parent: fos_rest.view_handler.default
calls:
- ['registerHandler', [ 'json', ['@my.secure_handler', 'createResponse'] ] ]

PhpList\Core\Security\Authentication:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Repository\Messaging\SubscriberListRepository:
autowire: true
autoconfigure: true

PhpList\RestBundle\EventListener\ExceptionListener:
tags:
- { name: kernel.event_listener, event: kernel.exception }

PhpList\RestBundle\EventListener\ResponseListener:
tags:
- { name: kernel.event_listener, event: kernel.response }
Loading

0 comments on commit 789315a

Please sign in to comment.