Skip to content

Commit 27d7031

Browse files
committed
4850: Updated docker compose setup
1 parent ec6a2c6 commit 27d7031

20 files changed

Lines changed: 603 additions & 26 deletions

.github/workflows/changelog.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/changelog.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Changelog
6+
###
7+
### Checks that changelog has been updated
8+
9+
name: Changelog
10+
11+
on:
12+
pull_request:
13+
14+
jobs:
15+
changelog:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Git fetch
26+
run: git fetch
27+
28+
- name: Check that changelog has been updated.
29+
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0

.github/workflows/composer.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/composer.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Composer
6+
###
7+
### Validates composer.json and checks that it's normalized.
8+
###
9+
### #### Assumptions
10+
###
11+
### 1. A docker compose service named `phpfpm` can be run and `composer` can be
12+
### run inside the `phpfpm` service.
13+
### 2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize)
14+
### is a dev requirement in `composer.json`:
15+
###
16+
### ``` shell
17+
### docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize
18+
### ```
19+
###
20+
### Normalize `composer.json` by running
21+
###
22+
### ``` shell
23+
### docker compose run --rm phpfpm composer normalize
24+
### ```
25+
26+
name: Composer
27+
28+
env:
29+
COMPOSE_USER: root
30+
31+
on:
32+
pull_request:
33+
push:
34+
branches:
35+
- main
36+
- develop
37+
38+
jobs:
39+
composer-validate:
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
steps:
44+
- uses: actions/checkout@v4
45+
- run: |
46+
docker network create frontend
47+
docker compose run --rm phpfpm composer validate --strict
48+
49+
composer-normalized:
50+
runs-on: ubuntu-latest
51+
strategy:
52+
fail-fast: false
53+
steps:
54+
- uses: actions/checkout@v4
55+
- run: |
56+
docker network create frontend
57+
docker compose run --rm phpfpm composer install
58+
docker compose run --rm phpfpm composer normalize --dry-run
59+
60+
composer-audit:
61+
runs-on: ubuntu-latest
62+
strategy:
63+
fail-fast: false
64+
steps:
65+
- uses: actions/checkout@v4
66+
- run: |
67+
docker network create frontend
68+
docker compose run --rm phpfpm composer audit

.github/workflows/javascript.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/drupal/javascript.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Drupal JavaScript (and TypeScript)
6+
###
7+
### Validates JavaScript files.
8+
###
9+
### #### Assumptions
10+
###
11+
### 1. A docker compose service named `prettier` for running
12+
### [Prettier](https://prettier.io/) exists.
13+
14+
name: JavaScript
15+
16+
on:
17+
pull_request:
18+
push:
19+
branches:
20+
- main
21+
- develop
22+
23+
jobs:
24+
javascript-lint:
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: false
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- run: |
33+
docker network create frontend
34+
35+
- run: |
36+
docker compose run --rm prettier 'web/themes/custom/**/js/**/*.js' --check

.github/workflows/markdown.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/markdown.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Markdown
6+
###
7+
### Lints Markdown files (`**/*.md`) in the project.
8+
###
9+
### [markdownlint-cli configuration
10+
### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration),
11+
### `.markdownlint.jsonc` and `.markdownlintignore`, control what is actually
12+
### linted and how.
13+
###
14+
### #### Assumptions
15+
###
16+
### 1. A docker compose service named `markdownlint` for running `markdownlint`
17+
### (from
18+
### [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli))
19+
### exists.
20+
21+
name: Markdown
22+
23+
on:
24+
pull_request:
25+
push:
26+
branches:
27+
- main
28+
- develop
29+
30+
jobs:
31+
markdown-lint:
32+
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- run: |
40+
docker network create frontend
41+
42+
- run: |
43+
docker compose run --rm markdownlint markdownlint '**/*.md'

