-
Notifications
You must be signed in to change notification settings - Fork 2
184 lines (155 loc) · 6.51 KB
/
build.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Build, Validate and Test
on:
schedule:
# Weekdays at 22:00 UTC (Monday to Friday 8 am AEST).
- cron: '0 22 * * 1-5'
workflow_dispatch:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
jobs:
full:
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' || !github.event.pull_request.draft }}
name: Full (Build, Validate, and Test)
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3']
services:
database:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
env:
SKIP_CHECKS: ${{ vars.SKIP_CHECKS }}
CI: GITHUB_ACTIONS
GH_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
# github.head_ref is only defined on pull_request events.
# When not a PR, github.ref_name has the branch name.
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# the commit ID for the last commit to the head branch of the pull request
# (the default is the last *merge* commit of the pull request merge branch)
- name: Setup PHP and tools
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:2.7.7
# See https://www.drupal.org/docs/getting-started/system-requirements/php-requirements#extensions
extensions: curl, date, dom, filter, gd, hash, json, mbstring, mysql, pcre, pdo, pdo_mysql, session, SimpleXML, SPL, tokenizer, xml, xmlwriter
# See https://docs.pantheon.io/guides/account-mgmt/plans/resources#current-plan-resources
ini-values: memory_limit=256M, max_execution_time=120
coverage: none
- name: Install php-spx extension
run: |
cd /tmp
git clone https://github.com/NoiseByNorthwest/php-spx.git
cd php-spx
git checkout release/latest
phpize
./configure
make
mkdir -p $HOME/php-exts
make INSTALL_ROOT=$HOME/php-exts install
EXTENSION_DIR=$(find $HOME/php-exts -name 'spx.so' | sed 's|/spx.so||')
echo "extension=${EXTENSION_DIR}/spx.so" >> "$(php -r 'echo php_ini_loaded_file();')"
shell: bash
- name: Prepare environment variables
run: |
echo "GITHUB_REF_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
echo "COMPOSER_BIN=$(echo ${GITHUB_WORKSPACE}/vendor/bin)" >> $GITHUB_ENV
echo "drush=$(echo ${GITHUB_WORKSPACE}/bin/drush)" >> $GITHUB_ENV
echo "SCRIPT_DIR=$(echo ${GITHUB_WORKSPACE}/.github/scripts)" >> $GITHUB_ENV
# Caching based on https://github.com/marketplace/actions/composer-php-actions#caching-dependencies-for-faster-builds
- name: Determine Composer cache directory
shell: bash
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"
- name: Cache dependencies installed with Composer
uses: actions/cache@v4
with:
path: |
"${{ env.COMPOSER_CACHE_DIR }}"
$GITHUB_WORKSPACE/vendor
$GITHUB_WORKSPACE/web/core
$GITHUB_WORKSPACE/web/libraries
$GITHUB_WORKSPACE/web/modules/contrib
$GITHUB_WORKSPACE/web/themes/contrib
$GITHUB_WORKSPACE/web/profiles/contrib
key: os-${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- name: Cache node modules
uses: actions/cache@v4
with:
path: |
~/.npm
~/.nvm
key: ${{ runner.os }}-build-${{ github.ref }}
# Caching END
- name: Composer install
run: |
composer validate
composer --no-interaction --no-progress --prefer-dist --optimize-autoloader install
- name: Setup environment variables
run: |
echo "$GITHUB_WORKSPACE/vendor/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Validate composer
run: composer validate --no-check-all --ansi
- name: Download JavaScript Cookie Library
run: curl --create-dirs -o libraries/js-cookie/dist/js.cookie.min.js https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
- name: PHP Compatibility Check
run: |
phpcs -p modules/custom --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --extensions=php,module,inc --runtime-set testVersion ${{ matrix.php }}
phpcs -p themes/custom --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --extensions=php,theme,inc --runtime-set testVersion ${{ matrix.php }}
- name: Run code quality checks
run: grumphp run --testsuite=code_quality
- name: Run code security checks
if: ${{ !env.SKIP_CHECKS || env.SKIP_CHECKS != '1' }}
run: grumphp run --testsuite=code_security
- name: Execute Drupal-check
run: php ./bin/drupal-check modules/custom
- name: Show environment variables
run: ls -alk ./bin
- name: Setup MySQL
run: |
sudo service mysql start
mysql -uroot -proot < $(echo ${SCRIPT_DIR})/install.sql
- name: Setup Application
run: |
SPX_ENABLED=1 drush si convivial --locale=en --db-url=mysql://drupal:[email protected]:${{ job.services.mysql.ports[3306] }}/drupal --account-name=superadmin --account-pass=superadmin --site-name='Convivial Demo' --yes
drush ucrt admin --password=admin [email protected] --yes
drush urol site_administrator admin --yes
drush status
- name: Start Application in background
run: |
drush runserver localhost:8080 &
until netstat -an 2>/dev/null | grep '8080.*LISTEN'; do true; done
- name: Run Drupal Test Traits
run: phpunit
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Prepare environment variables for cypress tests
run: |
which node
node --version
npm --version
cp cypress.ci.default.json cypress.env.json
- name: Install cypress dependencies
run: |
npm install
npm list
- name: Run Cypress Tests
run: npx cypress run