Skip to content

Commit

Permalink
Test against PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 16, 2024
1 parent 0288676 commit 0c1b1f2
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.1"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.4"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -26,7 +27,7 @@ jobs:
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand All @@ -39,6 +40,8 @@ jobs:

- name: Run PHPUnit
run: make test-coveralls
env:
PHPUNIT_VERSION: "${{ matrix.php-version == '8.4' && '10' || '07' }}"

- name: Upload code coverage
if: ${{ matrix.php-version == '7.1' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
build
composer.lock
vendor
34 changes: 21 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
FROM php:7.1-cli-buster
ARG PHP_TAG=7.1-cli-buster
FROM php:${PHP_TAG}

RUN docker-php-ext-enable opcache && \
docker-php-source delete
RUN <<-EOF
docker-php-ext-enable opcache
EOF

RUN echo '\
display_errors=On\n\
error_reporting=E_ALL\n\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini
RUN <<-EOF
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
display_errors=On
error_reporting=E_ALL
date.timezone=UTC
SHELL
EOF

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc
RUN <<-EOF
apt-get update
apt-get install unzip
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet
mv composer.phar /usr/local/bin/composer
cat <<-SHELL >> /root/.bashrc
export PATH="$HOME/.composer/vendor/bin:$PATH"
SHELL
EOF

RUN composer global require squizlabs/php_codesniffer
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# customization

PACKAGE_NAME = icanboogie/inflector
PHPUNIT = vendor/bin/phpunit

# do not edit the following lines
Expand All @@ -13,24 +12,32 @@ test-dependencies: vendor

.PHONY: test
test: test-dependencies
@$(PHPUNIT)
@XDEBUG_MODE=none $(PHPUNIT) --configuration=phpunit10.xml

.PHONY: test-coverage
test-coverage: test-dependencies
@mkdir -p build/coverage
@$(PHPUNIT) --coverage-html build/coverage
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage

.PHONY: test-coveralls
test-coveralls: test-dependencies
@mkdir -p build/logs
@$(PHPUNIT) --coverage-clover build/logs/clover.xml
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-clover build/logs/clover.xml

.PHONY: test-container
test-container:
@docker-compose run --rm app bash
test-container: test-container-71

.PHONY: test-container-71
test-container-71:
@-docker-compose run --rm app71 bash
@docker-compose down -v

.PHONY: test-container-84
test-container-84:
@-docker-compose run --rm app84 bash
@docker-compose down -v

.PHONY: lint
lint:
@phpcs
@vendor/bin/phpstan
@XDEBUG_MODE=off phpcs -s
@XDEBUG_MODE=off vendor/bin/phpstan
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"ext-mbstring": "*"
},
"require-dev": {
"icanboogie/common": "^2.0",
"phpstan/phpstan": "^0.12.92",
"phpunit/phpunit": "^7.5"
"icanboogie/common": "^2.1",
"phpstan/phpstan": "^0.12.100|^2.0",
"phpunit/phpunit": "^7.5.20|^10.0"
},
"conflict": {
"icanboogie/common": "<2.0"
Expand Down
21 changes: 17 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
---
version: "3.2"
services:
app:
build: .
app71:
build:
context: .
args:
PHP_TAG: "7.1-cli-buster"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-inflector'
volumes:
PHPUNIT_VERSION: "07"
volumes: &vol
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app84:
build:
context: .
args:
PHP_TAG: "8.4.0RC4-cli-bookworm"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-inflector'
PHPUNIT_VERSION: "10"
volumes: *vol
working_dir: /app
1 change: 0 additions & 1 deletion lib/InflectionsNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@

class InflectionsNotFound extends LogicException
{

}
2 changes: 1 addition & 1 deletion lib/Inflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function get(string $locale = self::DEFAULT_LOCALE): self
*/
private $inflections;

public function __construct(Inflections $inflections = null)
public function __construct(?Inflections $inflections = null)
{
$this->inflections = $inflections ?? new Inflections();
}
Expand Down
3 changes: 2 additions & 1 deletion phpunit.xml → phpunit07.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
verbose="true"
colors="true">
colors="true"
>
<testsuites>
<testsuite name="icanboogie/inflector">
<directory>./tests</directory>
Expand Down
23 changes: 23 additions & 0 deletions phpunit10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
bootstrap="tests/bootstrap.php"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
executionOrder="depends,defects"
>
<testsuites>
<testsuite name="icanboogie/inflector">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>lib</directory>
</include>
</source>
</phpunit>

0 comments on commit 0c1b1f2

Please sign in to comment.