|
| 1 | +name: Tests |
| 2 | +on: [push, pull_request] |
| 3 | +jobs: |
| 4 | + test: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + container: |
| 7 | + # The CKAN version tag of the Solr and Postgres containers should match |
| 8 | + # the one of the container the tests run on. |
| 9 | + # You can switch this base image with a custom image tailored to your project |
| 10 | + image: openknowledge/ckan-dev:2.9 |
| 11 | + services: |
| 12 | + solr: |
| 13 | + image: ckan/ckan-solr-dev:2.9 |
| 14 | + postgres: |
| 15 | + image: ckan/ckan-postgres-dev:2.9 |
| 16 | + env: |
| 17 | + POSTGRES_USER: postgres |
| 18 | + POSTGRES_PASSWORD: postgres |
| 19 | + POSTGRES_DB: postgres |
| 20 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 21 | + redis: |
| 22 | + image: redis:3 |
| 23 | + |
| 24 | + env: |
| 25 | + CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test |
| 26 | + CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test |
| 27 | + CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test |
| 28 | + CKAN_SOLR_URL: http://solr:8983/solr/ckan |
| 29 | + CKAN_REDIS_URL: redis://redis:6379/1 |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v2 |
| 33 | + - name: Install requirements |
| 34 | + # Install any extra requirements your extension has here (dev requirements, other extensions etc) |
| 35 | + run: | |
| 36 | + pip install -r requirements.txt |
| 37 | + pip install -r dev-requirements.txt |
| 38 | + pip install -e . |
| 39 | + - name: Setup extension |
| 40 | + # Extra initialization steps |
| 41 | + run: | |
| 42 | + # Replace default path to CKAN core config file with the one on the container |
| 43 | + sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini |
| 44 | +
|
| 45 | + ckan -c test.ini db init |
| 46 | + - name: Run tests |
| 47 | + run: pytest --ckan-ini=test.ini --cov=ckanext.generalpublic --disable-warnings ckanext/generalpublic |
| 48 | + |
0 commit comments