-
Notifications
You must be signed in to change notification settings - Fork 6
154 lines (136 loc) · 5.89 KB
/
reusable-functional.yml
File metadata and controls
154 lines (136 loc) · 5.89 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
name: Functional testing
on:
workflow_call:
inputs:
php:
type: string
required: true
wp:
type: string
required: true
dbtype:
type: string
required: false
default: 'mysql'
mysql:
type: string
required: false
default: ''
object_cache:
type: string
required: false
default: 'none'
coverage:
type: boolean
required: false
default: false
os:
type: string
required: false
default: 'ubuntu-22.04'
permissions:
contents: read
jobs:
functional:
name: Behat | PHP ${{ inputs.php }} | WP ${{ inputs.wp }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.dbtype == 'mariadb' && 'MariaDB' || 'MySQL' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
runs-on: ${{ inputs.os || 'ubuntu-22.04' }}
continue-on-error: ${{ inputs.dbtype == 'sqlite' || inputs.dbtype == 'mariadb' || inputs.php == 'nightly' || startsWith( inputs.os, 'windows' ) || startsWith( inputs.os, 'macos' ) }}
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Ghostscript
if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }}
run: |
sudo apt-get update
sudo apt-get install ghostscript -y
- name: Install dependencies (Windows)
if: ${{ startsWith(inputs.os, 'windows') }}
run: choco install sqlite ghostscript --yes
- name: Install dependencies (macOS)
if: ${{ startsWith(inputs.os, 'macos') }}
run: brew install ghostscript
- name: Set up PHP environment
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: '${{ inputs.php }}'
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
extensions: gd, imagick, mysql, zip, pdo_sqlite, exif
coverage: ${{ inputs.coverage && 'xdebug' || 'none' }}
tools: composer
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Change ImageMagick policy to allow pdf->png conversion.
if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }}
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
- name: Install Composer dependencies & cache dependencies
uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v3
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
# MySQL 8.4 requires explicit loading of mysql_native_password plugin
- name: Determine MySQL authentication configuration
id: mysql-config
if: ${{ inputs.dbtype != 'sqlite' && inputs.mysql == 'mysql-8.4' }}
run: |
echo "auth-config<<EOF" >> $GITHUB_OUTPUT
echo "mysql_native_password=ON" >> $GITHUB_OUTPUT
echo "authentication_policy=mysql_native_password," >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Setup MySQL Server
id: setup-mysql
if: ${{ inputs.dbtype != 'sqlite' }}
uses: shogo82148/actions-setup-mysql@840178c12b07a58353c6312be784c23b63756eea # v1
with:
mysql-version: ${{ inputs.mysql }}
auto-start: true
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
user: ${{ env.WP_CLI_TEST_DBUSER}}
password: ${{ env.WP_CLI_TEST_DBPASS}}
# Fall back to legacy configuration for MySQL 5.6, 5.7, 8.0 and MariaDB.
my-cnf: |
${{ steps.mysql-config.outputs.auth-config || 'default_authentication_plugin=mysql_native_password' }}
${{ inputs.dbtype == 'mariadb' && '[client]' || '' }}
${{ inputs.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }}
- name: Prepare test database
if: ${{ inputs.dbtype != 'sqlite' }}
run: composer prepare-tests
- name: Check Behat environment
env:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype || 'mysql' }}
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
WP_CLI_TEST_DEBUG_BEHAT_ENV: 1
run: composer behat
- name: Run Behat
env:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype || 'mysql' }}
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
WP_CLI_TEST_COVERAGE: ${{ inputs.coverage }}
BEHAT_ARGS: ${{ format( '{0}', runner.debug && '--format=pretty' ) }}
run: |
composer behat -- $BEHAT_ARGS || composer behat-rerun -- $BEHAT_ARGS
- name: Retrieve list of coverage files
id: coverage_files
if: ${{ inputs.coverage }}
run: |
FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -)
echo "files=$FILES" >> $GITHUB_OUTPUT
- name: Upload code coverage report
if: ${{ inputs.coverage }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
# Because somehow providing `directory: build/logs` doesn't work for these files
files: ${{ steps.coverage_files.outputs.files }}
flags: feature
token: ${{ secrets.CODECOV_TOKEN }}