|
| 1 | +name: Tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - master |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - uses: actions/setup-python@v2 |
| 15 | + with: |
| 16 | + python-version: '3.6' |
| 17 | + - name: Install requirements |
| 18 | + run: pip install flake8 pycodestyle |
| 19 | + - name: Check syntax |
| 20 | + run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ckan |
| 21 | + |
| 22 | + test: |
| 23 | + needs: lint |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + ckan-version: [2.9, 2.9-py2, 2.8] |
| 27 | + fail-fast: false |
| 28 | + |
| 29 | + name: CKAN ${{ matrix.ckan-version }} |
| 30 | + runs-on: ubuntu-latest |
| 31 | + container: |
| 32 | + image: openknowledge/ckan-dev:${{ matrix.ckan-version }} |
| 33 | + services: |
| 34 | + solr: |
| 35 | + image: ckan/ckan-solr-dev:${{ matrix.ckan-version }} |
| 36 | + postgres: |
| 37 | + image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }} |
| 38 | + env: |
| 39 | + POSTGRES_USER: postgres |
| 40 | + POSTGRES_PASSWORD: postgres |
| 41 | + POSTGRES_DB: postgres |
| 42 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 43 | + redis: |
| 44 | + image: redis:3 |
| 45 | + env: |
| 46 | + CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test |
| 47 | + CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test |
| 48 | + CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test |
| 49 | + CKAN_SOLR_URL: http://solr:8983/solr/ckan |
| 50 | + CKAN_REDIS_URL: redis://redis:6379/1 |
| 51 | + |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v2 |
| 54 | + - name: Install extension |
| 55 | + run: | |
| 56 | + pip install -e . |
| 57 | + # Replace default path to CKAN core config file with the one on the container |
| 58 | + sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini |
| 59 | + - name: Setup extension (CKAN 2.9) |
| 60 | + if: ${{ matrix.ckan-version == '2.9' }} |
| 61 | + run: | |
| 62 | + pip install -r dev-requirements.py3.txt |
| 63 | + pip install -r requirements.py3.txt |
| 64 | + ckan -c test.ini db init |
| 65 | + - name: Setup extension (CKAN 2.9-py2) |
| 66 | + if: ${{ matrix.ckan-version == '2.9-py2' }} |
| 67 | + run: | |
| 68 | + pip install -r dev-requirements.py2.txt |
| 69 | + pip install -r requirements.py2.txt |
| 70 | + ckan -c test.ini db init |
| 71 | +
|
| 72 | + - name: Setup extension (CKAN 2.8) |
| 73 | + if: ${{ matrix.ckan-version == '2.8' }} |
| 74 | + run: | |
| 75 | + pip install -r dev-requirements.py2.txt |
| 76 | + pip install -r requirements.py2.txt |
| 77 | + paster --plugin=ckan db init -c test.ini |
| 78 | + - name: Run tests |
| 79 | + run: pytest --ckan-ini=test.ini --cov=ckanext.autz_service --disable-warnings ckanext/authz_service/tests |
0 commit comments