-
Notifications
You must be signed in to change notification settings - Fork 9
142 lines (127 loc) · 5.71 KB
/
Copy pathreusable-testing.yml
File metadata and controls
142 lines (127 loc) · 5.71 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
name: Run Tests
on:
workflow_call:
inputs:
test-package:
type: string
required: true
php:
type: string
required: true
wp:
type: string
required: true
# Retained as optional inputs rather than removed, so a database or object
# cache leg can be reinstated without reshaping the workflow. The matrix no
# longer varies them: storage backends are covered per-package.
dbtype:
type: string
required: false
default: 'mysql'
object_cache:
type: string
required: false
default: 'none'
use-phar:
type: boolean
required: true
jobs:
run-test:
name: WP ${{ inputs.wp }} | PHP ${{ inputs.php }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.dbtype == 'mysql' && 'MySQL' || 'MariaDB' }}${{ inputs.use-phar && ' (Phar)' || '' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}
runs-on: ubuntu-22.04
# In this repository’s current matrix, every leg gates. The `continue-on-error`
# condition is retained so callers can still run optional SQLite/object-cache
# legs without reshaping the workflow, if needed.
continue-on-error: ${{ inputs.dbtype == 'sqlite' || inputs.object_cache == 'sqlite' }}
timeout-minutes: 90
env:
MYSQL_HOST: 127.0.0.1
MYSQL_TCP_PORT: 3306
WP_CLI_TEST_DBROOTUSER: root
WP_CLI_TEST_DBROOTPASS: root
WP_CLI_TEST_DBNAME: wp_cli_test
WP_CLI_TEST_DBUSER: wp_cli_test
WP_CLI_TEST_DBPASS: password1
WP_CLI_TEST_DBHOST: 127.0.0.1:3306
WP_CLI_TEST_OBJECT_CACHE: ${{ inputs.object_cache }}
steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Check existence of composer.json & behat.yml files
id: check_files
run: echo "files_exists=$([ -f composer.json ] && [ -f behat.yml ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
# Ghostscript ships with the GitHub hosted images, so the `apt-get update`
# this used to run unconditionally cost every job ~25s for a package that
# was already there. Keep the install as a fallback in case a future image
# drops it.
- name: Install Ghostscript
if: steps.check_files.outputs.files_exists == 'true'
run: |
if command -v gs > /dev/null 2>&1; then
echo "Ghostscript $(gs --version) is already installed; skipping."
exit 0
fi
sudo apt-get update
sudo apt-get install ghostscript -y
- name: Set up PHP environment
if: steps.check_files.outputs.files_exists == 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '${{ inputs.php }}'
extensions: gd, imagick, mysql, zip, pdo_sqlite
coverage: none
tools: composer
# composer.json sets `"lock": false` and every requirement is `dev-main`, so
# `composer update` resolves on every run while the cache key stays pinned to
# composer.json and never changes on its own. Rotate it weekly so third party
# dependencies cannot be served out of an indefinitely stale cache.
- name: Determine the weekly Composer cache suffix
id: composer-cache-suffix
run: echo "value=$(date -u +%Y-%W)" >> "$GITHUB_OUTPUT"
- name: Install Composer dependencies & cache dependencies
if: steps.check_files.outputs.files_exists == 'true'
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
with:
custom-cache-suffix: ${{ steps.composer-cache-suffix.outputs.value }}
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
- name: Change ImageMagick policy to allow pdf->png conversion.
if: steps.check_files.outputs.files_exists == 'true'
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
- name: Setup MySQL Server
id: setup-mysql
if: ${{ inputs.dbtype != 'sqlite' }}
uses: shogo82148/actions-setup-mysql@62da9377d83991fce27b6ed2a397d3306121e41d # v1
with:
mysql-version: '8.0' # Standard MySQL version for these tests
auto-start: true
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
user: ${{ env.WP_CLI_TEST_DBUSER}}
password: ${{ env.WP_CLI_TEST_DBPASS}}
my-cnf: |
default_authentication_plugin=mysql_native_password
- name: Prepare test database
if: steps.check_files.outputs.files_exists == 'true' && inputs.dbtype != 'sqlite'
run: composer prepare-tests
- name: Conditionally use Phar instead of source
if: steps.check_files.outputs.files_exists == 'true' && inputs.use-phar == true
run: echo "TEST_PHAR=nightly" >> $GITHUB_ENV
- name: Check Behat environment
if: steps.check_files.outputs.files_exists == 'true'
env:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype }}
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
- name: Run Behat
if: steps.check_files.outputs.files_exists == 'true'
env:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype }}
TEST_PACKAGE: 'wp-cli/${{ inputs.test-package }}'
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
run: composer test