Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 0.3.x dev - Update dependencies and PHP to 8.1 #47

Merged
merged 58 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8407ea5
feat: upgrade to php 8.1
Benoit382 Aug 11, 2022
56e2cf7
fix: ci
Benoit382 Aug 11, 2022
a53d4b5
[OT] close file handle when exception occurs at image upload
epalmans Aug 17, 2022
917770c
bump version dependencies for log and cache libs
epalmans Aug 18, 2022
2dcfde9
BREAKING CHANGE: require PHP8 as minimum
epalmans Aug 18, 2022
b4ffcc4
CI to only test on PHP 8.0/8.1. Drop for 7.x
epalmans Aug 18, 2022
a8d249e
extra check on file handle being closed post imageupload
epalmans Aug 18, 2022
0de2be9
[CI/phpStan] don't report unmatched ignoreErrors
epalmans Aug 18, 2022
8e5d666
bumped versions phpstan
epalmans Aug 18, 2022
07c090b
removed unused (written once) geography variabel
epalmans Aug 18, 2022
a01085a
applied fixes for phpstan errors
epalmans Aug 18, 2022
f11b8df
implemented iterator's typehints
epalmans Aug 18, 2022
a4caede
implemented iterator's typehints p.2
epalmans Aug 18, 2022
d865850
removed monolog dep.
epalmans Aug 22, 2022
66d4a0e
Merge remote-tracking branch 'Benoit/go-to-php8-new-start' into 0.3.x…
Dwarfex Feb 16, 2023
c28f4b1
add relevant changes from PR #32
Dwarfex Feb 16, 2023
cbc0ff6
update security checker
Dwarfex Feb 16, 2023
ba173dc
drop 8.0, add 8.2
Dwarfex Feb 16, 2023
7e05c26
remove unused ignore error
Dwarfex Feb 16, 2023
5548353
add docker setup for running local tests
Dwarfex Feb 16, 2023
1732e64
add command to run php-cs-fixer
Dwarfex Feb 16, 2023
a75e792
dont move bin file from vendor
Dwarfex Feb 16, 2023
f2bcd8f
add concurrency check to stop wastin minutes
Dwarfex Feb 16, 2023
05091eb
move to better place
Dwarfex Feb 16, 2023
1eddc8d
also use matrix to determine concurrency
Dwarfex Feb 16, 2023
5a37b3d
make sonarcloud happy
Dwarfex Feb 16, 2023
bb999e0
update me again
Dwarfex Feb 16, 2023
e6c59e4
update me again
Dwarfex Feb 16, 2023
25f32ec
Code smell fixes
Dwarfex Feb 16, 2023
373b5db
Format code with php-cs-fixer
deepsource-autofix[bot] Feb 16, 2023
c2ea727
change cache key generation
Dwarfex Feb 16, 2023
f721d14
Merge remote-tracking branch 'origin/0.3.x-dev' into 0.3.x-dev
Dwarfex Feb 16, 2023
b0528de
Format code with php-cs-fixer
deepsource-autofix[bot] Feb 16, 2023
7cc7443
change cache key hashing for sonarcloud -ffs
Dwarfex Feb 16, 2023
740992c
Merge remote-tracking branch 'origin/0.3.x-dev' into 0.3.x-dev
Dwarfex Feb 16, 2023
2b26cd3
sonarcloud
Dwarfex Feb 16, 2023
88a650b
sonarcloud - code smells
Dwarfex Feb 16, 2023
1777ede
sonarcloud - code smells
Dwarfex Feb 16, 2023
b0667e2
chore: restrict permissions for directories created during tests
epalmans Feb 26, 2023
671d58f
chore: gh actions version bumps (esp. because of upcoming node12 depr…
epalmans Feb 26, 2023
181061b
chore: ignore php version on cs-fixer gh actions run
epalmans Feb 26, 2023
c0a3658
chore: include php gd extension for gh action
epalmans Feb 26, 2023
f4f861e
chore: gh actions version bumps (esp. because of upcoming node12 depr…
epalmans Feb 26, 2023
c7f9901
chore: temp file path on gh action
epalmans Feb 26, 2023
970d04e
test: assert generated test image exists
epalmans Feb 26, 2023
9bb52c7
test: remove image upload test to live endpoint
epalmans Feb 27, 2023
a6a1b22
test: comment-out helper function used on image upload test
epalmans Feb 27, 2023
2df15cf
test: remove commented-out codeblocks
epalmans Feb 27, 2023
701b4a2
test: remove unused imports
epalmans Feb 27, 2023
f79d64c
Format code with php-cs-fixer
deepsource-autofix[bot] Feb 27, 2023
ef4eb31
Merge branch '0.3.x-dev' of github.com:openfoodfacts/openfoodfacts-ph…
epalmans Feb 27, 2023
9ad7e29
Update src/Collection.php
epalmans May 1, 2024
e685b27
cs fixer
epalmans May 1, 2024
bad4730
Skipping test due to intermittent issues at calling API
epalmans May 1, 2024
63391e4
have phpstan ignore change introduced in bad4730
epalmans May 1, 2024
54ac0c4
sonarcloud suggestions
epalmans May 1, 2024
2fc2248
sonarcloud suggestions #2
epalmans May 1, 2024
34bab53
Release-As: 0.3.0
epalmans May 1, 2024
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Docker
USER_ID=1000
GROUP_ID=1000
# For Composer (installing packages - optional)
#GITHUB_TOKEN="${GITHUB_TOKEN}"
2 changes: 1 addition & 1 deletion .github/workflows/auto-assign-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.4.0
- uses: toshimaru/auto-author-assign@v1.6.2
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ jobs:
tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
name: Tests - PHP ${{ matrix.php }}
php: ['8.1', '8.2']
name: Tests - PHP ${{ matrix.php }}
concurrency:
group: ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}-${{ matrix.php }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-db
with:
path: ~/.symfony/cache
Expand All @@ -23,23 +25,25 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
- name: Report PHP version
run: php -v
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ matrix.php }}-composer-
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --no-suggest
- name: check dependancy
uses: symfonycorp/security-checker-action@v2
- name: check dependency
uses: symfonycorp/security-checker-action@v5
- name: Check quality code
env:
PHP_CS_FIXER_IGNORE_ENV: 1
run: vendor/bin/php-cs-fixer fix --ansi --dry-run --using-cache=no --verbose
- name: Execute phpstan
run: vendor/bin/phpstan
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Example user template template
### Example user template
/build/
/bin/

