Skip to content

Commit cb2afe7

Browse files
authored
Merge pull request #659 from itk-dev/feature/cleanup-yml-linting
Feature/cleanup yml linting
2 parents 746e214 + 9e45ec0 commit cb2afe7

28 files changed

Lines changed: 250 additions & 424 deletions

.docker/data/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Ignore everything in this directory
22
*
3-
# Except this file
3+
# Except
44
!.gitignore
5-
!Readme.md
5+
!README.md

.docker/data/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# .docker/data
2+
3+
Please map persistent volumes to this directory on the servers.
4+
5+
If a container needs to persist data between restarts you can map the relevant files in the container to
6+
`.docker/data/<container-name>`.
7+
8+
## RabbitMQ example
9+
10+
If you are using RabbitMQ running in a container as a message broker you need to configure a persistent volume for
11+
RabbitMQs data directory to avoid losing message on container restarts.
12+
x
13+
```yaml
14+
# docker-compose.server.override.yml
15+
16+
services:
17+
rabbit:
18+
image: rabbitmq:3.9-management-alpine
19+
hostname: "${COMPOSE_PROJECT_NAME}"
20+
networks:
21+
- app
22+
- frontend
23+
environment:
24+
- "RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}"
25+
- "RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD}"
26+
- "RABBITMQ_ERLANG_COOKIE=${RABBITMQ_ERLANG_COOKIE}"
27+
volumes:
28+
- ".docker/data/rabbitmq:/var/lib/rabbitmq/mnesia/"
29+
```

