Skip to content

tests: Add Github Actions tests #24

tests: Add Github Actions tests

tests: Add Github Actions tests #24

Workflow file for this run

name: Tests
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
container:
image: python:2.7.18-buster
steps:
- uses: actions/checkout@v3
- name: Install requirements
run: pip install flake8 pycodestyle
- name: Check syntax
run: flake8 --statistics --show-source ckanext
test:
needs: lint
strategy:
matrix:
ckan-version: [2.8]
fail-fast: false
name: CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
services:
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
CKAN_SITE_URL: http://test.ckan.net
WORKDIR: /__w/ckanext-geocat/ckanext-geocat
SOLR_CONFIG_CKAN_DIR: /opt/solr/server/solr/configsets/ckan/conf
steps:
- uses: actions/checkout@v3
- name: Create solr container
run: |
git clone https://github.com/opendata-swiss/ckanext-switzerland-ng.git
docker create --name test_solr --network ${{ job.container.network }} --network-alias solr \
--workdir $WORKDIR --publish 8983:8983 \
-e "SOLR_HEAP=1024m" -e "SOLR_SCHEMA_FILE=$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-e GITHUB_ACTIONS=true -e CI=true \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/schema.xml":"$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/english_stop.txt":"$SOLR_CONFIG_CKAN_DIR/english_stop.txt" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/fr_elision.txt":"$SOLR_CONFIG_CKAN_DIR/fr_elision.txt" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/french_stop.txt":"$SOLR_CONFIG_CKAN_DIR/french_stop.txt" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/german_dictionary.txt":"$SOLR_CONFIG_CKAN_DIR/german_dictionary.txt" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/german_stop.txt":"$SOLR_CONFIG_CKAN_DIR/german_stop.txt" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/italian_stop.txt":"$SOLR_CONFIG_CKAN_DIR/italian_stop.txt" \
-v "${{ github.workspace }}/ckanext-switzerland-ng/solr/solrconfig.xml":"$SOLR_CONFIG_CKAN_DIR/solrconfig.xml" \
ckan/ckan-solr:${{ matrix.ckan-version }}
docker start test_solr
- name: Create ckan container
run: |
docker create --name test_ckan --network ${{ job.container.network }} --network-alias ckan \
-e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" \
-v "/home/runner/work":"/__w" -v "/home/runner/work/_temp":"/__w/_temp" \
-v "/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" \
-v "/home/runner/work/_temp/_github_home":"/github/home" \
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
--entrypoint "tail" openknowledge/ckan-dev:${{ matrix.ckan-version }} "-f" "/dev/null"
docker start test_ckan
- name: Install requirements and set up database
run: |
docker exec test_ckan $WORKDIR/bin/install_test_requirements.sh ${{ matrix.ckan-version }}
- name: Run tests
run: |
docker exec test_ckan nosetests --ckan --nocapture --nologcapture --with-pylons=$WORKDIR/test.ini \
--with-coverage --cover-package=ckanext.geocat --cover-inclusive --cover-erase --cover-tests $WORKDIR/ckanext/geocat