Skip to content

Instantly share code, notes, and snippets.

@bellisk
Last active June 20, 2023 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bellisk/949ea041369ad512f6e07c065fc14083 to your computer and use it in GitHub Desktop.
Save bellisk/949ea041369ad512f6e07c065fc14083 to your computer and use it in GitHub Desktop.
name: Tests
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
ckan-version: ["2.10", 2.9]
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
ports:
- 5432:5432
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
WORKDIR: /__w/ckanext-example/ckanext-example
SOLR_CONFIG_CKAN_DIR: /opt/solr/server/solr/configsets/ckan/conf
steps:
- uses: actions/checkout@v3
- name: Create solr container
run: |
/usr/bin/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 }}/solr/schema.xml":"$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-v "${{ github.workspace }}/solr/german_dictionary.txt":"$SOLR_CONFIG_CKAN_DIR/german_dictionary.txt" \
-v "${{ github.workspace }}/solr/solrconfig.xml":"$SOLR_CONFIG_CKAN_DIR/solrconfig.xml" \
ckan/ckan-solr:${{ matrix.ckan-version }}
docker start test_solr
- name: Create ckan container
run: |
/usr/bin/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 ckanext
run: |
docker exec test_ckan $WORKDIR/bin/install_test_requirements.sh ${{ matrix.ckan-version }}
- name: Run tests
run: |
docker exec test_ckan pytest --ckan-ini=$WORKDIR/test.ini \
--cov=ckanext.example--disable-warnings $WORKDIR/ckanext/example/tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment