Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Add MySQL example. #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Potherca
Copy link

I thought it might be useful to have a working example for MySQL, in case folks want/need to use a different version from the installed default.

I've tried to make the code look similar to already existing examples.

The example can be seen working here: https://github.com/potherca-contrib/example-services/actions/runs/449593636

If you have any feedback, please let me know! 👍

Copy link

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While trying to get the VM version working, in my specific case, I still did not succeed unless I made the following additional changes.

Also see: https://github.community/t/how-to-use-a-different-mysql-version-than-the-default-5-7-in-a-gh-action/152403/

MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
# will assign a random free host port
- 3306/tcp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 3306/tcp
- 3306:3306

# use localhost for the host here because we are running the job on the VM.
# If we were running the job on in a container this would be mysql
MYSQL_HOST: localhost
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} # get randomly assigned published port
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} # get randomly assigned published port
MYSQL_PORT: 3306

@Potherca
Copy link
Author

@jrfnl I'd be curious to know why job.services.<service id>.ports did not work... but other than that, I am very much inclined to include your edit. 👍

Maybe @andymckay or @chrispat could comment on this?

@jrfnl
Copy link

jrfnl commented Feb 11, 2021

@Potherca I honestly wouldn't know. I also found that using 127.0.0.1 (or in practice: 127.0.0.1:3306) worked better than using localhost. But to be honest, I tried so much that it is hard to say which bit was the bit which fixed it.

In the end, the changes I needed for this particular workflow were quite small, but the complete combi was needed to get it all working. Relevant commits:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants