Skip to content

Commit 3ee78c0

Browse files
committed
Update docker environment and CONTRIBUTING.md
Use the docker environment in GitHub Actions too
1 parent 2711479 commit 3ee78c0

File tree

11 files changed

+97
-108
lines changed

11 files changed

+97
-108
lines changed

.github/workflows/coding-standards.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ name: "coding standards"
33
on: ["pull_request", "push"]
44

55
jobs:
6-
coding-standards:
7-
name: "coding standards"
8-
runs-on: "ubuntu-latest"
9-
steps:
10-
- name: "checkout"
11-
uses: "actions/checkout@v2"
6+
coding-standards:
7+
name: "coding standards"
8+
runs-on: "ubuntu-latest"
9+
steps:
10+
- name: "checkout"
11+
uses: "actions/checkout@v2"
1212

13-
- name: "installing PHP"
14-
uses: "shivammathur/setup-php@v2"
15-
with:
16-
php-version: "7.4"
17-
ini-values: memory_limit=-1
18-
tools: composer:v2, cs2pr, php-cs-fixer
13+
- name: "build the environment"
14+
run: "dev/bin/docker-compose build"
1915

20-
- name: "checking coding standards"
21-
run: "php-cs-fixer fix --dry-run --diff --ansi"
16+
- name: "check coding standards"
17+
run: "dev/bin/php php-cs-fixer fix --dry-run --diff --ansi"
18+
19+
- name: clear docker volumes
20+
if: ${{ always() }}
21+
run: dev/bin/docker-compose down --volumes

.github/workflows/static-analysis.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,22 @@ name: "static analysis"
33
on: ["pull_request", "push"]
44

55
jobs:
6-
static-analysis:
7-
name: "static analysis"
8-
runs-on: "ubuntu-latest"
9-
steps:
10-
- name: "checkout"
11-
uses: "actions/checkout@v2"
6+
static-analysis:
7+
name: "static analysis"
8+
runs-on: "ubuntu-latest"
9+
steps:
10+
- name: "checkout"
11+
uses: "actions/checkout@v2"
1212

13-
- name: "installing PHP"
14-
uses: "shivammathur/setup-php@v2"
15-
with:
16-
php-version: "7.4"
17-
ini-values: memory_limit=-1
18-
tools: composer:v2, cs2pr
19-
extensions: intl, bcmath, curl, openssl, mbstring, pdo, pdo_sqlite
13+
- name: "build the environment"
14+
run: "dev/bin/docker-compose build"
2015

21-
- name: "installing psalm"
22-
run: "composer require vimeo/psalm:^4.6 psalm/plugin-symfony:^2.2 --dev --no-update && composer require --no-update"
16+
- name: "install dependencies"
17+
run: "dev/bin/php composer update --prefer-stable"
2318

24-
- name: "installing dependencies"
25-
run: "composer update --no-interaction --no-progress"
19+
- name: "run static analysis"
20+
run: "dev/bin/php psalm --shepherd --stats"
2621

27-
- name: "running static analysis"
28-
run: "vendor/bin/psalm --shepherd --stats"
22+
- name: clear docker volumes
23+
if: ${{ always() }}
24+
run: dev/bin/docker-compose down --volumes

.github/workflows/unit-tests.yml

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,45 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12+
#Stable supported versions
13+
php: ['7.3', '7.4', '8.0']
14+
symfony: ['5.3.*']
15+
composer-flags: ['--prefer-stable']
16+
can-fail: [false]
1217
include:
13-
# Lowest supported stable Symfony branches
14-
- php: 7.2
15-
symfony: 5.3.*
16-
composer-flags: '--prefer-stable'
18+
# Lowest supported versions
19+
- php: '7.2'
20+
symfony: '5.3.*'
21+
composer-flags: '--prefer-stable --prefer-lowest'
1722
can-fail: false
18-
# Development Symfony branches
19-
- php: 7.3
20-
symfony: 5.4.*@dev
21-
composer-flags: '--prefer-stable' # Needed to force `lcobucci/jwt` to install a usable version
22-
can-fail: false
23-
- php: 7.4
24-
symfony: 5.4.*@dev
25-
composer-flags: ''
26-
can-fail: false
27-
- php: 8.0
28-
symfony: 5.4.*@dev
23+
# Development versions
24+
- php: '8.1-rc'
25+
symfony: '5.4.x-dev'
2926
composer-flags: ''
3027
can-fail: false
31-
- php: 8.1
32-
symfony: 6.0.*@dev
28+
- php: '8.1-rc'
29+
symfony: '6.0.x-dev'
3330
composer-flags: ''
3431
can-fail: false
3532

3633
name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"
3734

