diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c583649b..4d6ee163 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/Dockerfile.mysql b/Dockerfile.mysql new file mode 100644 index 00000000..f36bbedd --- /dev/null +++ b/Dockerfile.mysql @@ -0,0 +1,38 @@ +ARG MYSQL_VERSION + +FROM mysql:${MYSQL_VERSION}-debian +# Make all apt-get commands non-interactive. Setting this as an ARG will apply to the entire +# build phase, but not leak into the final image and run phase. +ARG DEBIAN_FRONTEND=noninteractive + +# MySQL 5.7 has been EOL'd and is no longer being built by the official mysql docker maintainers: +# https://github.com/docker-library/mysql/pull/1019 +# As such, if we want to add to it, we'll need to update the keyring ourselves. +RUN if [ "${MYSQL_MAJOR}" = "5.7" ]; then \ + set -eux; \ + # pub rsa4096 2023-10-23 [SC] [expires: 2025-10-22] + # BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C + # uid [ unknown] MySQL Release Engineering + # sub rsa4096 2023-10-23 [E] [expires: 2025-10-22] + key='BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C'; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \ + mkdir -p /etc/apt/keyrings; \ + gpg --batch --export "$key" > /etc/apt/keyrings/mysql.gpg; \ + gpgconf --kill all; \ + rm -rf "$GNUPGHOME"; \ + fi + +# Install the MySQL test package so that we can utilize test plugins. +# https://github.com/docker-library/mysql/issues/1040 +RUN set -eux \ + # Install MySQL test package. + && apt-get update \ + && apt-get install --yes mysql-community-test \ + # Clean up apt-get cache. + && rm -rf /var/lib/apt/lists/* \ + # Remove all data directories so that the entrypoint can initialize them. + && rm -rf /var/lib/mysql \ + && mkdir -p /var/lib/mysql /var/run/mysqld \ + && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ + && chmod 1777 /var/run/mysqld /var/lib/mysql diff --git a/docker-compose.yml b/docker-compose.yml index a15d2221..e69c8906 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,20 @@ services: db: platform: linux/x86_64 - image: "mysql:${MYSQL_VERSION}-debian" + image: "ghcr.io/trilogy-libraries/trilogy/ci-mysql:${MYSQL_VERSION}-debian" command: - --sql_mode=NO_ENGINE_SUBSTITUTION - --server-id=1 - --gtid-mode=ON - --enforce-gtid-consistency=ON - --log-bin=mysql-bin.log + build: + context: . + dockerfile: Dockerfile.mysql + args: + - MYSQL_VERSION=${MYSQL_VERSION} + cache_from: + - ghcr.io/trilogy-libraries/trilogy/ci-mysql:${MYSQL_VERSION}-debian environment: MYSQL_ALLOW_EMPTY_PASSWORD: 1 MYSQL_DATABASE: test @@ -15,7 +22,6 @@ services: volumes: - "db-data:/var/lib/mysql" - ./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: image: ghcr.io/trilogy-libraries/trilogy/ci-app:distro-${DISTRIBUTION_SLUG}-ruby-${RUBY_VERSION}-mysql-${MYSQL_VERSION} privileged: true diff --git a/script/cibuild b/script/cibuild index b56598c6..a0fb64d5 100755 --- a/script/cibuild +++ b/script/cibuild @@ -43,7 +43,7 @@ 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 @@ -51,7 +51,7 @@ DISTRIBUTION_SLUG="$(echo "$DISTRIBUTION" | awk '{ gsub(":", "_") ; print $0 }') export DISTRIBUTION_SLUG docker compose rm -s -f -v -output_fold "Pull cache image..." docker compose pull app || true +output_fold "Pull cache image..." docker compose pull app db || true output_fold "Bootstrapping container..." docker compose build output_fold "Running tests..." docker compose run --rm app -output_fold "Pushing cache image..." docker compose push app || true # Don't fail if push fails +output_fold "Pushing cache image..." docker compose push app db || true # Don't fail if push fails diff --git a/test/auth_plugins/5.7/auth_test_plugin.so b/test/auth_plugins/5.7/auth_test_plugin.so deleted file mode 100755 index fc4fc1f1..00000000 Binary files a/test/auth_plugins/5.7/auth_test_plugin.so and /dev/null differ diff --git a/test/auth_plugins/8/auth_test_plugin.so b/test/auth_plugins/8/auth_test_plugin.so deleted file mode 100644 index 5b990734..00000000 Binary files a/test/auth_plugins/8/auth_test_plugin.so and /dev/null differ