# IntelliJ project files
.idea
Expand All @@ -12,6 +13,8 @@ composer.phar
/vendor/
/log/
/tests/tmp/*
.env
/xdebug_profile/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file https://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
19 changes: 13 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(['src', 'tests'])
$config = new PhpCsFixer\Config();
$finder = $config->getFinder();
$finder
->in(['src','tests'])
;

$config = new PhpCsFixer\Config();
return $config->setRules([
return $config
->setRules([
'@PSR12' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'single_quote' => true,
'blank_line_before_statement' => true,
'no_spaces_around_offset' => true,
'no_unused_imports' => true,
'ternary_operator_spaces' => true,
])
->setFinder($finder)
;
->setUsingCache(false)
;
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
5. Create a new Pull Request
6. Help this Project move forward :)
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

php-setup:
test -e .env || cp .env.example .env
docker compose down
docker compose rm
docker compose build
docker compose up -d --force-recreate
make composer install

install:
docker compose exec php-fpm bash -c 'XDEBUG_MODE=off composer install'

fix:
docker compose exec php-fpm bash -c 'XDEBUG_MODE=off ./vendor/bin/php-cs-fixer fix'

test:
docker compose exec php-fpm bash -c 'XDEBUG_MODE=off ./vendor/bin/phpunit'

composer:
docker compose exec php-fpm bash -c "XDEBUG_MODE=off composer $(filter-out $@,$(MAKECMDGOALS))"
28 changes: 16 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
{
"name": "Roberto Moreno",
"email": "[email protected]",
"homepage": "http://www.rampmaster.org",
"homepage": "https://rampmaster.org/",
"role": "Wrapper Developer"
},
{
"name": "Colin Benoit",
"homepage": "https://github.com/Benoit382",
"role": "PHP Developer"
}
],
"require": {
"php": "^7.2|^8.0",
"php": "^8.1",
"ext-json": "*",
"ext-curl": "*",
"guzzlehttp/guzzle": "^6.3|^7.0",
"psr/log": "^1.0",
"psr/simple-cache": "^1.0"
"ext-gd": "*",
"guzzlehttp/guzzle": "^7.4",
"psr/log": "^3.0",
"psr/simple-cache": "^3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -35,12 +41,10 @@
}
},
"require-dev": {
"ext-gd": "*",
"monolog/monolog": "^1.23",
"symfony/cache": "^4.3",
"phpunit/phpunit": "^8.5|^9.5",
"phpstan/phpstan": "^0.12.99",
"phpstan/phpstan-phpunit": "^0.12.22",
"friendsofphp/php-cs-fixer": "^3.1"
"symfony/cache": "^6.1.3",
"phpunit/phpunit": "^9.5.21",
"phpstan/phpstan": "^1.8.2",
"phpstan/phpstan-phpunit": "^1.1.1",
"friendsofphp/php-cs-fixer": "^3.9.5"
}
}
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.7'

services:
php-fpm:
container_name: openfoodfacts-php
build:
context: .
dockerfile: ./docker/php/Dockerfile
args:
GITHUB_TOKEN: $GITHUB_TOKEN
GROUP_ID: $GROUP_ID
USER_ID: $USER_ID
environment:
XDEBUG_CONFIG: client_host=host.docker.internal
image: somecoding/crawler-php-fpm
volumes:
- .:/var/www/html:delegated
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini
- ./docker/php/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./docker/php/fpm_additional.conf:/usr/local/etc/php-fpm.d/zzzz-fpm_additional.conf # zzzz- to be loaded last: overwrites all before
- ./xdebug_profile:/tmp/profile:delegated
networks:
- default
extra_hosts:
- "host.docker.internal:host-gateway"
50 changes: 50 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# syntax=docker/dockerfile:experimental
FROM composer:2 AS COMPOSER
ENV COMPOSER_HOME=/usr/config/composer
ENV GITHUB_TOKEN=""
RUN if [[ -z "$GITHUB_TOKEN" ]] ; then echo Github Token not provided ; else composer config -g github-oauth.github.com $GITHUB_TOKEN; fi

FROM php:8.1-fpm

ENV COMPOSER_HOME=/usr/config/composer
ARG USER_ID
ARG GROUP_ID
RUN usermod -u $USER_ID www-data && groupmod -g $GROUP_ID www-data

# Install php-src extensions
RUN apt-get -qq update && apt-get -qq --no-install-recommends install \
libzip-dev \
unzip \
libpng-dev \
libjpeg-dev \
mariadb-client \
git > /dev/null && \
pecl install xdebug-3.1.6 > /dev/null && \
docker-php-ext-enable xdebug > /dev/null && \
pecl install -o -f redis-5.3.4 > /dev/null && \
docker-php-ext-install \
-j$(nproc) \
zip \
gd \
bcmath \
pdo_mysql > /dev/null && \
rm -rf /tmp/pear > /dev/null && \
rm -rf /var/lib/apt/lists/*
RUN mkdir /tmp/profile; chmod 755 /tmp/profile

# Install composer and dependencies
COPY --chown=root:root --from=COMPOSER --chmod=755 /usr/bin/composer /usr/bin/composer


ENV GITHUB_TOKEN=""
###COPY --chown=www-data:www-data --from=COMPOSER /usr/config/composer /usr/config/composer
#Re-enable aboce COPY when Token is set

# Make sure composer can checkout github
RUN mkdir -p /var/www/.ssh/ && \
touch /var/www/.ssh/known_hosts && \
ssh-keyscan github.com >> /var/www/.ssh/known_hosts

WORKDIR /var/www/html

USER www-data
6 changes: 6 additions & 0 deletions docker/php/docker-php-ext-xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
zend_extension=xdebug

xdebug.mode=debug,profile
xdebug.client_port= 9000
xdebug.start_with_request=yes
xdebug.output_dir = /tmp/profile
7 changes: 7 additions & 0 deletions docker/php/fpm_additional.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[www]
pm = dynamic
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 250
4 changes: 4 additions & 0 deletions docker/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
max_execution_time=600
memory_limit=-1
session.cookie_httponly = 1; // Make sonarcloud happy - docker is for local dev only
session.cookie_secure = 1;
2 changes: 1 addition & 1 deletion examples/01-basic_api_usage/cached_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Symfony\Component\Cache\Psr16Cache;

include '../../vendor/autoload.php';
$logger = new \Monolog\Logger('test');
$logger = new \Psr\Log\NullLogger;
$httpClient = new \GuzzleHttp\Client();
// the PSR-6 cache object that you want to use (you might also use a PSR-16 Interface Object directly)
$psr6Cache = new FilesystemAdapter();
Expand Down
8 changes: 5 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ includes:
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: max
level: 8
checkMissingIterableValueType: false
ignoreErrors:
- '/.*is not subtype of Throwable/'
paths:
- src
- tests
ignoreErrors:
-
message: "#^Unreachable statement - code above always terminates.$#"
path: tests/ApiFoodTest.php
Loading
Loading