35+
env:
36+
SYMFONY_REQUIRE: ${{ matrix.symfony }}
37+
3838
steps:
39-
- name: "Checkout"
39+
- name: "checkout"
4040
uses: "actions/checkout@v2"
41-
with:
42-
fetch-depth: 2
43-
44-
- name: "Cache Composer packages"
45-
uses: "actions/cache@v2"
46-
with:
47-
path: "~/.composer/cache"
48-
key: "php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('composer.json') }}-flags-${{ matrix.composer-flags }}"
49-
restore-keys: "php-"
5041

51-
- name: "Install PHP"
52-
uses: "shivammathur/setup-php@v2"
53-
with:
54-
php-version: "${{ matrix.php }}"
55-
tools: "composer:v2,flex"
42+
- name: "build the environment"
43+
run: "dev/bin/docker-compose build --build-arg PHP_VERSION=${{ matrix.php }} php"
5644

57-
- name: "Set Composer stability"
58-
if: "matrix.symfony == '5.4.*@dev' || matrix.symfony == '6.0.*@dev'"
59-
run: "composer config minimum-stability dev"
45+
- name: "install dependencies"
46+
run: "dev/bin/php composer update --ansi ${{ matrix.composer-flags }}"
6047

61-
- name: "Install dependencies"
62-
run: "composer update ${{ matrix.composer-flags }} --prefer-dist"
63-
env:
64-
SYMFONY_REQUIRE: "${{ matrix.symfony }}"
48+
- name: "run unit tests"
49+
run: "dev/bin/php-test vendor/bin/simple-phpunit --colors=always"
6550

66-
- name: "Run PHPUnit Tests"
67-
run: "vendor/bin/simple-phpunit"
51+
- name: clear docker volumes
52+
if: ${{ always() }}
53+
run: dev/bin/docker-compose down --volumes

CONTRIBUTING.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ dev/bin/docker-compose build
2828

2929
> **NOTE:** You can target a different version of PHP during development by appending the `--build-arg PHP_VERSION=<version>` argument.
3030
31-
After that, install all the needed packages required to develop the project:
31+
After that, download all the needed packages required to develop the project:
3232

3333
```sh
34-
dev/bin/php composer install
34+
dev/bin/php composer update --prefer-stable
3535
```
3636

3737
### Debugging
3838

3939
You can run the debugger using the following command:
4040

4141
```sh
42-
dev/bin/php-debug vendor/bin/phpunit
42+
dev/bin/php-debug vendor/bin/simple-phpunit
4343
```
4444

