diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..bcd47c1e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,68 @@ +name: Tests +on: [push, pull_request] +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.6' + - name: Install requirements + run: pip install flake8 pycodestyle + - name: Check syntax + run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ckan + - name: Run flake8 + run: flake8 . --count --max-line-length=127 --statistics --exclude ckan + + test: + needs: lint + strategy: + matrix: + ckan-version: [2.9, 2.9-py2, 2.8, 2.7] + fail-fast: false + + name: CKAN ${{ matrix.ckan-version }} + runs-on: ubuntu-latest + container: + image: openknowledge/ckan-dev:${{ matrix.ckan-version }} + services: + solr: + image: ckan/ckan-solr-dev:${{ matrix.ckan-version }} + postgres: + image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }} + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + redis: + image: redis:3 + env: + CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test + CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test + CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test + CKAN_SOLR_URL: http://solr:8983/solr/ckan + CKAN_REDIS_URL: redis://redis:6379/1 + + steps: + - uses: actions/checkout@v2 + - name: Install requirements + run: | + pip install -r pip-requirements.txt + pip install -r dev-requirements.txt + pip install -e . + # Replace default path to CKAN core config file with the one on the container + sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini + - name: Setup extension (CKAN >= 2.9) + if: ${{ matrix.ckan-version != '2.7' && matrix.ckan-version != '2.8' }} + run: | + ckan -c test.ini db init + ckan -c test.ini archiver init + - name: Setup extension (CKAN < 2.9) + if: ${{ matrix.ckan-version == '2.7' || matrix.ckan-version == '2.8' }} + run: | + paster --plugin=ckan db init -c test.ini + paster --plugin=ckanext-archiver archiver init -c test.ini + - name: Run tests + run: pytest --ckan-ini=test.ini --cov=ckanext.archiver --disable-warnings tests \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ce2f045f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: python -python: - - "2.7" -env: - - CKANVERSION=master - - CKANVERSION=2.6 - - CKANVERSION=2.7 - - CKANVERSION=2.8 -services: - - redis-server - - postgresql -install: - - bash bin/travis-build.bash - - pip install coveralls -script: sh bin/travis-run.sh -after_success: - - coveralls - -# the new trusty images of Travis cause build errors with psycopg2, see https://github.com/travis-ci/travis-ci/issues/8897 -dist: trusty -group: deprecated-2017Q4 - -stages: - - Flake8 - - test - -jobs: - include: - - stage: Flake8 - env: FLAKE8=True - install: - - bash bin/travis-build.bash - - pip install flake8==3.5.0 - - pip install pycodestyle==2.3.0 - script: - - flake8 --version - # stop the build if there are Python syntax errors or undefined names - - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ckan - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - - flake8 . --count --max-line-length=127 --statistics --exclude ckan diff --git a/dev-requirements.txt b/dev-requirements.txt index 48473f85..e4d62a15 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -2,3 +2,5 @@ flask==1.0.2 ProgressBar==2.3 nose mock +pytest-ckan +pytest-cov \ No newline at end of file