From b33ed4faaacda97a435a9887ebfc044eedb698da Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Mon, 8 Apr 2024 18:53:07 -0700 Subject: [PATCH 1/3] Format Dockerfile --- .github/workflows/{ci.yml => linux-build.yml} | 8 +++--- .../workflows/{macos.yml => macos-build.yml} | 0 Dockerfile | 26 ++++++++++++++----- test/mysql/Dockerfile | 1 + 4 files changed, 25 insertions(+), 10 deletions(-) rename .github/workflows/{ci.yml => linux-build.yml} (83%) rename .github/workflows/{macos.yml => macos-build.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/linux-build.yml similarity index 83% rename from .github/workflows/ci.yml rename to .github/workflows/linux-build.yml index 4d6ee163..af7369df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/linux-build.yml @@ -1,4 +1,4 @@ -name: CI +name: Linux on: push: @@ -9,8 +9,8 @@ on: pull_request: jobs: - build: - name: ${{ format('Build ({0}, {1}, {2})', matrix.mysql, matrix.distribution, matrix.ruby) }} + test: + name: ${{ format('Test (Ruby {0}, MySQL {1}, {2})', matrix.ruby, matrix.mysql, matrix.distribution) }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -24,7 +24,7 @@ jobs: 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 }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos-build.yml similarity index 100% rename from .github/workflows/macos.yml rename to .github/workflows/macos-build.yml diff --git a/Dockerfile b/Dockerfile index 91538556..d100618d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,31 @@ 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 +RUN apt-get update -qq \ + && apt-get install --yes --no-install-recommends \ + build-essential \ + ca-certificates \ + wget \ + libssl-dev \ + default-libmysqlclient-dev \ + clang clang-tools \ + llvm \ + valgrind \ + netcat RUN update-ca-certificates -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 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 -ARG RUBY_VERSION=3.2 RUN ruby-install --system ruby ${RUBY_VERSION} RUN ruby --version 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/ From b9899bed74c90327b53dbae483e2a5f1e0099f40 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Mon, 8 Apr 2024 19:40:26 -0700 Subject: [PATCH 2/3] Use ruby-build --- .github/workflows/linux-build.yml | 2 +- Dockerfile | 48 ++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index af7369df..41978c44 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -17,7 +17,7 @@ jobs: 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" diff --git a/Dockerfile b/Dockerfile index d100618d..2d281aa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,27 +7,53 @@ ARG RUBY_VERSION=3.2 # build phase, but not leak into the final image and run phase. ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update -qq \ +# Install system dependencies. +RUN apt-get update --quiet=2 \ + && apt-get install --quiet --yes \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg + +# Install Ruby dependencies. +RUN apt-get update --quiet=2 \ && apt-get install --yes --no-install-recommends \ + autoconf \ + bison \ + patch \ build-essential \ - ca-certificates \ - wget \ + 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 \ + clang \ + clang-tools \ llvm \ valgrind \ netcat RUN update-ca-certificates -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 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 . . From 589c854f8c9575d647db9b316ebd66293229c754 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 9 Apr 2024 09:11:33 -0700 Subject: [PATCH 3/3] Combine mac and linux into a single workflow --- .github/workflows/{macos-build.yml => ci.yml} | 36 ++++++++++++++++--- .github/workflows/linux-build.yml | 36 ------------------- 2 files changed, 31 insertions(+), 41 deletions(-) rename .github/workflows/{macos-build.yml => ci.yml} (65%) delete mode 100644 .github/workflows/linux-build.yml diff --git a/.github/workflows/macos-build.yml b/.github/workflows/ci.yml similarity index 65% rename from .github/workflows/macos-build.yml rename to .github/workflows/ci.yml index f24cf85a..aed9c1b9 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,5 @@ -name: macOS +name: CI + on: push: branches: @@ -8,8 +9,33 @@ on: pull_request: jobs: - test: - name: Test + 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.0"] + include: + - mysql: "5.7" + distribution: "debian:buster" + ruby: "2.7.8" + steps: + - uses: actions/checkout@v4 + - name: Docker login + run: echo $GITHUB_TOKEN | docker login ghcr.io --username trilogy --password-stdin + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run tests + env: + MYSQL_VERSION: ${{ matrix.mysql }} + 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: @@ -27,8 +53,8 @@ jobs: 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 + macos-test-ruby: + name: ${{ format('macOS Ruby (MySQL {0})', matrix.mysql) }} runs-on: macos-latest strategy: matrix: diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml deleted file mode 100644 index 41978c44..00000000 --- a/.github/workflows/linux-build.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Linux - -on: - push: - branches: - - main - tags: - - v* - pull_request: - -jobs: - test: - name: ${{ format('Test (Ruby {0}, MySQL {1}, {2})', matrix.ruby, matrix.mysql, matrix.distribution) }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - mysql: ["5.7", "8.0"] - distribution: ["debian:buster", "ubuntu:focal", "ubuntu:bionic"] - ruby: ["3.3.0"] - include: - - mysql: "5.7" - distribution: "debian:buster" - ruby: "2.7.8" - steps: - - uses: actions/checkout@v4 - - name: Docker login - run: echo $GITHUB_TOKEN | docker login ghcr.io --username trilogy --password-stdin - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Run tests - env: - MYSQL_VERSION: ${{ matrix.mysql }} - DISTRIBUTION: ${{ matrix.distribution }} - RUBY_VERSION: ${{ matrix.ruby }} - run: script/cibuild