Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions: Only initialize required database service #192

Open
jrchamp opened this issue Oct 17, 2022 · 2 comments
Open

GitHub Actions: Only initialize required database service #192

jrchamp opened this issue Oct 17, 2022 · 2 comments

Comments

@jrchamp
Copy link
Contributor

jrchamp commented Oct 17, 2022

Currently, both mariadb and postgres images are installed and configured for each test. As far as the Moodle install, only one database is actually used per job. For self-hosted runners, this is quite wasteful and requires more frequent container cleanup. Moodle core uses conditional logic that appears to address this concern. Is that something that could / should be added to the recommended GHA configuration? Or is there a good reason that moodle-plugin-ci has not been changed to align with Moodle itself?

@stronk7
Copy link
Member

stronk7 commented Oct 18, 2022

Hi @jrchamp ,

I think that's something that is going to be hard to solve. The environment for each build in the matrix is completely isolated from others, so if you've it defined to run with, say:

  • php 7.4 and 8.0.
  • mysql and postgres
  • boost and classic
    (just to name some variables that may be part of the "matrix")

Then you got 2 x 2 x 2 = 8 builds (jobs to effectively be run). And each one knows nothing about the others and have to be in isolated environments. With Travis, with GHA and with any CI I can imagine.

Not sure if that's what you're talking about, feel free to enlighten me (I'm specially "silly" today)...

Then, it's the problem about Moodle instances being installed by the install command, when they should only be installed when phpunit or behat are going to be run. So, if all you want to do are static analysis, then don't need to spend some minute(s) waiting for the site to be installed for nothing.

That's reported in #36 and hope some day we can move the initialisation to the real commands and same some good time.

Ciao :-)

@stronk7
Copy link
Member

stronk7 commented Oct 18, 2022

Ah,

on a second read I think I've understood now! You are talking about only installing the DB engine that the run (in the matrix) is going to need.

And that, obviously, cannot be done in the "services" section (that is the recommended way in moodle-plugin-ci), because the services (unless I'm wrong, haven't checked) don't know anything about the matrix.

So, the alternative solution, that we use in core, is to install the DB engines using available GHA actions, and conditionally, so we setup MySQL or PostgreSQL based on the matrix run.

Yeah, that's something that we could document, so people knows that, by using the available GHA actions to setup the DB, they can fine (conditionally) control which DBs are setup.

I'd investigate if the "services" know about the "matrix" or no, because, if they are matrix-aware and can add the conditions there... then everything is way simpler. If not, then we have to use actions providing the DBs (GHA only, cannot imagine how to do so with Travis), or maybe create an action ourselves, that, automagically, setups any database... to dream is cheap!

In any case, to document the possibility is a welcome addition for those worried about starting too many "services" (docker containers) for nothing.

Ciao :-)

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

No branches or pull requests

2 participants