From ba96393eb98ab709a04dad520f70e91450d83b14 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 11:19:10 +0100 Subject: [PATCH 01/11] First pass at GitHub actions --- .github/workflows/test-suite.yml | 29 +++++++++++++++++++++++++++++ .travis.yml | 29 ----------------------------- scripts/install | 23 +++++++++-------------- scripts/test | 3 --- 4 files changed, 38 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/test-suite.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml new file mode 100644 index 00000000..5c201cc2 --- /dev/null +++ b/.github/workflows/test-suite.yml @@ -0,0 +1,29 @@ +--- +name: Test Suite + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + tests: + name: "Python ${{ matrix.python-version }}" + runs-on: "ubuntu-latest" + + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8"] + + steps: + - uses: "actions/checkout@v2" + - uses: "actions/setup-python@v1" + with: + python-version: "${{ matrix.python-version }}" + - name: "Install dependencies" + run: "scripts/install" + - name: "Run tests" + env: + TEST_DATABASE_URLS: "sqlite:///test.db" + run: "scripts/test" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 914dd9f8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: python - -dist: xenial - -cache: pip - -python: - - "3.6" - - "3.7" - -env: - - TEST_DATABASE_URLS="postgresql://localhost/test_database, mysql://localhost/test_database, sqlite:///test.db, postgresql+aiopg://localhost/test_database" - -services: - - postgresql - - mysql - -install: - - pip install -U -r requirements.txt - -before_script: - - psql -c 'create database test_database;' -U postgres - - echo 'create database test_database;' | mysql - -script: - - scripts/test - -after_script: - - codecov diff --git a/scripts/install b/scripts/install index d263b44f..65885a72 100755 --- a/scripts/install +++ b/scripts/install @@ -1,24 +1,19 @@ #!/bin/sh -e # Use the Python executable provided from the `-p` option, or a default. -[[ $1 = "-p" ]] && PYTHON=$2 || PYTHON="python3" - -MIN_VERSION="(3, 6)" -VERSION_OK=`"$PYTHON" -c "import sys; print(sys.version_info[0:2] >= $MIN_VERSION and '1' or '');"` - -if [[ -z "$VERSION_OK" ]] ; then - PYTHON_VERSION=`"$PYTHON" -c "import sys; print('%s.%s' % sys.version_info[0:2]);"` - DISP_MIN_VERSION=`"$PYTHON" -c "print('%s.%s' % $MIN_VERSION)"` - echo "ERROR: Python $PYTHON_VERSION detected, but $DISP_MIN_VERSION+ is required." - echo "Please upgrade your Python distribution to install Databases." - exit 1 -fi +[ "$1" = "-p" ] && PYTHON=$2 || PYTHON="python3" REQUIREMENTS="requirements.txt" VENV="venv" -PIP="$VENV/bin/pip" set -x -"$PYTHON" -m venv "$VENV" + +if [ -z "$GITHUB_ACTIONS" ]; then + "$PYTHON" -m venv "$VENV" + PIP="$VENV/bin/pip" +else + PIP="pip" +fi + "$PIP" install -r "$REQUIREMENTS" "$PIP" install -e . diff --git a/scripts/test b/scripts/test index 4a4fa4a3..4042539b 100755 --- a/scripts/test +++ b/scripts/test @@ -5,9 +5,6 @@ if [ -d 'venv' ] ; then export PREFIX="venv/bin/" fi -export VERSION_SCRIPT="import sys; print('%s.%s' % sys.version_info[0:2])" -export PYTHON_VERSION=`python -c "$VERSION_SCRIPT"` - if [ -z "$TEST_DATABASE_URLS" ] ; then echo "Variable TEST_DATABASE_URLS must be set." exit 1 From c3847ef813016c3d7b101b4aeba5be1bcd3076c9 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 11:42:10 +0100 Subject: [PATCH 02/11] Add mysql service --- .github/workflows/test-suite.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 5c201cc2..910dc60b 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -25,5 +25,15 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://localhost:${{ job.services.mysql.ports[3306] }}/testsuite" run: "scripts/test" + +services: + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: testsuite + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 From 3c0cb8268bc868bef341704fe02ed6b4bdef39d3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 11:43:45 +0100 Subject: [PATCH 03/11] Fix workflow --- .github/workflows/test-suite.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 910dc60b..3125a9c6 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -28,12 +28,12 @@ jobs: TEST_DATABASE_URLS: "sqlite:///test.db, mysql://localhost:${{ job.services.mysql.ports[3306] }}/testsuite" run: "scripts/test" -services: - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: testsuite - ports: - - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: testsuite + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 From 139cd0ccfff1c0f6d04d0bc54a0634d74503e93f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 11:58:33 +0100 Subject: [PATCH 04/11] Setup MYSQL_USER, MYSQL_PASSWORD --- .github/workflows/test-suite.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 3125a9c6..62bedae7 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -25,14 +25,15 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://localhost:${{ job.services.mysql.ports[3306] }}/testsuite" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://username:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite" run: "scripts/test" services: mysql: image: mysql:5.7 env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_USER: username + MYSQL_PASSWORD: password MYSQL_DATABASE: testsuite ports: - 3306 From f5a9a564e7aaf8427d7dfc704bc1be1202dfdf68 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:08:44 +0100 Subject: [PATCH 05/11] Tweak mysql service --- .github/workflows/test-suite.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 62bedae7..3dcf3d92 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -16,6 +16,16 @@ jobs: matrix: python-version: ["3.6", "3.7", "3.8"] + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: testsuite + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -25,16 +35,5 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://username:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite" run: "scripts/test" - - services: - mysql: - image: mysql:5.7 - env: - MYSQL_USER: username - MYSQL_PASSWORD: password - MYSQL_DATABASE: testsuite - ports: - - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 From f41cc92b84120ebaa0e320775af3e221e5ab520a Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:14:23 +0100 Subject: [PATCH 06/11] Add postgresql service --- .github/workflows/test-suite.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 3dcf3d92..a669373d 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -26,6 +26,16 @@ jobs: - 3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: username + POSTGRES_PASSWORD: password + POSTGRES_DB: testsuite + ports: + - 5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -35,5 +45,5 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite, postgresql://username:password@localhost:${{ job.services.postgresql.ports[5432] }}/testsuite" run: "scripts/test" From 9b8e612c940a1d1643fbb8e8cabf5bffc26fbb04 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:17:14 +0100 Subject: [PATCH 07/11] Fix Postgres PORT --- .github/workflows/test-suite.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index a669373d..4e751295 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -33,7 +33,7 @@ jobs: POSTGRES_PASSWORD: password POSTGRES_DB: testsuite ports: - - 5432 + - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: @@ -45,5 +45,5 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite, postgresql://username:password@localhost:${{ job.services.postgresql.ports[5432] }}/testsuite" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite, postgresql://username:password@localhost:5432/testsuite" run: "scripts/test" From 6057aed7d6543dcd7abf0509515b16193864fea1 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:20:09 +0100 Subject: [PATCH 08/11] Add aiopg to test suite --- .github/workflows/test-suite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 4e751295..a6b99b53 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -45,5 +45,5 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite, postgresql://username:password@localhost:5432/testsuite" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite, postgresql://username:password@localhost:5432/testsuite, postgresql+aiopg://username:password@localhost:5432/testsuite" run: "scripts/test" From fb1d49d3ed5d4fffacdd9a64c2c8626509fe7735 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:22:44 +0100 Subject: [PATCH 09/11] Expose MySQL on default port --- .github/workflows/test-suite.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index a6b99b53..14f8127c 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -23,7 +23,7 @@ jobs: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: testsuite ports: - - 3306 + - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 postgres: @@ -45,5 +45,5 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/testsuite, postgresql://username:password@localhost:5432/testsuite, postgresql+aiopg://username:password@localhost:5432/testsuite" + TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:3306/testsuite, postgresql://username:password@localhost:5432/testsuite, postgresql+aiopg://username:password@localhost:5432/testsuite" run: "scripts/test" From e1d0118d75303d626c8c68fa801dcefdca800069 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:39:42 +0100 Subject: [PATCH 10/11] Tweak workflow --- .github/workflows/test-suite.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 14f8127c..b9ef7a65 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -20,7 +20,8 @@ jobs: mysql: image: mysql:5.7 env: - MYSQL_ROOT_PASSWORD: password + MYSQL_USER: username + MYSQL_PASSWORD: password MYSQL_DATABASE: testsuite ports: - 3306:3306 @@ -45,5 +46,5 @@ jobs: run: "scripts/install" - name: "Run tests" env: - TEST_DATABASE_URLS: "sqlite:///test.db, mysql://root:password@localhost:3306/testsuite, postgresql://username:password@localhost:5432/testsuite, postgresql+aiopg://username:password@localhost:5432/testsuite" + TEST_DATABASE_URLS: "sqlite:///testsuite, mysql://username:password@localhost:3306/testsuite, postgresql://username:password@localhost:5432/testsuite, postgresql+aiopg://username:password@localhost:5432/testsuite" run: "scripts/test" From c3ee0a353d96e63cb71515260a095bbe7f1381fa Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 25 Apr 2020 12:42:25 +0100 Subject: [PATCH 11/11] Add MYSQL_ROOT_PASSWORD --- .github/workflows/test-suite.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index b9ef7a65..207ec1c3 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -22,6 +22,7 @@ jobs: env: MYSQL_USER: username MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: testsuite ports: - 3306:3306