Skip to content

chore(dependencies): update for symfony #22

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

Merged
merged 3 commits into from
Mar 14, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vendor
*.cache
composer.lock
tools/php-cs-fixer/composer.lock
.git
.idea
Dockerfile
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli-alpine AS dependencies
ARG PHP_CS_FIXER
RUN apk add --update --no-cache zip unzip php-zip
COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN addgroup -S php && adduser -S php -G php \
&& mkdir -p /usr/src/xml-lint \
&& chown php:php -R /usr/src/xml-lint
WORKDIR /usr/src/xml-lint
COPY --chown=php:php . ./
USER php
RUN composer install --prefer-dist -o -a -n --no-progress \
&& \
if [[ -n "${PHP_CS_FIXER}" ]]; then \
composer install --working-dir=tools/php-cs-fixer --prefer-dist -o -a -n --no-progress; \
fi

FROM php:${PHP_VERSION}-cli-alpine AS test
ARG PHP_CS_FIXER
RUN addgroup -S php && adduser -S php -G php \
&& mkdir -p /usr/src/xml-lint \
&& chown php:php -R /usr/src/xml-lint

WORKDIR /usr/src/xml-lint
COPY --from=dependencies --chown=php:php /usr/src/xml-lint ./
USER php

RUN if [[ -n "${PHP_CS_FIXER}" ]]; then \
php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run -v; \
fi
RUN php vendor/bin/phpunit
RUN php vendor/bin/behat

FROM dependencies AS build_production
WORKDIR /usr/src/xml-lint

RUN rm -rf tools/ tests/ \
&& composer install --prefer-dist -o -a -n --no-progress --no-dev

FROM php:${PHP_VERSION}-cli-alpine AS production
WORKDIR /usr/src/xml-lint
COPY --from=build_production /usr/src/xml-lint ./
RUN ln -s /usr/src/xml-lint/bin/xmllint /usr/bin/xml-lint
WORKDIR /usr/src
ENTRYPOINT ["php", "/usr/src/xml-lint/bin/xmllint"]
CMD ["--help"]
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@ php vendor/bin/behat
Using docker:

```shell
# Install dependencies
docker run -it --rm -v "$PWD":/usr/src/xml-lint -w /usr/src/xml-lint -v ${COMPOSER_HOME:-$HOME/.composer}:/tmp --user $(id -u):$(id -g) composer install --ignore-platform-reqs --no-scripts
docker run -it --rm -v "$PWD":/usr/src/xml-lint -w /usr/src/xml-lint/tools/php-cs-fixer -v ${COMPOSER_HOME:-$HOME/.composer}:/tmp --user $(id -u):$(id -g) composer install --ignore-platform-reqs --no-scripts
# Example
docker build -t xml-lint:php-8.1 --build-arg=PHP_VERSION="8.1" .

# Run code style check
docker run -it --rm -v "$PWD":/usr/src/xml-lint -w /usr/src/xml-lint php:7.4-cli php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run -v
# PHP_VERSION: choose between 7.4, 8.0 and 8.1
docker build -t xml-lint:php-7.4 --build-arg=PHP_VERSION="7.4" .
docker build -t xml-lint:php-8.0 --build-arg=PHP_VERSION="8.0" .
docker build -t xml-lint:php-8.1 --build-arg=PHP_VERSION="8.1" .

# Run tests
docker run -it --rm -v "$PWD":/usr/src/xml-lint -w /usr/src/xml-lint --user $(id -u):$(id -g) php:7.4-cli php vendor/bin/phpunit
docker run -it --rm -v "$PWD":/usr/src/xml-lint -w /usr/src/xml-lint --user $(id -u):$(id -g) php:7.4-cli php vendor/bin/behat
# Run with code style check
docker build -t xml-lint:php-7.4 --build-arg=PHP_VERSION="7.4" --build-arg=PHP_CS_FIXER=true .

# Use this image to run xml-lint:
cd tests/functional/_testdata
docker run -it --rm -v "$PWD":/var/src -w /var/src xml-lint:php-7.4 -r -v -- ./
```


Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
],
"bin": ["bin/xmllint"],
"require": {
"php": "7.3.*|7.4.*|8.0.*",
"symfony/console": "3.4.*|4.4.*|5.*",
"symfony/finder": "3.4.*|4.4.*|5.*",
"php": "7.4.*|8.0.*|8.1.*",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you wouldn't want to just do:

"php": "^7.4 || ^8.0",

This eases out maintenance and future compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion, but it's a deliberate choice. I really prefer to run the test suite against any new version before releasing it.

"symfony/console": "4.4.*|5.3.*|5.4.*|6.*",
"symfony/finder": "4.4.*|5.3.*|5.4.*|6.*",
"ext-libxml": "*",
"ext-dom": "*"
},
Expand Down
Loading