-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
230 lines (214 loc) · 10 KB
/
Copy pathaction.yml
File metadata and controls
230 lines (214 loc) · 10 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
name: PHPUnit Action
author: discoverygarden
description: Runs configured PHPUnit Tests implemented in called repository.
inputs:
composer-auth:
description: 'Composer auth token necessary for accessing our composer project.'
required: false
composer_package:
description: "Composer project reference. (ex. discoverygarden/dgi_group) it's only necessary to provide this if the composer package differs from the repository name."
required: false
default: "${{ github.repository }}"
drupal_extension:
description: "The module name for enabling within drupal. (Ex. discoverygarden/module would be `module`). It's only necessary to provide this if the module name differs from the repository name."
required: false
default: "${{ github.event.repository.name }}"
composer_patches:
description: 'Additional composer patches that might be necessary to run the workflow.'
required: false
default: '{}'
composer_package_prerequisites:
description: 'require-dev modules required for the module.'
required: false
drupal_root:
description: 'The root drupal directory. (Default: /opt/drupal)'
default: /opt/drupal
drupal_web_root:
description: 'The drupal web root directory. (Default: /opt/drupal/web)'
default: /opt/drupal/web
postgres_db:
description: 'The postgres database name. (Default: drupal)'
default: drupal
postgres_user:
description: 'The postgres database user. (Default: drupal)'
default: drupal
postgres_password:
description: 'The postgress database user password. (Default: drupal)'
default: drupal
apache_user:
description: 'The apache user. (Default: www-data)'
default: www-data
apache_user_group:
description: 'The apache user group. (Default: www-data)'
default: www-data
drupal-version:
description: 'The version of Drupal under which to run, if we need to know it.'
default: "${{ matrix.drupal-version }}"
experimental:
type: boolean
description: 'If the execution should be permissive of errors.'
default: "${{ matrix.experimental }}"
drush-spec:
description: 'Composer spec for acquiring drush.'
default: 'drush/drush'
do-leniency:
default: true
lenient-packages:
default: '[]'
matrix-patches:
default: '{}'
runs:
using: "composite"
steps:
- name: Grab additional packages
run: |
echo "::group::Installing drupal and composer"
# postgresql-client required for drush's site installation process
# git required to grab repo as repo via actions/checkout
apt update
apt install -y postgresql-client git unzip jq
shell: bash
- name: Checkout Repo
uses: actions/checkout@v7
- name: Misc setup
working-directory: ${{ inputs.drupal_root }}
run: |
set -eu
# XXX: When running inside a container, it skips the entry point,
# so... let's kick off the Apache process.
apache2ctl start
# Configure access and install our module.
if [ -n "${{ inputs.composer-auth }}" ] ; then
echo '${{ inputs.composer-auth }}' > auth.json
fi
# Setup our repos.
# XXX: We don't want the default Drupal thing first (it'll be readded
# later).
composer config --unset repositories.0
# We need to specify things in the _opposite_ order than what we want.
# XXX: Some repos are in an odd state, between different repos... so
# let's throw 'em in.
if [ -n "${{ inputs.composer-auth }}" ] ; then
composer config -- repo.packagist false
else
composer config --json -- repositories.packagist \
'{"type": "composer", "url": "https://repo.packagist.org", "canonical": false}'
fi
composer config --json -- repositories.drupal \
'{"type": "composer", "url": "https://packages.drupal.org/8", "canonical": false}'
# Configure access, and add our private packagist, if relevant.
if [ -n "${{ inputs.composer-auth }}" ] ; then
echo '${{ inputs.composer-auth }}' > auth.json
composer config --json -- repositories.private_packagist \
'{"type": "composer", "url": "https://repo.packagist.com/discoverygarden/", "canonical": false}'
fi
git config --global --add safe.directory $GITHUB_WORKSPACE
composer config --json -- repositories.actions \
"{\"type\": \"path\", \"url\": \"$GITHUB_WORKSPACE\"}"
# Dump out the configured repositories.
composer config repositories
PATCHES="$(
jq -n 'reduce inputs as $item ({}; . * $item)' \
<(echo '${{ env.COMPOSER_PATCHES }}') \
<(echo '${{ inputs.matrix-patches }}') \
<(echo '${{ env.ADDITIONAL_COMPOSER_PATCHES }}')
)"
if [ "$(jq 'length > 1' <(echo "$PATCHES"))" = 'true' ] ; then
composer config -- allow-plugins.cweagans/composer-patches true
composer config --json --merge -- extra.patches "$PATCHES"
composer require "cweagans/composer-patches:^1.7"
fi
composer config minimum-stability dev
# Leniency for Drupal versions...
if [ '${{ inputs.do-leniency }}' = 'true' ] ; then
echo "Doing the lenient thing."
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
composer config --merge --json extra.drupal-lenient.allowed-list '${{ inputs.lenient-packages }}'
composer require "mglaman/composer-drupal-lenient"
else
echo "Not doing the lenient thing."
fi
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] ; then
if [[ "${{ github.ref_type }}" == "branch" ]] ; then
VERSION_SPEC="dev-${{ github.ref_name }}"
else
VERSION_SPEC="${{ github.ref_name }}"
fi
else
VERSION_SPEC="dev-${{ github.sha }}"
fi
composer require --update-with-all-dependencies ${{ env.COMPOSER_PACKAGE_PREREQUISITES }} ${{ env.ADDITIONAL_COMPOSER_PACKAGE_PREREQUISITES }} \
"${{ inputs.composer_package }}:$VERSION_SPEC"
# XXX: Trying to run PHPUnit complains w/o prophecy-phpunit:
# > Drupal requires Prophecy PhpUnit when using PHPUnit 9 or greater.
# > Please use 'composer require --dev phpspec/prophecy-phpunit:^2' to
# > ensure that it is present.
# ... so let's add it as well...
composer require --dev --update-with-all-dependencies "drupal/core-dev:~${{ inputs.drupal-version }}.0" phpspec/prophecy-phpunit:^2
# Install Drush.
composer require --update-with-all-dependencies ${{ inputs.drush-spec }}
# Install the site.
drush --uri=http://localhost --yes -v site:install minimal --db-url="pgsql://${{ inputs.postgres_user }}:${{ inputs.postgres_password }}@postgres/${{ inputs.postgres_db}}" install_configure_form.enable_update_status_emails=NULL
# Install the module.
drush --uri=http://localhost --yes -v en ${{ inputs.drupal_extension }}
chown -R $APACHE_USER:$APACHE_GROUP web/sites web/modules web/themes
echo "::endgroup::"
env:
# XXX: Installation of the module is presently a little funky...
# "require-dev" doesn't quite do the trick, as it's only usable at the
# root-project level.
COMPOSER_PACKAGE_PREREQUISITES: >-
"discoverygarden/test_support:dev-main as 1.x-dev"
"discoverygarden/islandora_test_support:^1"
"drupal/geolocation:3.x-dev"
ADDITIONAL_COMPOSER_PACKAGE_PREREQUISITES: ${{ inputs.composer_package_prerequisites }}
# Patches need to be publically accessible, presently (so no private PRs,
# at present).
COMPOSER_PATCHES: |-
{
"drupal/core": {
"Referencable unpublished nodes": "https://www.drupal.org/files/issues/2022-06-17/2845144-67.patch"
},
"drupal/migrate_directory": {
"D11 support": "https://www.drupal.org/files/issues/2025-01-12/migrate_directory.2.x-dev.rector.patch",
"https://www.drupal.org/project/migrate_directory/issues/3594904": "https://git.drupalcode.org/project/migrate_directory/-/commit/e303f73ef1f8738f5098b3328c23ccb7cac02bbf.diff"
}
}
ADDITIONAL_COMPOSER_PATCHES: ${{ inputs.composer_patches }}
APACHE_USER: ${{ inputs.apache_user }}
APACHE_GROUP: ${{ inputs.apache_group }}
shell: bash
continue-on-error: ${{ fromJSON(inputs.experimental) }}
- name: Run PHPUnit tests (base)
env:
SIMPLETEST_BASE_URL: http://127.0.0.1
SIMPLETEST_DB: "pgsql://${{ inputs.postgres_user }}:${{ inputs.postgres_password }}@postgres/${{ inputs.postgres_db}}"
APACHE_USER: ${{ inputs.apache_user }}
DRUPAL_WEB_ROOT: ${{ inputs.drupal_web_root }}
working-directory: ${{ inputs.drupal_root }}
continue-on-error: ${{ fromJSON(inputs.experimental) }}
run: |
echo "::group::Run PHPUnit tests (base)"
su "$APACHE_USER" -s /bin/bash <<-EOS
phpunit "--bootstrap=$DRUPAL_WEB_ROOT/core/tests/bootstrap.php" --group ${{ inputs.drupal_extension }} "$GITHUB_WORKSPACE"
EOS
echo "::endgroup::"
shell: bash
- name: Run PHPUnit tests (reporting deprecations)
env:
SIMPLETEST_BASE_URL: http://127.0.0.1
SIMPLETEST_DB: "pgsql://${{ inputs.postgres_user }}:${{ inputs.postgres_password }}@postgres/${{ inputs.postgres_db}}"
APACHE_USER: ${{ inputs.apache_user }}
DRUPAL_WEB_ROOT: ${{ inputs.drupal_web_root }}
working-directory: ${{ inputs.drupal_root }}
# XXX: A number of deprecation things in modules pulled in make a mess
# presently... so let's just report 'em, for now.
continue-on-error: true
run: |
echo "::group::Run PHPUnit tests (reporting deprecations)"
su "$APACHE_USER" -s /bin/bash <<-EOS
phpunit "--configuration=$DRUPAL_WEB_ROOT/core/phpunit.xml.dist" --group ${{ inputs.drupal_extension }} "$GITHUB_WORKSPACE"
EOS
echo "::endgroup::"
shell: bash