mirromutth/mysql-action

Should automatically shutdown the Default MySQL before setup a MySQL

fbjork opened this issue ยท 7 comments

I get this error when I try to setup a mysql instance in my Actions workflow. Any idea what I'm doing wrong?

docker: Error response from daemon: driver failed programming external connectivity on endpoint busy_mcnulty (e90f9b113c26a0772d43fe413b6c5755204a5459a16817a6ff398ca003a859ee): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use.

Here's my workflow:

jobs:
  ruby:
    name: Ruby Tests
    runs-on: ubuntu-latest
    steps:
      - uses: zhulik/redis-action@v1.0.0
        with:
          redis version: "4"

      - uses: mirromutth/mysql-action@v1.1
        with:
          mysql version: "5.7.17"
          mysql root password: "test"

      - uses: actions/checkout@v1.0.0

      - name: Setup Ruby
        uses: actions/setup-ruby@v1.0.0
        with:
          ruby-version: 2.5.5

      - name: Install Dependencies
        run: bundle install

      - name: Setup Database
        env:
          RAILS_ENV: test
          DATABASE_URL: mysql2://root:test@127.0.0.1/test
        run: bundle exec rake db:create db:schema:load --trace

      - name: Run Tests
        env:
          RAILS_ENV: test
          DATABASE_URL: mysql2://root:test@127.0.0.1/test
        run: bundle exec rspec

I got the same error when the host port was 3306. I changed both ports and it works for me.

mysql-action

@Keyflight Thanks. Curious why the default port doesn't work.

@Keyflight @fbjork Just found this out: looks like mysql is already installed on ubuntu (version 5.7) with root user password "root". Actually quite a bit of software is available:

https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions#ubuntu-1804-lts

All you need to do is create your database like so:

    - name: Create DB
      run: mysql -uroot -proot -e "CREATE DATABASE dbname;"

Hi there,

Sorry for late reply.
Sounds like the host port 3306 has bound. It seems like MySQL was set-up twice or the port 3306 has been bound by other container.

@mazzarito You're right, MySQL has been installed and started by ubuntu, so the port 3306 has been bound by default MySQL that is outer than Docker.

I will add a command try to stop the default MySQL of Ubuntu before set-up Docker MySQL.

For now, there is no built-in functionality to execute a command on the host before docker build (i.e., no "hooks" to trigger scripts on the host).

@fbjork @Keyflight So we should run a script by other Actions Step that will shutdown the Default MySQL before we set-up MySQL. Or just use the Default MySQL.

I have added its description to README, it is not a solution but it may be solve this problem.

Keep this issue, maybe we can fix this in future.

GitHub Actions Breaking Change:
Starting March 3rd, 2020, the Ubuntu virtual environments will no longer start the MySQL service automatically.

actions/runner-images#375