4545
Make sure your IDE is setup properly, for more information check out the [dedicated documentation](docs/debugging.md).
@@ -49,15 +49,23 @@ Make sure your IDE is setup properly, for more information check out the [dedica
4949
This bundle enforces the PSR-2 and Symfony code standards during development by using the [PHP CS Fixer](https://cs.sensiolabs.org/) utility. Before committing any code, you can run the utility to fix any potential rule violations:
5050

5151
```sh
52-
dev/bin/php composer lint
52+
dev/bin/php php-cs-fixer fix
53+
```
54+
55+
### Running static analysis
56+
57+
You can run static anaysis of code using the following command:
58+
59+
```sh
60+
dev/bin/php psalm --shepherd --stats
5361
```
5462

5563
### Testing
5664

5765
You can run the whole test suite using the following command:
5866

5967
```sh
60-
dev/bin/php-test composer test
68+
dev/bin/php-test vendor/bin/simple-phpunit
6169
```
6270

6371
**Happy coding**!

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=7.2",
20-
"doctrine/doctrine-bundle": "^2.0",
20+
"doctrine/doctrine-bundle": "^2.0.8",
2121
"doctrine/orm": "^2.7.1",
2222
"league/oauth2-server": "^8.0",
2323
"nyholm/psr7": "^1.4",

dev/bin/php-debug

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ readonly BASE_DIR=$(cd "$(dirname "$0")"; pwd)
66

77
"${BASE_DIR}"/docker-compose run --rm --no-deps \
88
-e PHP_IDE_CONFIG=serverName="${PHP_IDE_CONFIG:-oauth}" \
9-
-e XDEBUG_REMOTE_AUTOSTART=1 \
10-
-e TIMECOP_FUNC_OVERRIDE=1 \
9+
-e XDEBUG_START_WITH_REQUEST=1 \
1110
php "$@"

dev/bin/php-test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ set -e
55
readonly BASE_DIR=$(cd "$(dirname "$0")"; pwd)
66

77
"${BASE_DIR}"/docker-compose run --rm --no-deps \
8-
-e TIMECOP_FUNC_OVERRIDE=1 \
98
php "$@"

dev/docker/Dockerfile

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
ARG PHP_VERSION=7.4
22

3-
FROM php:${PHP_VERSION}-cli-alpine3.10
3+
FROM php:${PHP_VERSION}-cli-alpine
44
LABEL maintainer="Petar Obradović <[email protected]>"
55

6-
ARG COMPOSER_VERSION=1.9.3
7-
ARG FLEX_VERSION=1.6.2
8-
ARG PHP_CS_FIXER_VERSION=2.16.2
9-
ARG XDEBUG_VERSION=2.9.2
10-
11-
ENV XDEBUG_REMOTE_AUTOSTART 0
12-
136
# This is where we're going to store all of our non-project specific binaries
147
RUN mkdir -p /app/bin
158
ENV PATH /app/bin:$PATH
@@ -24,18 +17,20 @@ RUN apk add --update --no-cache --virtual .build-deps \
2417
xml \
2518
zip \
2619
&& pecl install \
27-
xdebug-${XDEBUG_VERSION} \
20+
xdebug \
2821
&& docker-php-ext-enable \
2922
xdebug \
3023
&& apk del --purge .build-deps
3124

3225
RUN mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini
3326

27+
ENV XDEBUG_START_WITH_REQUEST 0
28+
3429
RUN echo '[xdebug]' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
35-
&& echo 'xdebug.remote_autostart = ${XDEBUG_REMOTE_AUTOSTART}' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
36-
&& echo 'xdebug.remote_enable = 1' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
37-
&& echo 'xdebug.remote_connect_back = 0' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
38-
&& echo 'xdebug.remote_host = %XDEBUG_REMOTE_HOST%' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini
30+
&& echo 'xdebug.start_with_request = ${XDEBUG_START_WITH_REQUEST}' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
31+
&& echo 'xdebug.mode = debug' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
32+
&& echo 'xdebug.discover_client_host = 0' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \
33+
&& echo 'xdebug.client_host = %XDEBUG_CLIENT_HOST%' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini
3934

4035
# Utilities needed to run this image
4136
RUN apk add --update --no-cache \
@@ -46,21 +41,26 @@ RUN apk add --update --no-cache \
4641
shadow
4742

4843
# Composer
49-
RUN curl --show-error https://getcomposer.org/installer | php -- \
50-
--install-dir=/app/bin \
51-
--filename=composer \
52-
--version=${COMPOSER_VERSION}
53-
54-
# PHP-CS-Fixer
55-
RUN curl --location --output /app/bin/php-cs-fixer --show-error \
56-
https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v${PHP_CS_FIXER_VERSION}/php-cs-fixer.phar \
57-
&& chmod a+x /app/bin/php-cs-fixer
44+
RUN curl --location --output /app/bin/composer --show-error \
45+
https://github.com/composer/composer/releases/latest/download/composer.phar \
46+
&& chmod a+x /app/bin/composer
5847

5948
# Create the user that's going to run our application
6049
RUN useradd -ms /bin/sh app
6150

51+
# Composer bin plugin
52+
RUN su-exec app composer global require --dev bamarni/composer-bin-plugin
53+
54+
# PHP-CS-Fixer
55+
RUN su-exec app composer global bin php-cs-fixer require --dev friendsofphp/php-cs-fixer \
56+
&& ln -s /home/app/.composer/vendor/bin/php-cs-fixer /app/bin/php-cs-fixer
57+
58+
# Psalm
59+
RUN su-exec app composer global bin psalm require --dev vimeo/psalm psalm/plugin-symfony \
60+
&& ln -s /home/app/.composer/vendor/bin/psalm /app/bin/psalm
61+
6262
# Enable parallel package installation for Composer
63-
RUN su-exec app composer global require symfony/flex:${FLEX_VERSION}
63+
RUN su-exec app composer global require symfony/flex
6464

6565
COPY entrypoint.sh /usr/local/bin/docker-entrypoint
6666

dev/docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ groupmod -og "${HOST_GROUP_ID}" app &> /dev/null
77

88
HOST_IP="${HOST_IP:-$(ip route | grep ^default | awk '{ print $3 }')}"
99

10-
sed -i "s/%XDEBUG_REMOTE_HOST%/$HOST_IP/" \
10+
sed -i "s/%XDEBUG_CLIENT_HOST%/$HOST_IP/" \
1111
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
1212

1313
su-exec app docker-php-entrypoint "$@"

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
HOST_USER_ID: ${HOST_USER_ID}
77
HOST_GROUP_ID: ${HOST_GROUP_ID}
88
HOST_IP: ${HOST_IP:-}
9-
SYMFONY_REQUIRE: ${SYMFONY_REQUIRE:-4.4.*}
9+
SYMFONY_REQUIRE: ${SYMFONY_REQUIRE:-5.3.*}
1010
image: league/oauth2-server-bundle
1111
volumes:
1212
- .:/app/src

0 commit comments

Comments
 (0)