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(php-tools): add phpstan and phpunit #23

Merged
merged 4 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*
!./assets
!./php-flavours.json
15 changes: 15 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@ jobs:
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' $DOCKER_IMAGE
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-${{ matrix.os_flavour }}

- name: Test the image tooling(composer)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint composer $DOCKER_IMAGE --version
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-${{ matrix.os_flavour }}

- name: Test the image tooling(phpunit)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint phpunit $DOCKER_IMAGE --version
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-${{ matrix.os_flavour }}

- name: Test the image tooling(phpstan)
run: docker run --env PS_DOMAIN='localhost:80' --entrypoint phpstan $DOCKER_IMAGE --version
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-${{ matrix.os_flavour }}
1 change: 1 addition & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ ignored:
- DL3009
- DL3018
- DL4006
- DL4001
- SC1091
15 changes: 13 additions & 2 deletions docker/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RUN apk --no-cache add -U \
nginx-mod-stream nginx-mod-stream-geoip ca-certificates \
gnu-libiconv php-common mariadb-client sudo

# Install PHP requirements
# Install PHP requirements and dev-tools
# see: https://olvlvl.com/2019-06-install-php-ext-source
RUN apk --no-cache add -U zlib-dev libjpeg-turbo-dev libpng-dev libzip-dev icu-dev libmcrypt-dev \
RUN apk --no-cache add -U composer zlib-dev libjpeg-turbo-dev libpng-dev libzip-dev icu-dev libmcrypt-dev \
&& if [ "7.1" = "$PHP_VERSION" ]; then docker-php-ext-configure gd --with-gd --with-jpeg --with-jpeg-dir --with-zlib-dir && docker-php-ext-install gd pdo_mysql zip intl mcrypt; \
else \
docker-php-ext-configure gd --with-jpeg && docker-php-ext-install gd pdo_mysql zip intl; \
Expand All @@ -41,6 +41,17 @@ RUN rm -rf /var/log/php* /etc/php*/php-fpm.conf /etc/php*/php-fpm.d \
&& chown www-data:www-data /var/log/php /var/run/php
COPY ./assets/php-fpm.conf /usr/local/etc/php-fpm.conf
COPY ./assets/nginx.conf /etc/nginx/nginx.conf
COPY ./php-flavours.json /tmp

# Install phpunit
RUN PHPUNIT_VERSION=$(jq -r '."'"${PHP_VERSION}"'".phpunit' < /tmp/php-flavours.json) \
&& wget -q -O /usr/bin/phpunit "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" \
&& chmod +x /usr/bin/phpunit

# Install phpstan
RUN PHPSTAN_VERSION=$(jq -r '."'"${PHP_VERSION}"'".phpstan' < /tmp/php-flavours.json) \
&& wget -q -O /usr/bin/phpstan "https://github.com/phpstan/phpstan/raw/${PHPSTAN_VERSION}/phpstan.phar" \
&& chmod a+x /usr/bin/phpstan

# --------------------------------
# Flashlight install and dump SQL
Expand Down
19 changes: 17 additions & 2 deletions docker/debian.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ ENV PS_FOLDER=/var/www/html
# Install base tools
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \
bash less vim git tzdata zip unzip curl jq netcat-traditional ca-certificates \
bash less vim git tzdata zip unzip curl wget jq netcat-traditional ca-certificates \
lsb-release libgnutls30 gnupg libiconv-hook1 \
nginx libnginx-mod-http-headers-more-filter libnginx-mod-http-geoip \
libnginx-mod-http-geoip libnginx-mod-stream mariadb-client sudo

# Install PHP requirements
# Install PHP requirements and dev-tools
# see: https://olvlvl.com/2019-06-install-php-ext-source
# see: https://stackoverflow.com/a/73834081
# see: https://packages.sury.org/php/dists/
Expand All @@ -33,6 +33,10 @@ RUN apt-get update \
else \
docker-php-ext-configure gd --with-jpeg && docker-php-ext-install gd pdo_mysql zip intl; \
fi;
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& mv ./composer.phar /usr/bin/composer;

# Configure php-fpm and nginx
RUN rm -rf /var/log/php* /etc/php*/php-fpm.conf /etc/php*/php-fpm.d \
Expand All @@ -43,6 +47,17 @@ RUN rm -rf /var/log/php* /etc/php*/php-fpm.conf /etc/php*/php-fpm.d \
&& chown www-data:www-data /var/log/php /var/run/php
COPY ./assets/php-fpm.conf /usr/local/etc/php-fpm.conf
COPY ./assets/nginx.conf /etc/nginx/nginx.conf
COPY ./php-flavours.json /tmp

# Install phpunit
RUN PHPUNIT_VERSION=$(jq -r '."'"${PHP_VERSION}"'".phpunit' < /tmp/php-flavours.json) \
&& wget -q -O /usr/bin/phpunit "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" \
&& chmod +x /usr/bin/phpunit

# Install phpstan
RUN PHPSTAN_VERSION=$(jq -r '."'"${PHP_VERSION}"'".phpstan' < /tmp/php-flavours.json) \
&& wget -q -O /usr/bin/phpstan "https://github.com/phpstan/phpstan/raw/${PHPSTAN_VERSION}/phpstan.phar" \
&& chmod a+x /usr/bin/phpstan

# --------------------------------
# Flashlight install and dump SQL
Expand Down
32 changes: 24 additions & 8 deletions php-flavours.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,50 @@
{
"7.1": {
"alpine": "7.1-fpm-alpine",
"debian": "7.1-fpm-buster",
"alpine": "7.1-fpm-alpine"
"phpstan": "1.4.10",
"phpunit": "7.5.20"
},
"7.2": {
"alpine": "7.2-fpm-alpine",
"debian": "7.2-fpm-buster",
"alpine": "7.2-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "8.5.34"
},
"7.3": {
"alpine": "7.3-fpm-alpine",
"debian": "7.3-fpm-buster",
"alpine": "7.3-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "9.6.13"
},
"7.4": {
"alpine": "7.4-fpm-alpine",
"debian": "7.4-fpm-buster",
"alpine": "7.4-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "9.6.13"
},
"8.0": {
"alpine": "8.0-fpm-alpine",
"debian": "8.0-fpm-bullseye",
"alpine": "8.0-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "9.6.13"
},
"8.1": {
"alpine": "8.1-fpm-alpine",
"debian": "8.1-fpm-bookworm",
"alpine": "8.1-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "10.4.2"
},
"8.2": {
"alpine": "8.2-fpm-alpine",
"debian": "8.2-fpm-bookworm",
"alpine": "8.2-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "10.4.2"
},
"8.3": {
"alpine": "8.3-fpm-alpine",
"debian": "8.3-fpm-bookworm",
"alpine": "8.3-fpm-alpine"
"phpstan": "HEAD",
"phpunit": "10.4.2"
}
}