0

I have GitHub repo and I want to use GithubActions to automatically execute unit Tests with every pull request.

I already set up a workflow file:

   name: CI

on:
  pull_request:
    branches: [ master ]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
      - name: Install
        run: npm ci
      - name: Linter
        run: npm run lint
      - name: Build
        run: npm run build
      - name: Docker
        run: docker-compose up -d
      - name: Wait / Sleep
        uses: jakejarvis/[email protected]
        with:
          time: '10s'
      - run: | 
          docker ps
          cat ./dumps/backup.sql | docker exec -i mysql-development_1 /usr/bin/mysql -u root --password=password        
      - name: Test
        run: npm test

As I need to insert the tables first, I want to insert a dump which does work on my machine with the exact same command used here.

However, the Action fails with this error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
read unix @->/var/run/docker.sock: read: connection reset by peer
cat: write error: Broken pipe
##[error]Process completed with exit code 1.

How can I access the database within GithubActions?

docker-compose.yml:

version: '3'

services:

  mysql-development:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: test_db
    ports:
      - "3308:3306"

1 Answer 1

1

To anyone who might run into the same problem:

https://github.blog/changelog/2020-02-21-github-actions-breaking-change-ubuntu-virtual-environments-will-no-longer-start-the-mysql-service-automatically/

You just need to start the mysql-service manually and perhaps wait for a couple of seconds

Sign up to request clarification or add additional context in comments.

1 Comment

does the start order matter? Docker up first or mysql start first?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.