-
Notifications
You must be signed in to change notification settings - Fork 4
105 lines (84 loc) · 3.24 KB
/
drupal.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Drupal
on:
pull_request:
push:
branches:
# Push events on main branch
- main
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * *'
workflow_dispatch:
env:
DRUPAL_DB_HOST: 127.0.0.1
DRUPAL_DB_PORT: 3306
DRUPAL_INSTALL_PROFILE: minimal
SIMPLETEST_DB: mysql://drupal:[email protected]:3306/drupal
SIMPLETEST_BASE_URL: http://127.0.0.1:8080
BROWSERTEST_OUTPUT_DIRECTORY: 'public/sites/simpletest'
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
services:
db:
# See https://hub.docker.com/r/druidfi/mysql
image: druidfi/mysql:8.0-drupal-lts
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2
- name: Validate composer.json
run: composer validate
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
#key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress
- name: Lint
run: |
vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer,vendor/slevomat/coding-standard
vendor/bin/phpcs -i
vendor/bin/phpcs --standard=Drupal,DrupalPractice -n public/modules/custom
vendor/bin/phpcs --standard=Drupal,DrupalPractice -n public/themes/custom
- name: Install Drupal
run: vendor/bin/drush site-install --verbose --yes $DRUPAL_INSTALL_PROFILE
- name: Operate on Drupal
run: |
vendor/bin/drush status
# composer require --no-progress drupal/ctools
# vendor/bin/drush en --yes ctools
- name: Run web server with Drush
run: |
vendor/bin/drush runserver $SIMPLETEST_BASE_URL > /dev/null 2>&1 &
chromedriver --port=4444 &
- name: Wait for web server to start
run: for i in {1..5}; do RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$SIMPLETEST_BASE_URL" || true); if [ "$RESPONSE_CODE" -gt "301" ] || [ "$RESPONSE_CODE" -lt "200" ]; then sleep 2; fi; done
- name: Run PHPUnit tests
run: |
set -o pipefail && vendor/bin/phpunit -c $GITHUB_WORKSPACE/phpunit.xml.dist
- name: Create an artifact from test report
uses: actions/upload-artifact@v4
if: always()
with:
name: results
path: public/sites/simpletest/browser_output/
retention-days: 1