From 1376c6be032a46b396c6991133b958271604e829 Mon Sep 17 00:00:00 2001 From: Oliver Seemann Date: Fri, 22 Apr 2022 09:40:18 +0200 Subject: [PATCH] Run tests as GitHub Actions (#376) To easier find out when changes break the tests. - Use Python 3.7 for starters, because it's the oldest still-supported CPython interpreter version. More can be added in a subsequent step. - Use "docker compose" to run the Percona versions from the dev readme. Different MySQL implementations (e.g. MariaDB, Oracle, etc.) could be added on top. - The test suite is skipping `test_no_trailing_rotate_event` because it requires a different test setup, with access to the binlog files. - The test suite also skips `test_end_log_pos` for now, because it currently fails and the best solution wasn't obvious to me, the original author should have a look. --- .github/workflows/pytest.yml | 33 +++++++++++++++++++++++++++++++++ docker-compose.yml | 17 +++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/pytest.yml create mode 100644 docker-compose.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 00000000..44453d10 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,33 @@ +name: PyTest +on: push + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 2 + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.7" + + - name: Run database server in docker + run: | + docker compose create + docker compose start + # Wait for the services to accept connections, + # TODO: do that smarter, poll connection attempt until it succeeds + sleep 30 + + - name: Install dependencies + run: | + pip install . + pip install pytest + + - name: Run test suite + run: | + pytest -k "not test_no_trailing_rotate_event and not test_end_log_pos" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d6449d2c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.2' +services: + percona-5.7: + image: percona:5.7 + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: true + ports: + - 3306:3306 + command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates + + percona-5.7-ctl: + image: percona:5.7 + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: true + ports: + - 3307:3307 + command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307