@@ -17,15 +17,15 @@ jobs:
17
17
18
18
# Virtual Environment to use.
19
19
# @see: https://github.com/actions/virtual-environments
20
- runs-on : ubuntu-20.04
20
+ runs-on : ubuntu-latest
21
21
22
22
# Environment Variables.
23
23
# Accessible by using ${{ env.NAME }}
24
24
# Use ${{ secrets.NAME }} to include any GitHub Secrets in ${{ env.NAME }}
25
25
# The base folder will always be /home/runner/work/github-repo-name/github-repo-name
26
26
env :
27
- ROOT_DIR : /home/runner/work/convertkit-wpforms/convertkit-wpforms/wordpress
28
- PLUGIN_DIR : /home/runner/work/convertkit-wpforms/convertkit-wpforms/wordpress /wp-content/plugins/convertkit-wpforms
27
+ ROOT_DIR : /var/www/html
28
+ PLUGIN_DIR : /var/www/html /wp-content/plugins/convertkit-wpforms
29
29
DB_NAME : test
30
30
DB_USER : root
31
31
DB_PASS : root
72
72
replace : ' -'
73
73
replaceAll : true
74
74
75
+ # Checkout Plugin to /home/runner/work/convertkit-wpforms/convertkit-wpforms/convertkit-wpforms
76
+ # We cannot checkout to ${{ env.PLUGIN_DIR }} as GitHub Actions require it be first placed in /home/runner/work/repo/repo
77
+ - name : Checkout Plugin
78
+ uses : actions/checkout@v4
79
+ with :
80
+ path : /home/runner/work/convertkit-wpforms/convertkit-wpforms/convertkit-wpforms
81
+
75
82
- name : Start MySQL
76
83
run : sudo systemctl start mysql.service
77
84
@@ -86,17 +93,15 @@ jobs:
86
93
87
94
# Some workflows checkout WordPress from GitHub, but that seems to bring a bunch of uncompiled files with it.
88
95
# Instead download from wordpress.org stable.
89
- - name : Download WordPress
90
- run : wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
91
-
92
- - name : Extract WordPress
93
- run : tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
94
-
95
- # Checkout (copy) this repository's Plugin to this VM.
96
- - name : Checkout Plugin
97
- uses : actions/checkout@v4
98
- with :
99
- path : ${{ env.PLUGIN_DIR }}
96
+ - name : Download and Extract WordPress
97
+ run : |
98
+ sudo chown -R runner:docker /var/www/html
99
+ ls -la /var/www/html
100
+ cd /var/www/html
101
+ wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
102
+ tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
103
+ mv wordpress/* .
104
+ rm -rf wordpress wordpress-${{ matrix.wp-versions }}.tar.gz
100
105
101
106
# We install WP-CLI, as it provides useful commands to setup and install WordPress through the command line.
102
107
- name : Install WP-CLI
@@ -118,6 +123,10 @@ jobs:
118
123
working-directory : ${{ env.ROOT_DIR }}
119
124
run : wp-cli plugin install ${{ env.INSTALL_PLUGINS }}
120
125
126
+ # Move Plugin
127
+ - name : Move Plugin
128
+ run : mv /home/runner/work/convertkit-wpforms/convertkit-wpforms/convertkit-wpforms ${{ env.PLUGIN_DIR }}
129
+
121
130
# WP_DEBUG = true is required so all PHP errors are output and caught by tests (E_ALL).
122
131
- name : Enable WP_DEBUG
123
132
working-directory : ${{ env.ROOT_DIR }}
@@ -139,10 +148,37 @@ jobs:
139
148
php-version : ${{ matrix.php-versions }}
140
149
coverage : xdebug
141
150
142
- # Make sure that an nginx configuration file exists in this repository at tests/nginx/php-x.x.conf.
143
- # Refer to an existing .conf file in this repository if you need to create a new one e.g. for a new PHP version.
144
- - name : Copy nginx configuration file
145
- run : sudo cp ${{ env.PLUGIN_DIR }}/tests/nginx/php-${{ matrix.php-versions }}.conf /etc/nginx/conf.d/php-${{ matrix.php-versions }}.conf
151
+ # Configure nginx to use the PHP version and WOrdPress installation at /var/www/html
152
+ - name : Configure nginx site
153
+ run : |
154
+ sudo rm -f /etc/nginx/sites-enabled/default
155
+ sudo tee /etc/nginx/sites-available/default > /dev/null << 'EOF'
156
+
157
+ server {
158
+ listen 80 default_server;
159
+ listen [::]:80 default_server;
160
+
161
+ root /var/www/html;
162
+ index index.php;
163
+
164
+ server_name localhost;
165
+
166
+ location / {
167
+ try_files $uri $uri/ /index.php?$args;
168
+ }
169
+
170
+ location ~ \.php$ {
171
+ include snippets/fastcgi-php.conf;
172
+ fastcgi_pass unix:/run/php/php${{ matrix.php-versions }}-fpm.sock;
173
+ }
174
+
175
+ location ~ /\.ht {
176
+ deny all;
177
+ }
178
+ }
179
+ EOF
180
+
181
+ sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default || true
146
182
147
183
- name : Test nginx
148
184
run : sudo nginx -t
@@ -190,6 +226,21 @@ jobs:
190
226
working-directory : ${{ env.PLUGIN_DIR }}
191
227
run : composer dump-autoload
192
228
229
+ # This ensures that applicable files and folders can be written to by WordPress and cache Plugins.
230
+ - name : Set File and Folder Permissions
231
+ run : |
232
+ sudo chmod 767 ${{ env.ROOT_DIR }}
233
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}
234
+
235
+ sudo chmod 767 ${{ env.ROOT_DIR }}/wp-config.php
236
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-config.php
237
+
238
+ sudo chmod 767 ${{ env.ROOT_DIR }}/wp-content
239
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content
240
+
241
+ sudo chmod -R 767 ${{ env.ROOT_DIR }}/wp-content/uploads
242
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content/uploads
243
+
193
244
# This ensures the Plugin's log file can be written to.
194
245
# We don't recursively do this, as it'll prevent Codeception from writing to the /tests/_output directory.
195
246
- name : Set Permissions for Plugin Directory
0 commit comments