Skip to content

Commit 2870526

Browse files
committed
Added docker compose setup
1 parent d4abb30 commit 2870526

File tree

4 files changed

+47
-76
lines changed

4 files changed

+47
-76
lines changed

.github/workflows/pr.yml

Lines changed: 13 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23,97 +23,41 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
php-versions: [ '8.3' ]
2726
dependency-version: [ prefer-lowest, prefer-stable ]
2827
steps:
2928
- uses: actions/checkout@v4
30-
- name: Setup PHP, with composer and extensions
31-
uses: shivammathur/setup-php@v2
32-
with:
33-
php-version: ${{ matrix.php-versions }}
34-
extensions: json
35-
coverage: none
36-
tools: composer:v2
37-
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
38-
- name: Get composer cache directory
39-
id: composer-cache
40-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
41-
- name: Cache dependencies
42-
uses: actions/cache@v4
43-
with:
44-
path: ${{ steps.composer-cache.outputs.dir }}
45-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46-
restore-keys: ${{ runner.os }}-composer-
4729
- name: Validate composer files
4830
run: |
49-
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
50-
# The --strict flag on validate has been removed due to the package drupal/config_entity_revisions 2.0.x-dev
51-
# being considered a version cf. https://getcomposer.org/doc/articles/versions.md#branches
52-
composer validate composer.json
53-
# Check that dependencies resolve.
54-
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
31+
# Note that we don't use the --strict flag on validate due to the
32+
# package drupal/config_entity_revisions 2.0.x-dev being considered a
33+
# version cf.
34+
# https://getcomposer.org/doc/articles/versions.md#branches
35+
docker compose run --rm php composer validate composer.json
5536
- name: Check that composer file is normalized
5637
run: |
57-
composer normalize --dry-run
38+
docker compose run --rm php composer install
39+
docker compose run --rm php composer normalize --dry-run
40+
- name: Check that dependencies resolve.
41+
run: |
42+
docker compose run --rm php composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
5843
5944
php-coding-standards:
6045
name: PHP coding standards
6146
runs-on: ubuntu-latest
62-
strategy:
63-
matrix:
64-
php-versions: [ '8.3' ]
6547
steps:
6648
- uses: actions/checkout@v4
67-
- name: Setup PHP, with composer and extensions
68-
uses: shivammathur/setup-php@v2
69-
with:
70-
php-version: ${{ matrix.php-versions }}
71-
extensions: json
72-
coverage: none
73-
tools: composer:v2
74-
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
75-
- name: Get composer cache directory
76-
id: composer-cache
77-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
78-
- name: Cache dependencies
79-
uses: actions/cache@v4
80-
with:
81-
path: ${{ steps.composer-cache.outputs.dir }}
82-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
83-
restore-keys: ${{ runner.os }}-composer-
8449
- name: Install Dependencies
8550
run: |
86-
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
87-
composer install --no-interaction --no-progress
51+
docker compose run --rm php composer install
8852
- name: PHPCS
8953
run: |
90-
composer coding-standards-check/phpcs
54+
docker compose run --rm php composer coding-standards-check/phpcs
9155
9256
php-code-analysis:
9357
name: PHP code analysis
9458
runs-on: ubuntu-latest
95-
strategy:
96-
matrix:
97-
php-versions: [ '8.3' ]
9859
steps:
9960
- uses: actions/checkout@v4
100-
- name: Setup PHP, with composer and extensions
101-
uses: shivammathur/setup-php@v2
102-
with:
103-
php-version: ${{ matrix.php-versions }}
104-
extensions: json
105-
coverage: none
106-
tools: composer:v2
107-
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
108-
- name: Get composer cache directory
109-
id: composer-cache
110-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
111-
- name: Cache dependencies
112-
uses: actions/cache@v4
113-
with:
114-
path: ${{ steps.composer-cache.outputs.dir }}
115-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
116-
restore-keys: ${{ runner.os }}-composer-
11761
- name: Code analysis
11862
run: |
11963
./scripts/code-analysis
@@ -127,4 +71,4 @@ jobs:
12771

12872
- name: Coding standards
12973
run: |
130-
docker run --rm --volume $PWD:/md itkdev/markdownlint markdownlint '**/*.md'
74+
docker compose run --rm markdownlint markdownlint '**/*.md'

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,27 @@ run the checks locally.
121121
### PHP
122122

123123
```sh
124-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer install
124+
docker compose pull
125+
docker compose run --rm php composer install
125126
# Fix (some) coding standards issues.
126-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-apply
127-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-check
127+
docker compose run --rm php composer coding-standards-apply
128+
docker compose run --rm php composer coding-standards-check
128129
```
129130

131+
> [!TIP]
132+
> If the `composer install` commands fails with
133+
>
134+
> > Unable to install module simplesamlphp/simplesamlphp-assets-base, package name must be on the form "VENDOR/simplesamlphp-module-MODULENAME".
135+
>
136+
> you can remove the `vendor` folder and rerun the `composer install` command (cf.
137+
> <https://www.drupal.org/project/simplesamlphp_auth/issues/3350773>).
138+
130139
### Markdown
131140

132141
```sh
133-
docker pull peterdavehello/markdownlint
134-
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md' --fix
135-
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md'
142+
docker compose pull
143+
docker compose run --rm markdownlint markdownlint '**/*.md' --fix
144+
docker compose run --rm markdownlint markdownlint '**/*.md'
136145
```
137146

138147
## Code analysis
@@ -143,7 +152,7 @@ Running statis code analysis on a standalone Drupal module is a bit tricky, so w
143152
analysis:
144153

145154
```shell
146-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm ./scripts/code-analysis
155+
docker compose run --rm php ./scripts/code-analysis
147156
```
148157

149158
**Note**: Currently the code analysis is only run on the `os2forms_digital_post` sub-module (cf. [`phpstan.neon`](./phpstan.neon)).

compose.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://hub.docker.com/r/ddev/ddev-php-base
2+
3+
services:
4+
php:
5+
image: ddev/ddev-php-base
6+
profiles:
7+
- dev
8+
working_dir: /app
9+
volumes:
10+
- ./:/app
11+
12+
markdownlint:
13+
image: itkdev/markdownlint
14+
# The default working dir is `/md`
15+
working_dir: /app
16+
volumes:
17+
- ./:/app

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"mglaman/composer-drupal-lenient": true,
9999
"phpstan/extension-installer": true,
100100
"simplesamlphp/composer-module-installer": true,
101+
"simplesamlphp/composer-xmlprovider-installer": true,
101102
"vaimo/composer-patches": true,
102103
"zaporylie/composer-drupal-optimizations": true
103104
},

0 commit comments

Comments
 (0)