test.yml 2.5 KB

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