.github/workflows/php.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/drupal/php.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Drupal PHP
6+
###
7+
### Checks that PHP code adheres to the [Drupal coding
8+
### standards](https://www.drupal.org/docs/develop/standards).
9+
###
10+
### #### Assumptions
11+
###
12+
### 1. A docker compose service named `phpfpm` can be run and `composer` can be
13+
### run inside the `phpfpm` service.
14+
### 2. [drupal/coder](https://www.drupal.org/project/coder) is a dev requirement
15+
### in `composer.json`:
16+
###
17+
### ``` shell
18+
### docker compose run --rm phpfpm composer require --dev drupal/coder
19+
### ```
20+
###
21+
### Clean up and check code by running
22+
###
23+
### ``` shell
24+
### docker compose run --rm phpfpm vendor/bin/phpcbf
25+
### docker compose run --rm phpfpm vendor/bin/phpcs
26+
### ```
27+
###
28+
### > [!NOTE]
29+
### > The template adds `.phpcs.xml.dist` as [a configuration file for
30+
### > PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file)
31+
### > and this makes it possible to override the actual configuration used in a
32+
### > project by adding a more important configuration file, e.g. `.phpcs.xml`.
33+
34+
name: PHP
35+
36+
env:
37+
COMPOSE_USER: root
38+
39+
on:
40+
pull_request:
41+
push:
42+
branches:
43+
- main
44+
- develop
45+
46+
jobs:
47+
coding-standards:
48+
name: PHP - Check Coding Standards
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- run: |
53+
docker network create frontend
54+
docker compose run --rm phpfpm composer install
55+
docker compose run --rm phpfpm vendor/bin/phpcs

.github/workflows/site.yaml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/drupal/site.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Drupal
6+
###
7+
### Checks that site can be installed and can be updated (from base branch on
8+
### pull request).
9+
###
10+
### #### Assumptions
11+
###
12+
### 1. A docker compose service named `phpfpm` can be run and `composer` can be
13+
### run inside the `phpfpm` service.
14+
### 2. The docker setup contains a database container and other the dependent
15+
### services and the default settings match connection credentials for these
16+
### services.
17+
### 3. The Drupal site can be installed from existing config.
18+
19+
name: Drupal
20+
21+
env:
22+
COMPOSE_USER: root
23+
24+
on:
25+
pull_request:
26+
push:
27+
branches:
28+
- main
29+
- develop
30+
31+
jobs:
32+
install-site:
33+
name: Check that site can be installed
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Start docker and install dependencies
39+
run: |
40+
docker network create frontend
41+
docker compose pull
42+
docker compose up --detach
43+
44+
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
45+
docker compose exec phpfpm composer install --no-interaction
46+
47+
- name: Install site
48+
run: |
49+
# Add some local settings.
50+
cat > web/sites/default/settings.local.php <<'EOF'
51+
<?php
52+
53+
$settings['hash_salt'] = '${{ github.head_ref }}';
54+
EOF
55+
56+
# Install the site from config
57+
docker compose exec phpfpm vendor/bin/drush site:install --existing-config --yes
58+
59+
- name: Show site URL
60+
run: |
61+
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)
62+
63+
update-site:
64+
# Check updating site only on pull request.
65+
if: github.event_name == 'pull_request'
66+
name: Check that site can be updated
67+
runs-on: ubuntu-latest
68+
steps:
69+
# Install site from our base ref
70+
- uses: actions/checkout@v4
71+
with:
72+
ref: ${{ github.base_ref }}
73+
74+
- name: Start docker and install dependencies
75+
run: |
76+
docker network create frontend
77+
docker compose pull
78+
docker compose up --detach
79+
80+
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
81+
docker compose exec phpfpm composer install --no-interaction
82+
83+
- name: Install site
84+
run: |
85+
# Add some local settings.
86+
cat > web/sites/default/settings.local.php <<'EOF'
87+
<?php
88+
89+
$settings['hash_salt'] = '${{ github.head_ref }}';
90+
EOF
91+
92+
# Install the site from config
93+
docker compose exec phpfpm vendor/bin/drush site:install --existing-config --yes
94+
95+
- name: Show site URL
96+
run: |
97+
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)
98+
99+
- name: Clean up root stuff
100+
run: |
101+
sudo chown -Rv $USER:$USER vendor/ web/ private-files/ || true
102+
sudo chmod -Rv a+w web/sites/default || true
103+
104+
# Install site with our current ref
105+
- uses: actions/checkout@v4
106+
with:
107+
ref: ${{ github.head_ref }}
108+
# Keep our local settings (cf.
109+
# https://github.com/actions/checkout?tab=readme-ov-file#usage)
110+
clean: false
111+
112+
- name: Start docker and install dependencies
113+
run: |
114+
docker network create frontend || true
115+
docker compose pull
116+
docker compose up --detach
117+
118+
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
119+
docker compose exec phpfpm composer install --no-interaction
120+
121+
- name: Update site
122+
run: |
123+
docker compose exec phpfpm vendor/bin/drush deploy --yes
124+
125+
- name: Show site URL
126+
run: |
127+
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)

0 commit comments

Comments
 (0)