diff --git a/.github/actions/mysql-client-tests/action.yaml b/.github/actions/mysql-client-tests/action.yaml new file mode 100644 index 0000000000..4d89a8ceda --- /dev/null +++ b/.github/actions/mysql-client-tests/action.yaml @@ -0,0 +1,5 @@ +name: 'Dolt MySQL client integration tests' +description: 'Smoke tests for mysql client integrations' +runs: + using: 'docker' + image: '../../../MySQLDockerfile' diff --git a/.github/workflows/ci-mysql-client-tests.yaml b/.github/workflows/ci-mysql-client-tests.yaml new file mode 100644 index 0000000000..adfe2ed423 --- /dev/null +++ b/.github/workflows/ci-mysql-client-tests.yaml @@ -0,0 +1,13 @@ +name: Test MySQL Client integrations + +on: [pull_request] + +jobs: + mysql_client_integrations_job: + runs-on: ubuntu-latest + name: Run tests + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Test mysql client integrations + uses: ./.github/actions/mysql-client-tests diff --git a/mysql-client-tests/MySQLDockerfile b/MySQLDockerfile similarity index 71% rename from mysql-client-tests/MySQLDockerfile rename to MySQLDockerfile index d134320f5f..77abce6cf4 100644 --- a/mysql-client-tests/MySQLDockerfile +++ b/MySQLDockerfile @@ -1,5 +1,15 @@ +FROM golang:1.15.0-buster as builder +WORKDIR /root/building/go +COPY ./go/ . + +# install dolt from source +ENV GOFLAGS="-mod=readonly" +RUN go build -o dolt ./cmd/dolt + FROM ubuntu:18.04 -COPY . /mysql-client-tests +COPY --from=builder /root/building/go/dolt /usr/local/bin/dolt +COPY ./mysql-client-tests /mysql-client-tests +COPY ./mysql-client-tests-entrypoint.sh /mysql-client-tests/entrypoint.sh # install python ENV DEBIAN_FRONTEND=noninteractive @@ -20,8 +30,7 @@ RUN apt-get -y install curl RUN pip3 install mysql-connector-python RUN pip3 install PyMySQL -# install java -# Install OpenJDK-8 +# install OpenJDK-8 RUN apt-get update && \ apt-get install -y openjdk-8-jdk && \ apt-get install -y ant && \ @@ -48,23 +57,12 @@ RUN cat /etc/apt/sources.list.d/nodesource.list RUN apt -y install nodejs # install bats -RUN apt-get update -RUN apt-get install bats - -# install dolt TODO build from source -RUN curl -L https://github.com/liquidata-inc/dolt/releases/latest/download/install.sh | bash -RUN dolt version - -# setup dolt config -RUN dolt config --global --add metrics.disabled true -RUN dolt config --global --add metrics.host localhost -RUN dolt config --global --add user.name mysql-test-runner -RUN dolt config --global --add user.email mysql-test-runner@liquidata.co +RUN apt-get -y update +RUN apt-get -y install bats # install node deps WORKDIR /mysql-client-tests/node RUN npm install -# run tests WORKDIR /mysql-client-tests - +ENTRYPOINT ["/mysql-client-tests/entrypoint.sh"] diff --git a/mysql-client-tests-entrypoint.sh b/mysql-client-tests-entrypoint.sh new file mode 100755 index 0000000000..9ee3bc7e83 --- /dev/null +++ b/mysql-client-tests-entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "Updating dolt config for tests:" +dolt config --global --add metrics.disabled true +dolt config --global --add metrics.host localhost +dolt config --global --add user.name mysql-test-runner +dolt config --global --add user.email mysql-test-runner@liquidata.co + +echo "Running mysql-client-tests:" +bats /mysql-client-tests/mysql-client-tests.bats diff --git a/mysql-client-tests/README.md b/mysql-client-tests/README.md new file mode 100644 index 0000000000..071add29c5 --- /dev/null +++ b/mysql-client-tests/README.md @@ -0,0 +1,28 @@ +## MySQL Client Tests +We created smoke tests for Dolt's MySQL client integrations and we run these tests through Github Actions +on pull requests. + +These tests can be run locally using Docker. From the root directory of this repo, run: +```bash +$ docker build -t mysql-client-tests -f MySQLDockerfile . +$ docker run mysql-client-tests:latest +``` + +The `docker build` step will take a few minutes to complete as it needs to install all of the +dependencies in the image. + +Running the built container will produce output like: +```bash +$ docker run mysql-client-tests:latest +updating dolt config for tests: +Config successfully updated. +Config successfully updated. +Config successfully updated. +Config successfully updated. +Running mysql-client-tests: +1..4 +ok 1 python mysql.connector client +ok 2 python pymysql client +ok 3 mysql-connector-java client +ok 4 node mysql client +```