Skip to content

Commit

Permalink
maint/php84 (#1)
Browse files Browse the repository at this point in the history
* maint/php84 Updated `.github/workflows/test.yml`.

* maint/php84 Updated `.gitignore`.

* maint/php84 Updated `SECURITY.md`.

* maint/php84 Updated `composer.json`.

* maint/php84 Updated `docker-compose.yml`.

* maint/php84 Created `docker/php84/Dockerfile`.

* maint/php84 Created `docker/php84/php.ini`.

* maint/php84 Updated `src/Omdb.php`.

* maint/php84 Updated `test.sh`.

---------

Co-authored-by: david_smith <david_smith@sweetwater.com>
  • Loading branch information
zero-to-prod and david_smith authored Jan 5, 2025
1 parent e365b1e commit 677e5b1
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
php-version: [ php83, php82, php81 ]
php-version: [ php84, php83, php82, php81 ]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ composer.lock
.php-cs-fixer.cache
/tests/generated/
/.phpunit.cache/
/vendor-php81/
/vendor-php82/
/vendor-php83/
/vendor-php84/
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| 8.1.x | :white_check_mark: |
| 8.2.x | :white_check_mark: |
| 8.3.x | :white_check_mark: |
| 8.4.x | :white_check_mark: |

## Reporting a Vulnerability

Expand Down
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"omdb"
],
"homepage": "https://github.com/zero-to-prod/omdb",
"support": {
"email": "dave0016@gmail.com",
"issues": "https://github.com/zero-to-prod/omdb/issues",
"source": "https://github.com/zero-to-prod/data-model",
"docs": "https://zero-to-prod.github.io/omdb/",
"security": "https://github.com/zero-to-prod/omdb/blob/main/SECURITY.md"
},
"license": "MIT",
"readme": "./README.md",
"authors": [
Expand Down
38 changes: 36 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
target: base
volumes:
- ./:/app
- ./vendor-php81:/app/vendor

php81debug:
build:
Expand All @@ -13,20 +14,23 @@ services:
volumes:
- ./:/app
- ./docker/php81:/usr/local/etc/php
- ./vendor-php81:/app/vendor

php81composer:
build:
context: docker/php81
target: composer
volumes:
- ./:/app
- ./vendor-php81:/app/vendor

php82:
build:
context: docker/php82
target: base
volumes:
- ./:/app
- ./vendor-php82:/app/vendor

php82debug:
build:
Expand All @@ -35,32 +39,62 @@ services:
volumes:
- ./:/app
- ./docker/php82:/usr/local/etc/php
- ./vendor-php82:/app/vendor

php82composer:
build:
context: docker/php82
target: composer
volumes:
- ./:/app
- ./vendor-php82:/app/vendor

php83:
build:
context: docker/php83
target: base
volumes:
- ./:/app
- ./vendor-php83:/app/vendor

php83debug:
build:
context: docker/php83
target: debug
volumes:
- ./:/app
- ./docker/php82:/usr/local/etc/php
- ./docker/php83:/usr/local/etc/php
- ./vendor-php83:/app/vendor

php83composer:
build:
context: docker/php83
target: composer
volumes:
- ./:/app
- ./:/app
- ./vendor-php83:/app/vendor

php84:
build:
context: docker/php84
target: base
volumes:
- ./:/app
- ./vendor-php84:/app/vendor

php84debug:
build:
context: docker/php84
target: debug
volumes:
- ./:/app
- ./docker/php84:/usr/local/etc/php
- ./vendor-php84:/app/vendor

php84composer:
build:
context: docker/php84
target: composer
volumes:
- ./:/app
- ./vendor-php84:/app/vendor
23 changes: 23 additions & 0 deletions docker/php84/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:8.4-cli AS base

WORKDIR /app

RUN apt-get update && apt-get install -y \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*

FROM base AS composer

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

FROM base AS debug

RUN pecl channel-update pecl.php.net && \
pecl install xdebug && \
docker-php-ext-enable xdebug && \
echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

WORKDIR /app

CMD ["bash"]
2 changes: 2 additions & 0 deletions docker/php84/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
zend_extension = xdebug.so
xdebug.mode = coverage
20 changes: 10 additions & 10 deletions src/Omdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ public function poster(string $imdbID): string
* @see https://github.com/zero-to-prod/omdb-api
*/
public function byIdOrTitle(
string $title = null,
string $imdb_id = null,
Type $Type = null,
int $year = null,
bool $full_plot = false,
?string $title = null,
?string $imdb_id = null,
?Type $Type = null,
?int $year = null,
?bool $full_plot = false,
mixed $callback = null,
string $version = null,
?string $version = null,
array $CURLOPT = [CURLOPT_TIMEOUT => 10]
): Error|Title {
$response = $this->OmdbApi->byIdOrTitle(
Expand Down Expand Up @@ -115,11 +115,11 @@ public function byIdOrTitle(
*/
public function search(
string $title,
Type $Type = null,
int $year = null,
int $page = 1,
?Type $Type = null,
?int $year = null,
?int $page = 1,
mixed $callback = null,
string $version = null,
?string $version = null,
array $CURLOPT = [CURLOPT_TIMEOUT => 10]

): Error|SearchResults {
Expand Down
17 changes: 4 additions & 13 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
# run-tests.sh
#!/bin/bash
set -e

php_versions=("php83" "php82" "php81")
php_versions=("php84" "php83" "php82" "php81")

for version in "${php_versions[@]}"; do
if [ -f composer.lock ]; then
echo "removing composer.lock"
rm composer.lock
fi

docker compose run --rm "$version"composer composer install
docker compose run --rm "${version}composer" composer update --no-cache

echo "Running tests on $version..."
if ! docker compose run --rm "$version" vendor/bin/phpunit; then
echo "Tests failed on $version."
exit 1
fi
done

echo "All tests passed!"
done

0 comments on commit 677e5b1

Please sign in to comment.