diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d6ee163..aed9c1b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,22 +9,22 @@ on: pull_request: jobs: - build: - name: ${{ format('Build ({0}, {1}, {2})', matrix.mysql, matrix.distribution, matrix.ruby) }} + linux-test: + name: ${{ format('{0} (Ruby {1}, MySQL {2})', matrix.distribution, matrix.ruby, matrix.mysql) }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: mysql: ["5.7", "8.0"] distribution: ["debian:buster", "ubuntu:focal", "ubuntu:bionic"] - ruby: ["3.3"] + ruby: ["3.3.0"] include: - mysql: "5.7" distribution: "debian:buster" ruby: "2.7.8" steps: - uses: actions/checkout@v4 - - name: docker login + - name: Docker login run: echo $GITHUB_TOKEN | docker login ghcr.io --username trilogy --password-stdin env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -34,3 +34,51 @@ jobs: DISTRIBUTION: ${{ matrix.distribution }} RUBY_VERSION: ${{ matrix.ruby }} run: script/cibuild + macos-test: + name: ${{ format('macOS (MySQL {0})', matrix.mysql) }} + runs-on: macos-latest + strategy: + matrix: + mysql: ["5.7", "8.0"] + steps: + - uses: actions/checkout@v4 + - name: Setup MySQL + run: | + brew install mysql@${{ matrix.mysql }} + (unset CI; brew postinstall mysql@${{ matrix.mysql }}) + brew services start mysql@${{ matrix.mysql }} + sleep 5 + $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test' + - name: Build + run: CFLAGS="-I$(brew --prefix openssl@1.1)/include" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" make all test/test + - name: test + run: test/test + macos-test-ruby: + name: ${{ format('macOS Ruby (MySQL {0})', matrix.mysql) }} + runs-on: macos-latest + strategy: + matrix: + mysql: ["5.7", "8.0"] + steps: + - uses: actions/checkout@v4 + - name: Setup MySQL + env: + MYSQL_VERSION: ${{ matrix.mysql }} + run: | + brew install mysql@${{ matrix.mysql }} + (unset CI; brew postinstall mysql@${{ matrix.mysql }}) + brew services start mysql@${{ matrix.mysql }} + sleep 5 + $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test' + [[ "$MYSQL_VERSION" == "8.0" ]] && $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/caching_sha2_password_user.sql + $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/native_password_user.sql + $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/x509_user.sql + $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/cleartext_user.sql + - name: Install dependencies + run: | + cd contrib/ruby + bundle --without benchmark + - name: Run tests + run: | + cd contrib/ruby + bundle exec rake diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index f24cf85a..00000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: macOS -on: - push: - branches: - - main - tags: - - v* - pull_request: - -jobs: - test: - name: Test - runs-on: macos-latest - strategy: - matrix: - mysql: ["5.7", "8.0"] - steps: - - uses: actions/checkout@v4 - - name: Setup MySQL - run: | - brew install mysql@${{ matrix.mysql }} - (unset CI; brew postinstall mysql@${{ matrix.mysql }}) - brew services start mysql@${{ matrix.mysql }} - sleep 5 - $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test' - - name: Build - run: CFLAGS="-I$(brew --prefix openssl@1.1)/include" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" make all test/test - - name: test - run: test/test - test-ruby: - name: Test Ruby - runs-on: macos-latest - strategy: - matrix: - mysql: ["5.7", "8.0"] - steps: - - uses: actions/checkout@v4 - - name: Setup MySQL - env: - MYSQL_VERSION: ${{ matrix.mysql }} - run: | - brew install mysql@${{ matrix.mysql }} - (unset CI; brew postinstall mysql@${{ matrix.mysql }}) - brew services start mysql@${{ matrix.mysql }} - sleep 5 - $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot -e 'CREATE DATABASE test' - [[ "$MYSQL_VERSION" == "8.0" ]] && $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/caching_sha2_password_user.sql - $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/native_password_user.sql - $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/x509_user.sql - $(brew --prefix mysql@${{ matrix.mysql }})/bin/mysql -uroot < test/mysql/docker-entrypoint-initdb.d/cleartext_user.sql - - name: Install dependencies - run: | - cd contrib/ruby - bundle --without benchmark - - name: Run tests - run: | - cd contrib/ruby - bundle exec rake diff --git a/Dockerfile b/Dockerfile index 91538556..2d281aa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,59 @@ ARG DISTRIBUTION=ubuntu:jammy + FROM ${DISTRIBUTION} LABEL maintainer="github@github.com" +ARG RUBY_VERSION=3.2 +# 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 -RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y build-essential ca-certificates wget libssl-dev default-libmysqlclient-dev clang clang-tools llvm valgrind netcat +# Install system dependencies. +RUN apt-get update --quiet=2 \ + && apt-get install --quiet --yes \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg -RUN update-ca-certificates +# Install Ruby dependencies. +RUN apt-get update --quiet=2 \ + && apt-get install --yes --no-install-recommends \ + autoconf \ + bison \ + patch \ + build-essential \ + rustc \ + libssl-dev \ + libyaml-dev \ + libreadline-dev \ + zlib1g-dev \ + libgmp-dev \ + libncurses-dev \ + libffi-dev \ + libgdbm-dev \ + libdb-dev \ + uuid-dev \ + # Other dependencies... + default-libmysqlclient-dev \ + clang \ + clang-tools \ + llvm \ + valgrind \ + netcat -RUN wget https://github.com/postmodern/ruby-install/releases/download/v0.9.0/ruby-install-0.9.0.tar.gz && \ - tar -xzvf ruby-install-0.9.0.tar.gz && \ - cd ruby-install-0.9.0/ && \ - make install +RUN update-ca-certificates -ARG RUBY_VERSION=3.2 -RUN ruby-install --system ruby ${RUBY_VERSION} -RUN ruby --version +RUN if which ruby >/dev/null 2>&1; then \ + echo "Ruby is already installed: $(ruby --version)"; \ + else \ + curl --location \ + "https://github.com/rbenv/ruby-build/archive/refs/tags/$(basename $(curl --location --silent --output /dev/null --write-out %{url_effective} https://github.com/rbenv/ruby-build/releases/latest)).tar.gz" \ + | tar --extract --gzip \ + && PREFIX=/usr/local ./ruby-build-*/install.sh \ + && rm -rf ./ruby-build-*/install.sh \ + && ruby-build ${RUBY_VERSION} /usr/local \ + && echo "Installed Ruby: $(ruby --version)"; \ + fi WORKDIR /app COPY . . diff --git a/test/mysql/Dockerfile b/test/mysql/Dockerfile index d60ee325..6cd5594e 100644 --- a/test/mysql/Dockerfile +++ b/test/mysql/Dockerfile @@ -20,4 +20,5 @@ RUN set -eux \ # This is the final stage inwhich we copy the plugins from the test stage. Doing it this way allows # us to not have to install the test package in the final image since we only need the plugins. FROM mysql:${MYSQL_VERSION}-debian +LABEL maintainer="github@github.com" COPY --from=0 /usr/lib/mysql/plugin/ /usr/lib/mysql/plugin/