geerlingguy / jeffgeerling-com

Drupal Codebase for JeffGeerling.com
https://www.jeffgeerling.com
GNU General Public License v2.0
40 stars 2 forks source link

Issue #9: Add CI workflow for GitHub Actions. #10

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

Fixes #9.

geerlingguy commented 4 years ago

Getting:

Creating drupal-mysql     ... error

ERROR: for drupal-mysql  Cannot start service mysql: driver failed programming external connectivity on endpoint drupal-mysql (5f13a8b29d76b8050aff12fecd3c5ea46bc2ab847da5b00c83f08e91c06b2556): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use
geerlingguy commented 4 years ago

Added a step to stop MySQL:

    steps:
      - name: Stop the GitHub Actions MySQL instance.
        run: sudo service mysql stop

I also added a step to wait for MySQL to respond before installing Drupal:

      - name: Wait for MySQL to start.
        run: |
          while ! mysqladmin ping -h"127.0.0.1" -P"3306" --silent; do
            sleep 1
          done

That was taken from this post: Using the MySQL Service with Github Actions

geerlingguy commented 4 years ago

Drupal install fails with:

Run docker-compose exec drupal bash -c 'drush site:install minimal --db-url="mysql://drupal:drupal@127.0.0.1/drupal" --site-name="Jeff Geerling" --existing-config -y'
  shell: /bin/bash -e {0}
the input device is not a TTY
##[error]Process completed with exit code 1.

See related: https://github.com/docker/compose/issues/5696

geerlingguy commented 4 years ago

Also related: https://github.com/docker/compose/issues/3352

geerlingguy commented 4 years ago

Now hitting:

Run docker-compose exec -T drupal bash -c 'drush site:install minimal --db-url="mysql://drupal:drupal@127.0.0.1/drupal" --site-name="Jeff Geerling" --existing-config -y'

 // You are about to create a sites/default/settings.php file and CREATE the    
 // 'drupal' database. Do you want to continue?: yes.                           

In SiteInstallCommands.php line 367:

  Failed to drop or create the database:  

site:install [--db-url DB-URL] [--db-prefix DB-PREFIX] [--db-su DB-SU] [--db-su-pw DB-SU-PW] [--account-name [ACCOUNT-NAME]] [--account-mail [ACCOUNT-MAIL]] [--site-mail [SITE-MAIL]] [--account-pass ACCOUNT-PASS] [--locale [LOCALE]] [--site-name [SITE-NAME]] [--site-pass SITE-PASS] [--sites-subdir SITES-SUBDIR] [--config-dir CONFIG-DIR] [--existing-config] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--xh-link XH-LINK] [--druplicon] [--notify] [--] <command> [<profile>]...

##[error]Process completed with exit code 1.
geerlingguy commented 4 years ago

Now getting:

In bootstrap.inc line 230:

  The configuration directory type 'sync' does not exist  
geerlingguy commented 4 years ago

So the problem is this:

  1. I need to have $settings['config_sync_directory'] = '../config/sync'; in settings.php
  2. I don't want to store settings.php in my repo
  3. Drupal creates the settings.php during installation
  4. Drupal templates the settings.php from the default.settings.php.

Chicken-and-egg issue, because I can't just add a task that drops that line in settings.php... since it doesn't even exist. Maybe use composer-packages? The problem here is that Drush's install allows --existing-config but doesn't allow me (AFAICT) to override the config sync directory via CLI...

geerlingguy commented 4 years ago

I just realized the Drupal Composer template had some custom PHP to handle this scenario. It basically rewrites the settings.php file adding that line to the end.

I'm trying to just do it to the default.settings.php template with:

      - name: Add config sync directory config to default.settings.php.
        run: >
          echo "$settings['config_sync_directory'] = '../config/sync';"
          >> web/sites/default/default.settings.php
geerlingguy commented 4 years ago

Now attempting to use a settings.local.php file, with the generic settings.php added to the repository.

geerlingguy commented 4 years ago

Finally have install working, but getting some config sync validation errors:

          <div role="alert">
                  <h2 class="visually-hidden">Error message</h2>
                    <ul class="messages__list">
                      <li class="messages__item">The configuration synchronization failed validation.</li>
                      <li class="messages__item">Configuration <em class="placeholder">block.block.bartik_system_main</em> depends on the <em class="placeholder">Bartik</em> theme that will not be installed after import.</li>
                      <li class="messages__item">Configuration <em class="placeholder">block.block.bartik_user_login</em> depends on the <em class="placeholder">Bartik</em> theme that will not be installed after import.</li>
                      <li class="messages__item">Configuration <em class="placeholder">node.type.blog_post</em> depends on the <em class="placeholder">Menu UI</em> module that will not be installed after import.</li>
                      <li class="messages__item">Configuration <em class="placeholder">node.type.page</em> depends on the <em class="placeholder">Menu UI</em> module that will not be installed after import.</li>
                      <li class="messages__item">Configuration <em class="placeholder">node.type.project</em> depends on the <em class="placeholder">Menu UI</em> module that will not be installed after import.</li>
                  </ul>
                </div>
geerlingguy commented 4 years ago

Hopefully fixed via above commit. Had to enable Menu UI, delete the annoying blocks that keep popping up, and I've also trimmed down the Dockerfile so it should build much faster for now.

geerlingguy commented 4 years ago

Success! Now waiting on the last action to build, and if it does, merging this and away we go.