@@ -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-woocommerce/convertkit-woocommerce/wordpress
28
- PLUGIN_DIR : /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress /wp-content/plugins/convertkit-woocommerce
27
+ ROOT_DIR : /var/www/html
28
+ PLUGIN_DIR : /var/www/html /wp-content/plugins/convertkit-woocommerce
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-woocommerce/convertkit-woocommerce/convertkit-woocmmerce
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-woocommerce/convertkit-woocommerce/convertkit-woocommerce
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
@@ -132,6 +137,10 @@ jobs:
132
137
- name : Install Paid Third Party WordPress Plugins
133
138
working-directory : ${{ env.ROOT_DIR }}
134
139
run : wp-cli plugin install ${{ secrets.CONVERTKIT_PAID_PLUGIN_URLS }}
140
+
141
+ # Move Plugin
142
+ - name : Move Plugin
143
+ run : mv /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocommerce ${{ env.PLUGIN_DIR }}
135
144
136
145
# WP_DEBUG = true is required so all PHP errors are output and caught by tests (E_ALL).
137
146
# WP_DEBUG = false for PHP 8.1+, otherwise E_DEPRECATED is output due to WooCommerce.
@@ -156,10 +165,37 @@ jobs:
156
165
php-version : ${{ matrix.php-versions }}
157
166
coverage : xdebug
158
167
159
- # Make sure that an nginx configuration file exists in this repository at tests/nginx/php-x.x.conf.
160
- # Refer to an existing .conf file in this repository if you need to create a new one e.g. for a new PHP version.
161
- - name : Copy nginx configuration file
162
- run : sudo cp ${{ env.PLUGIN_DIR }}/tests/nginx/php-${{ matrix.php-versions }}.conf /etc/nginx/conf.d/php-${{ matrix.php-versions }}.conf
168
+ # Configure nginx to use the PHP version and WOrdPress installation at /var/www/html
169
+ - name : Configure nginx site
170
+ run : |
171
+ sudo rm -f /etc/nginx/sites-enabled/default
172
+ sudo tee /etc/nginx/sites-available/default > /dev/null << 'EOF'
173
+
174
+ server {
175
+ listen 80 default_server;
176
+ listen [::]:80 default_server;
177
+
178
+ root /var/www/html;
179
+ index index.php;
180
+
181
+ server_name localhost;
182
+
183
+ location / {
184
+ try_files $uri $uri/ /index.php?$args;
185
+ }
186
+
187
+ location ~ \.php$ {
188
+ include snippets/fastcgi-php.conf;
189
+ fastcgi_pass unix:/run/php/php${{ matrix.php-versions }}-fpm.sock;
190
+ }
191
+
192
+ location ~ /\.ht {
193
+ deny all;
194
+ }
195
+ }
196
+ EOF
197
+
198
+ sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default || true
163
199
164
200
- name : Test nginx
165
201
run : sudo nginx -t
@@ -209,6 +245,21 @@ jobs:
209
245
working-directory : ${{ env.PLUGIN_DIR }}
210
246
run : composer dump-autoload
211
247
248
+ # This ensures that applicable files and folders can be written to by WordPress and cache Plugins.
249
+ - name : Set File and Folder Permissions
250
+ run : |
251
+ sudo chmod 767 ${{ env.ROOT_DIR }}
252
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}
253
+
254
+ sudo chmod 767 ${{ env.ROOT_DIR }}/wp-config.php
255
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-config.php
256
+
257
+ sudo chmod 767 ${{ env.ROOT_DIR }}/wp-content
258
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content
259
+
260
+ sudo chmod -R 767 ${{ env.ROOT_DIR }}/wp-content/uploads
261
+ sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content/uploads
262
+
212
263
# This ensures the Plugin's log file can be written to.
213
264
# We don't recursively do this, as it'll prevent Codeception from writing to the /tests/_output directory.
214
265
- name : Set Permissions for Plugin Directory
0 commit comments