.docker/nginx.conf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ http {
1717
include /etc/nginx/mime.types;
1818
default_type application/octet-stream;
1919

20-
set_real_ip_from 172.16.0.0/16;
21-
real_ip_recursive on;
22-
real_ip_header X-Forwarded-For;
20+
# Note: set_real_ip_from is set in the server block
2321

2422
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" '
2523
'$status $body_bytes_sent "$http_referer" '
@@ -34,4 +32,3 @@ http {
3432

3533
include /etc/nginx/conf.d/*.conf;
3634
}
37-

.docker/templates/default.conf.template

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,30 @@ server {
66

77
client_max_body_size ${NGINX_MAX_BODY_SIZE};
88

9-
# This also needs to be set in the single server tag and not only in http.
109
set_real_ip_from 172.16.0.0/16;
10+
set_real_ip_from 192.168.39.0/24;
1111
real_ip_recursive on;
1212
real_ip_header X-Forwarded-For;
1313

14+
location = /cron-metrics {
15+
# Proxy to supercronic metrics
16+
proxy_pass http://${NGINX_CRON_METRICS}/metrics;
17+
proxy_set_header Host $host;
18+
proxy_set_header X-Real-IP $remote_addr;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
proxy_set_header X-Forwarded-Proto $scheme;
21+
}
22+
23+
# Define which paths to protect
24+
location ~ ^/(flag/flag|admin|user/login) {
25+
# Block bots on these paths only
26+
if ($http_user_agent ~* (bot|crawl|crawler|spider|scraper)) {
27+
return 403;
28+
}
29+
30+
try_files $uri /index.php?$query_string;
31+
}
32+
1433
location = /favicon.ico {
1534
log_not_found off;
1635
access_log off;
@@ -86,16 +105,6 @@ server {
86105
fastcgi_pass ${NGINX_FPM_SERVICE};
87106
}
88107

89-
# Define which paths to protect
90-
location ~ ^/(flag/flag|admin|user/login) {
91-
# Block bots on these paths only
92-
if ($http_user_agent ~* (bot|crawl|crawler|spider|scraper)) {
93-
return 403;
94-
}
95-
96-
try_files $uri /index.php?$query_string;
97-
}
98-
99108
# Enforce clean URLs
100109
#
101110
# Removes index.php from urls like www.example.com/index.php/my-page --> www.example.com/my-page

.github/workflows/changelog.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ on:
1414
jobs:
1515
changelog:
1616
runs-on: ubuntu-latest
17-
strategy:
18-
fail-fast: false
1917
steps:
2018
- name: Checkout
21-
uses: actions/checkout@v4
19+
uses: actions/checkout@v6
2220
with:
2321
fetch-depth: 2
2422

.github/workflows/composer.yaml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,54 @@
2626
name: Composer
2727

2828
env:
29-
COMPOSE_USER: root
29+
COMPOSE_USER: runner
3030

3131
on:
3232
pull_request:
33+
paths: &paths
34+
- "composer.json"
35+
- "composer.lock"
36+
- "docker-compose.yml"
3337
push:
3438
branches:
3539
- main
3640
- develop
41+
paths: *paths
3742

3843
jobs:
3944
composer-validate:
4045
runs-on: ubuntu-latest
41-
strategy:
42-
fail-fast: false
4346
steps:
44-
- uses: actions/checkout@v4
45-
- run: |
47+
- uses: actions/checkout@v6
48+
49+
- name: Create docker network
50+
run: |
4651
docker network create frontend
52+
4753
- run: |
48-
docker compose run --rm phpfpm composer validate
54+
docker compose run --rm phpfpm composer validate --strict
4955
5056
composer-normalized:
5157
runs-on: ubuntu-latest
52-
strategy:
53-
fail-fast: false
5458
steps:
55-
- uses: actions/checkout@v4
56-
- run: |
59+
- uses: actions/checkout@v6
60+
61+
- name: Create docker network
62+
run: |
5763
docker network create frontend
64+
5865
- run: |
5966
docker compose run --rm phpfpm composer install
6067
docker compose run --rm phpfpm composer normalize --dry-run
6168
6269
composer-audit:
6370
runs-on: ubuntu-latest
64-
strategy:
65-
fail-fast: false
66-
# Ignore abandoned packages until https://www.drupal.org/project/drupal/issues/3550917
6771
steps:
68-
- uses: actions/checkout@v4
69-
- run: |
72+
- uses: actions/checkout@v6
73+
74+
- name: Create docker network
75+
run: |
7076
docker network create frontend
77+
7178
- run: |
72-
docker compose run --rm phpfpm composer audit --locked --abandoned=ignore
79+
docker compose run --rm phpfpm composer audit

.github/workflows/javascript.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@ name: JavaScript
1515

1616
on:
1717
pull_request:
18+
paths: &paths
19+
- "web/themes/custom/**/js/**/*.js"
20+
- "docker-compose.yml"
1821
push:
1922
branches:
2023
- main
2124
- develop
25+
paths: *paths
2226

2327
jobs:
2428
javascript-lint:
2529
runs-on: ubuntu-latest
26-
strategy:
27-
fail-fast: false
2830
steps:
2931
- name: Checkout
30-
uses: actions/checkout@v4
32+
uses: actions/checkout@v6
3133

32-
- run: |
34+
- name: Create docker network
35+
run: |
3336
docker network create frontend
3437
3538
- run: |

.github/workflows/markdown.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,23 @@ name: Markdown
2222

2323
on:
2424
pull_request:
25+
paths: &paths
26+
- "**/*.md"
2527
push:
2628
branches:
2729
- main
2830
- develop
31+
paths: *paths
2932

3033
jobs:
3134
markdown-lint:
3235
runs-on: ubuntu-latest
33-
strategy:
34-
fail-fast: false
3536
steps:
3637
- name: Checkout
37-
uses: actions/checkout@v4
38+
uses: actions/checkout@v6
3839

39-
- run: |
40+
- name: Create docker network
41+
run: |
4042
docker network create frontend
4143
4244
- run: |

.github/workflows/php.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,32 @@
3434
name: PHP
3535

3636
env:
37-
COMPOSE_USER: root
37+
COMPOSE_USER: runner
3838

3939
on:
4040
pull_request:
41+
paths: &paths
42+
- "**/*.php"
43+
- "composer.json"
44+
- "composer.lock"
45+
- "docker-compose.yml"
4146
push:
4247
branches:
4348
- main
4449
- develop
50+
paths: *paths
4551

4652
jobs:
4753
coding-standards:
4854
name: PHP - Check Coding Standards
4955
runs-on: ubuntu-latest
5056
steps:
51-
- uses: actions/checkout@v4
52-
- run: |
57+
- uses: actions/checkout@v6
58+
59+
- name: Create docker network
60+
run: |
5361
docker network create frontend
62+
63+
- run: |
5464
docker compose run --rm phpfpm composer install
5565
docker compose run --rm phpfpm vendor/bin/phpcs

.github/workflows/site.yaml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
name: Drupal
2020

2121
env:
22-
COMPOSE_USER: root
22+
COMPOSE_USER: runner
2323

2424
on:
2525
pull_request:
@@ -33,11 +33,14 @@ jobs:
3333
name: Check that site can be installed
3434
runs-on: ubuntu-latest
3535
steps:
36-
- uses: actions/checkout@v4
36+
- uses: actions/checkout@v6
3737

38-
- name: Start docker and install dependencies
38+
- name: Create docker network
3939
run: |
4040
docker network create frontend
41+
42+
- name: Start docker and install dependencies
43+
run: |
4144
docker compose pull
4245
docker compose up --detach
4346
@@ -64,21 +67,41 @@ jobs:
6467
# Check updating site only on pull request.
6568
if: github.event_name == 'pull_request'
6669
name: Check that site can be updated
70+
71+
# This job checks that the Drupal site can be upgraded without issues.
72+
#
73+
# We do this by
74+
#
75+
# 1. Checking out the base branch ("github.base_ref") and installing the
76+
# site from scratch (using the exact same steps as the "install-site"
77+
# job)
78+
# 2. Checking out the updated code and updating the site from the previous
79+
# installation
80+
#
81+
# Notice that step 2 is NOT run with the code in our new branch, but with
82+
# the updated code merged on top of the target branch
83+
# (cf.https://github.com/actions/checkout/issues/881). This makes sure that
84+
# we can actually update the site after merging with the base branch.
85+
#
86+
# In some cases we run into a situation where the base site (step 1) cannot
87+
# be installed, e.g. if this is a new project or we're making changes that
88+
# require manual steps on the upgrade path, and then this jobs will fail. In
89+
# that case we should note this in the pull request description and document
90+
# the steps needed to complete the upgrade path.
91+
6792
runs-on: ubuntu-latest
68-
env:
69-
# Force docker compose to run with the new project name
70-
# @todo Remove in the future when base branch uses the new project name
71-
COMPOSE_PROJECT_NAME: deltag
72-
COMPOSE_DOMAIN: deltag.local.itkdev.dk
7393
steps:
7494
# Install site from our base ref
75-
- uses: actions/checkout@v4
95+
- uses: actions/checkout@v6
7696
with:
7797
ref: ${{ github.base_ref }}
7898

79-
- name: Start docker and install dependencies
99+
- name: Create docker network
80100
run: |
81101
docker network create frontend
102+
103+
- name: Start docker and install dependencies
104+
run: |
82105
docker compose pull
83106
docker compose up --detach
84107
@@ -106,17 +129,15 @@ jobs:
106129
sudo chown -Rv $USER:$USER vendor/ web/ private-files/ || true
107130
sudo chmod -Rv a+w web/sites/default || true
108131
109-
# Install site with our current ref
110-
- uses: actions/checkout@v4
132+
# Update site using our updated code.
133+
- uses: actions/checkout@v6
111134
with:
112-
ref: ${{ github.head_ref }}
113135
# Keep our local settings (cf.
114136
# https://github.com/actions/checkout?tab=readme-ov-file#usage)
115137
clean: false
116138

117139
- name: Start docker and install dependencies
118140
run: |
119-
docker network create frontend || true
120141
docker compose pull
121142
docker compose up --detach
122143

0 commit comments

Comments
 (0)