Commit 2495afc4 authored by David Read's avatar David Read
Browse files

Add Travis CI setup and generally refresh from ckanext template.

parent 4cb5c78d
*.pyc
*.swp
*egg-info
.ropeproject
node_modules
bower_components
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
sdist/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Sphinx documentation
docs/_build/
\ No newline at end of file
language: python
sudo: required
# use an older trusty image, because the newer images cause build errors with
# psycopg2 that comes with CKAN<2.8:
#  "Error: could not determine PostgreSQL version from '10.1'"
# see https://github.com/travis-ci/travis-ci/issues/8897
dist: trusty
group: deprecated-2017Q4
# matrix
python:
- 2.7
env:
- CKANVERSION=master
- CKANVERSION=2.7
- CKANVERSION=2.8
# tests
services:
- postgresql
- redis-server
install:
- bash bin/travis-build.bash
- pip install coveralls
script: sh bin/travis-run.sh
after_success:
- coveralls
# additional jobs
matrix:
include:
- name: "Flake8 on Python 3.7"
dist: xenial # required for Python 3.7
cache: pip
install: pip install flake8
script:
- flake8 --version
- flake8 . --count --max-complexity=10 --max-line-length=127 --statistics --exclude ckan,ckanext-hierarchy
python: 3.7
# overwrite matrix
env:
- FLAKE8=true
- CKANVERSION=master
\ No newline at end of file
GNU AFFERO GENERAL PUBLIC LICENSE
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
......
recursive-include ckanext/hierarchy/public *
recursive-include ckanext/hierarchy/templates *
recursive-include ckanext/hierarchy/fanstatic *
include README.rst
include LICENSE
include requirements.txt
recursive-include ckanext/hierarchy *.html *.json *.js *.less *.css *.mo
[![Travis CI status](https://travis-ci.org/davidread/ckanext-hierarchy.svg?branch=master)](https://travis-ci.org//ckanext-hierarchy)
[![Latest version on pypi](https://img.shields.io/pypi/v/ckanext-hierarchy.svg)](https://pypi.org/project/ckanext-hierarchy/)
[![License](https://img.shields.io/pypi/l/ckanext-hierarchy.svg)](https://pypi.org/project/ckanext-hierarchy/)
# ckanext-hierarchy - Organization hierarchy for CKAN
Organizations can be arranged into a tree hierarchy.
......@@ -13,7 +21,7 @@ organization:
When viewing an organization you see its context within the tree in the side bar. In addition you can widen search of the organization's datasets to include datasets in sub-organizations too:
![Screenshot of organization page](screenshots/org_page.png)
## Detail
## Technical details
Forms (hierachy_form plugin):
* /organization/new
......@@ -63,23 +71,85 @@ the short name or acronym (more convenient for display).
TODO:
* make the trees prettier with JSTree
## Compatibility
## Requirements
This extension requires CKAN v2.7 or later.
## Installation
Install the extension in your python environment
```
$ . /usr/lib/ckan/default/bin/activate
(pyenv) $ cd /usr/lib/ckan/default/src
(pyenv) $ pip install -e "git+https://github.com/davidread/ckanext-hierarchy.git#egg=ckanext-hierarchy"
```
Then change your CKAN ini file (e.g. development.ini or production.ini). Note that hierarchy_display
To install ckanext-hierarchy:
1. Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
2. Install the ckanext-hierarchy Python package into your virtual environment:
cd /usr/lib/ckan/default/src
pip install -e "git+https://github.com/davidread/ckanext-hierarchy.git#egg=ckanext-hierarchy"
3. Add ``hierarchy_display`` and ``hierarchy_form`` to the ``ckan.plugins`` setting in your CKAN
config file (by default the config file is located at
``/etc/ckan/default/production.ini``). Note that hierarchy_display
should come before hierarchy_form
```
ckan.plugins = stats text_view recline_view ... hierarchy_display hierarchy_form
```
e.g.:
ckan.plugins = stats text_view recline_view ... hierarchy_display hierarchy_form
4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
## Config settings
None at present
## Tests
To run the tests, do::
nosetests --nologcapture --with-pylons=test.ini
To run the tests and produce a coverage report, first make sure you have
coverage installed in your virtualenv (``pip install coverage``) then run::
nosetests --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.hierarchy --cover-inclusive --cover-erase --cover-tests
## Releasing a new version of ckanext-hierarchy
ckanext-hierarchy should be available on PyPI as https://pypi.org/project/ckanext-hierarchy.
To publish a new version to PyPI follow these steps:
1. Update the version number in the ``setup.py`` file.
See `PEP 440 <http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers>`_
for how to choose version numbers.
2. Make sure you have the latest version of necessary packages:
pip install --upgrade setuptools wheel twine
3. Create a source and binary distributions of the new version:
python setup.py sdist bdist_wheel && twine check dist/*
Fix any errors you get.
4. Upload the source distribution to PyPI:
twine upload dist/*
5. Commit any outstanding changes:
git commit -a
6. Tag the new release of the project on GitHub with the version number from
the ``setup.py`` file. For example if the version number in ``setup.py`` is
0.0.1 then do:
git tag 0.0.1
git push --tags
## Licence and copyright
......
#!/bin/bash
set -e
echo "This is travis-build.bash..."
echo "Installing the packages that CKAN requires..."
sudo apt-get update -qq
sudo apt-get install solr-jetty
echo "Installing CKAN and its Python dependencies..."
git clone https://github.com/ckan/ckan
cd ckan
if [ $CKANVERSION == 'master' ]
then
echo "CKAN version: master"
else
CKAN_TAG=$(git tag | grep ^ckan-$CKANVERSION | sort --version-sort | tail -n 1)
git checkout $CKAN_TAG
echo "CKAN version: ${CKAN_TAG#ckan-}"
fi
# install the recommended version of setuptools
if [ -f requirement-setuptools.txt ]
then
echo "Updating setuptools..."
pip install -r requirement-setuptools.txt
fi
if [ $CKANVERSION == '2.7' ]
then
echo "Installing setuptools"
pip install setuptools==39.0.1
fi
python setup.py develop
pip install -r requirements.txt
pip install -r dev-requirements.txt
cd -
echo "Creating the PostgreSQL user and database..."
sudo -u postgres psql -c "CREATE USER ckan_default WITH PASSWORD 'pass';"
sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckan_default;'
echo "Setting up Solr..."
# Solr is multicore for tests on ckan master, but it's easier to run tests on
# Travis single-core. See https://github.com/ckan/ckan/issues/2972
sed -i -e 's/solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' ckan/test-core.ini
printf "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
sudo service jetty restart
echo "Initialising the database..."
cd ckan
paster db init -c test-core.ini
cd -
echo "Installing ckanext-hierarchy and its requirements..."
python setup.py develop
pip install -r dev-requirements.txt
echo "Moving test.ini into a subdir..."
mkdir subdir
mv test.ini subdir
echo "travis-build.bash is done."
\ No newline at end of file
#!/bin/sh -e
set -ex
flake8 --version
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ckan,ckanext-hierarchy
nosetests --ckan \
--nologcapture \
--with-pylons=subdir/test.ini \
--with-coverage \
--cover-package=ckanext.hierarchy \
--cover-inclusive \
--cover-erase \
--cover-tests
# strict linting
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics --exclude ckan,ckanext-hierarchy
\ No newline at end of file
# encoding: utf-8
# this is a namespace package
try:
import pkg_resources
......
# encoding: utf-8
# this is a namespace package
try:
import pkg_resources
......
flake8 # for the travis build
\ No newline at end of file
[extract_messages]
keywords = translate isPlural
add_comments = TRANSLATORS:
output_file = ckanext/hierarchy/i18n/ckanext-hierarchy.pot
width = 80
[init_catalog]
domain = ckanext-hierarchy
input_file = ckanext/hierarchy/i18n/ckanext-hierarchy.pot
output_dir = ckanext/hierarchy/i18n
[update_catalog]
domain = ckanext-hierarchy
input_file = ckanext/hierarchy/i18n/ckanext-hierarchy.pot
output_dir = ckanext/hierarchy/i18n
previous = true
[compile_catalog]
domain = ckanext-hierarchy
directory = ckanext/hierarchy/i18n
statistics = true
\ No newline at end of file
from setuptools import setup, find_packages
import sys, os
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages # Always prefer setuptools over distutils
from codecs import open # To use a consistent encoding
from os import path
version = '0.1'
here = path.abspath(path.dirname(__file__))
# Get the long description from the relevant file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='ckanext-hierarchy',
version=version,
description="CKAN Organization hierarchy - templates and configuration",
long_description="""\
""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='',
author='David Read',
author_email='david.read@hackneyworkshop.com',
url='',
license='Affero General Public License (AGPL)',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
namespace_packages=['ckanext'],
include_package_data=True,
zip_safe=False,
install_requires=[
# -*- Extra requirements: -*-
],
entry_points=\
"""
name='''ckanext-hierarchy''',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# http://packaging.python.org/en/latest/tutorial.html#version
version='0.1',
description='''CKAN Organization hierarchy - templates and configuration''',
long_description=long_description,
# The project's main homepage.
url='https://github.com/davidread/ckanext-hierarchy',
# Author details
author='''David Read''',
author_email='''david.read@hackneyworkshop.com''',
# Choose your license
license='AGPL',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2.7',
],
# What does your project relate to?
keywords='''CKAN''',
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
namespace_packages=['ckanext'],
install_requires=[
# CKAN extensions should not list dependencies here, but in a separate
# ``requirements.txt`` file.
#
# http://docs.ckan.org/en/latest/extensions/best-practices.html#add-third-party-libraries-to-requirements-txt
],
# If there are data files included in your packages that need to be
# installed, specify them here. If using Python 2.6 or less, then these
# have to be included in MANIFEST.in as well.
include_package_data=True,
package_data={
},
# Although 'package_data' is the preferred approach, in some case you may
# need to place data files outside of your packages.
# see http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
data_files=[],
# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# pip to create the appropriate form of executable for the target platform.
entry_points='''
[ckan.plugins]
hierarchy_display=ckanext.hierarchy.plugin:HierarchyDisplay
hierarchy_form=ckanext.hierarchy.plugin:HierarchyForm
""",
[babel.extractors]
ckan = ckan.lib.extract:extract_ckan
''',
# If you are changing from the default layout of your extension, you may
# have to change the message extractors, you can read more about babel
# message extraction at
# http://babel.pocoo.org/docs/messages/#extraction-method-mapping-and-configuration
message_extractors={
'ckanext': [
('**.py', 'python', None),
('**.js', 'javascript', None),
('**/templates/**.html', 'ckan', None),
],
}
)
......@@ -11,8 +11,6 @@ port = 5000
[app:main]
use = config:../ckan/test-core.ini
solr_url = http://127.0.0.1:8983/solr
# Insert any custom config settings to be used when running your extension's
# tests here.
ckan.plugins = hierarchy_display hierarchy_form
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment