@@ -17,15 +17,15 @@ jobs:
1717
1818 # Virtual Environment to use.
1919 # @see: https://github.com/actions/virtual-environments
20- runs-on : ubuntu-20.04
20+ runs-on : ubuntu-latest
2121
2222 # Environment Variables.
2323 # Accessible by using ${{ env.NAME }}
2424 # Use ${{ secrets.NAME }} to include any GitHub Secrets in ${{ env.NAME }}
2525 # The base folder will always be /home/runner/work/github-repo-name/github-repo-name
2626 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
2929 DB_NAME : test
3030 DB_USER : root
3131 DB_PASS : root
7272 replace : ' -'
7373 replaceAll : true
7474
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+
7582 - name : Start MySQL
7683 run : sudo systemctl start mysql.service
7784
@@ -86,17 +93,15 @@ jobs:
8693
8794 # Some workflows checkout WordPress from GitHub, but that seems to bring a bunch of uncompiled files with it.
8895 # 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
100105
101106 # We install WP-CLI, as it provides useful commands to setup and install WordPress through the command line.
102107 - name : Install WP-CLI
@@ -118,6 +123,10 @@ jobs:
118123 working-directory : ${{ env.ROOT_DIR }}
119124 run : wp-cli plugin install ${{ env.INSTALL_PLUGINS }}
120125
126+ # Move Plugin
127+ - name : Move Plugin
128+ run : mv /home/runner/work/convertkit-wpforms/convertkit-wpforms/convertkit-wpforms ${{ env.PLUGIN_DIR }}
129+
121130 # WP_DEBUG = true is required so all PHP errors are output and caught by tests (E_ALL).
122131 - name : Enable WP_DEBUG
123132 working-directory : ${{ env.ROOT_DIR }}
@@ -139,10 +148,37 @@ jobs:
139148 php-version : ${{ matrix.php-versions }}
140149 coverage : xdebug
141150
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
146182
147183 - name : Test nginx
148184 run : sudo nginx -t
@@ -190,6 +226,21 @@ jobs:
190226 working-directory : ${{ env.PLUGIN_DIR }}
191227 run : composer dump-autoload
192228
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+
193244 # This ensures the Plugin's log file can be written to.
194245 # We don't recursively do this, as it'll prevent Codeception from writing to the /tests/_output directory.
195246 - name : Set Permissions for Plugin Directory
0 commit comments