Setting up WordPress for integration test in action fails

Hi! I’m trying to set up tests to run with my GH actions, but I’m getting

ERROR 1045 (28000): Access denied for user ‘root’@‘172.18.0.1’ (using password: YES)

when trying to install WordPress. The workflow file is here: https://github.com/dingo-d/woo-solo-api/blob/feature/2.0.0-update/.github/workflows/checks.yml#L68

tests:  
name: Integration tests
runs-on: ubuntu-latest

services:  
mysql:  
image: mysql:5.7
env:  
MYSQL\_ROOT\_PASSWORD: root
ports:  
 - 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:  
 - name: Checkout
uses: actions/checkout@v2

- name: PHP Setup
uses: shivammathur/setup-php@v2
with:  
php-version: 7.2
coverage: pcov

- name: Set Node.js version
uses: actions/setup-node@v1
with:  
node-version: 14

- name: Cache node modules
uses: actions/cache@v1
with:  
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |  
 ${{ runner.OS }}-build-${{ env.cache-name }}-  
 ${{ runner.OS }}-build-  
 ${{ runner.OS }}-  
  
 - name: Get Composer Cache Directory
id: composer-cache
run: |  
 echo "::set-output name=dir::$(composer config cache-files-dir)"  
  
 - name: Cache Composer Dependencies
uses: actions/cache@v1
with:  
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |  
 ${{ runner.os }}-composer-  
  
 - name: Install composer packages
run: composer install --no-progress

- name: Install node packages
run: npm install

- name: Run JS build
run: npm run build

# Setup WordPress so that we can run tests  
- name: Set up WordPress instance so that we can run tests
run: |  
 cd .. && mkdir wp && cd wp  
 curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar  
 chmod +x wp-cli.phar  
 sudo mv wp-cli.phar /usr/local/bin/wp  
 wp core download  
 wp config create --dbname=$TEST\_DB\_NAME --dbhost=$TEST\_DB\_HOST --dbuser=$TEST\_DB\_USER --dbpass=$TEST\_DB\_PASSWORD  
 wp core install --url=$TEST\_SITE\_WP\_URL --title=Test --admin\_user=$TEST\_SITE\_ADMIN\_USERNAME --admin\_password=$TEST\_SITE\_ADMIN\_PASSWORD --admin\_email=$TEST\_SITE\_ADMIN\_EMAIL  
 yes | cp .env.actions.testing .env.testing  
env:  
WP\_ROOT\_FOLDER: "/var/www/html"  
TEST\_SITE\_WP\_ADMIN\_PATH: "/wp-admin"  
TEST\_SITE\_DB\_NAME: "wordpresstest"  
TEST\_SITE\_DB\_HOST: "127.0.0.1"  
TEST\_SITE\_DB\_USER: "root"  
TEST\_SITE\_DB\_PASSWORD: "password"  
TEST\_SITE\_DB\_PORT: "3306"  
TEST\_SITE\_TABLE\_PREFIX: "wp\_"  
TEST\_TABLE\_PREFIX: "wp\_"  
TEST\_SITE\_WP\_URL: "http://wordpress.test"  
TEST\_SITE\_WP\_DOMAIN: "wordpress.test"  
TEST\_SITE\_ADMIN\_EMAIL: "admin@local.test"  
TEST\_SITE\_ADMIN\_USERNAME: "admin"  
TEST\_SITE\_ADMIN\_PASSWORD: "password"  
TEST\_DB\_NAME: "wordpresstest"  
TEST\_DB\_HOST: "127.0.0.1"  
TEST\_DB\_USER: "root"  
TEST\_DB\_PASSWORD: "password"  
TEST\_DB\_PORT: "3306"  
  
- name: Run integration tests
run: composer test:integration

I’m trying to avoid writing a dockerfile where I’d run tests, as this seems faster an (in theory) easier.

I’m not 100% sure what I’m doing wrong, so any help is appreciated :) 

@dingo-d ,

I can reproduce the same error. I also tried some solutions like as mentioned here, but did not work.

I have reported this issue to the appropriate engineering team for further investigation and evaluation. If they have any progress, I will notify you in time, and sometimes the appropriate engineers may directly reply you here.

1 Like

Thanks!

In the meantime, I’ll try to play with docker solutions. It would be great to be able to just specify 2 services (MySQL and WordPress) and run the tests from those. Looking forward to it :) 

@dingo-d ,

Did you check if the passwords you are using is correct or matchs the one you set on the service?

I went with creating my own Docker image and running tests from the container. I couldn’t get this, or the image: option to work.

The tests are still not running (could be the testing lib fault) but I got the WordPress set up so that’s something :D