Skip to content

Commit

Permalink
Use mysql:8.0-debian image tag for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ngan committed Apr 6, 2024
1 parent 6892cd0 commit 854baac
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
mysql: ["5.7", "8"]
mysql: ["5.7", "8.0"]
distribution: ["debian:buster", "ubuntu:focal", "ubuntu:bionic"]
ruby: ["3.3"]
include:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
/trilogy
/test/test
/example/trilogy_query

# Ignore everything in the tmp directory except for the keep file.
/tmp/**/*
!/tmp/.keep
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
MYSQL_DATABASE: test
MYSQL_HOST: db.local
volumes:
- "db-data:/var/lib/mysql"
- "./tmp/mysql-certs:/mysql-certs"
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./test/auth_plugins/${MYSQL_VERSION}/auth_test_plugin.so:/usr/lib/mysql/plugin/auth_test_plugin.so
app:
Expand All @@ -22,20 +22,18 @@ services:
build:
context: .
args:
- BUILDKIT_INLINE_CACHE=1
- DISTRIBUTION=${DISTRIBUTION}
- RUBY_VERSION=${RUBY_VERSION}
cache_from:
- ghcr.io/trilogy-libraries/trilogy/ci-app:distro-${DISTRIBUTION_SLUG}-ruby-${RUBY_VERSION}-mysql-${MYSQL_VERSION}
environment:
MYSQL_HOST: db.local
TRILOGY_TEST_CERTS: "/db-data"
TRILOGY_TEST_CERTS: "/mysql-certs"
depends_on:
- db
links:
- "db:db.local"
- "db:wildcard.db.local"
volumes:
- "db-data:/db-data"

volumes:
db-data:
- "./tmp/mysql-certs:/mysql-certs"
9 changes: 8 additions & 1 deletion docker-entrypoint-initdb.d/generate_keys.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

cd /var/lib/mysql

Expand Down Expand Up @@ -51,3 +53,8 @@ openssl x509 -req -sha256 -CA ca.pem -CAkey ca-key.pem -set_serial 2 \
-days 365 \
-in client-csr.pem \
-out client-cert.pem

# Copy the certificates to the shared directory so that it's accessible from the app
# container.

cp /var/lib/mysql/*.pem /mysql-certs
13 changes: 10 additions & 3 deletions script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,29 @@ output_fold() {
function cleanup() {
echo
echo "::group::Shutting down services..."
docker compose down -v
docker compose down --volumes
echo "::endgroup::"
}

trap cleanup EXIT

export CI_MODE=true

if [ -z "$MYSQL_VERSION" ]; then export MYSQL_VERSION=8 ; fi
if [ -z "$MYSQL_VERSION" ]; then export MYSQL_VERSION=8.0 ; fi
if [ -z "$DISTRIBUTION" ]; then export DISTRIBUTION=debian:buster ; fi
if [ -z "$RUBY_VERSION" ]; then export RUBY_VERSION=3.2 ; fi

DISTRIBUTION_SLUG="$(echo "$DISTRIBUTION" | awk '{ gsub(":", "_") ; print $0 }')"
export DISTRIBUTION_SLUG

docker compose rm -s -f -v
# Prepare the shared directory where the certificates will be stored. We need to create
# and chmod this directory on the host so that the permissions are persisted when the
# the directory is mounted in the containers. Since the mysql container runs as a non-root
# user, we need to ensure that the directory is writable by all users.
mkdir tmp/mysql-certs
chmod 777 tmp/mysql-certs

docker compose rm --stop --force --volumes
output_fold "Pull cache image..." docker compose pull app || true
output_fold "Bootstrapping container..." docker compose build
output_fold "Running tests..." docker compose run --rm app
Expand Down
File renamed without changes.
Empty file added tmp/.keep
Empty file.

0 comments on commit 854baac

Please sign in to comment.