diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml new file mode 100644 index 00000000..207ec1c3 --- /dev/null +++ b/.github/workflows/test-suite.yml @@ -0,0 +1,51 @@ +--- +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"] + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_USER: username + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: testsuite + ports: + - 3306: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: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" + with: + python-version: "${{ matrix.python-version }}" + - name: "Install dependencies" + run: "scripts/install" + - name: "Run tests" + env: + 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" 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