Skip to content

Commit

Permalink
Create barebone structure
Browse files Browse the repository at this point in the history
  • Loading branch information
duskobogdanovski committed Oct 27, 2020
0 parents commit 5dedc9e
Show file tree
Hide file tree
Showing 21 changed files with 1,135 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[report]
omit =
*/site-packages/*
*/python?.?/*
ckan/*
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.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/
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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-saml2auth
python: 3.7
# overwrite matrix
env:
- FLAKE8=true
- CKANVERSION=master
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.rst
include LICENSE
include requirements.txt
recursive-include ckanext/saml2auth *.html *.json *.js *.less *.css *.mo
146 changes: 146 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
.. You should enable this project on travis-ci.org and coveralls.io to make
these badges work. The necessary Travis and Coverage config files have been
generated for you.
.. image:: https://travis-ci.org/duskobogdanovski/ckanext-saml2auth.svg?branch=master
:target: https://travis-ci.org/duskobogdanovski/ckanext-saml2auth

.. image:: https://coveralls.io/repos/duskobogdanovski/ckanext-saml2auth/badge.svg
:target: https://coveralls.io/r/duskobogdanovski/ckanext-saml2auth

.. image:: https://img.shields.io/pypi/v/ckanext-saml2auth.svg
:target: https://pypi.org/project/ckanext-saml2auth/
:alt: Latest Version

.. image:: https://img.shields.io/pypi/pyversions/ckanext-saml2auth.svg
:target: https://pypi.org/project/ckanext-saml2auth/
:alt: Supported Python versions

.. image:: https://img.shields.io/pypi/status/ckanext-saml2auth.svg
:target: https://pypi.org/project/ckanext-saml2auth/
:alt: Development Status

.. image:: https://img.shields.io/pypi/l/ckanext-saml2auth.svg
:target: https://pypi.org/project/ckanext-saml2auth/
:alt: License

=============
ckanext-saml2auth
=============

.. Put a description of your extension here:
What does it do? What features does it have?
Consider including some screenshots or embedding a video!
------------
Requirements
------------

For example, you might want to mention here which versions of CKAN this
extension works with.


------------
Installation
------------

.. Add any additional install steps to the list below.
For example installing any non-Python dependencies or adding any required
config settings.
To install ckanext-saml2auth:

1. Activate your CKAN virtual environment, for example::

. /usr/lib/ckan/default/bin/activate

2. Install the ckanext-saml2auth Python package into your virtual environment::

pip install ckanext-saml2auth

3. Add ``saml2auth`` to the ``ckan.plugins`` setting in your CKAN
config file (by default the config file is located at
``/etc/ckan/default/ckan.ini``).

4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::

sudo service apache2 reload


---------------
Config settings
---------------

None at present

.. Document any optional config settings here. For example::
.. # The minimum number of hours to wait before re-checking a resource
# (optional, default: 24).
ckanext.saml2auth.some_setting = some_default_value
----------------------
Developer installation
----------------------

To install ckanext-saml2auth for development, activate your CKAN virtualenv and
do::

git clone https://github.com/duskobogdanovski/ckanext-saml2auth.git
cd ckanext-saml2auth
python setup.py develop
pip install -r dev-requirements.txt


-----
Tests
-----

To run the tests, do::

pytest --ckan-ini=test.ini

To run the tests and produce a coverage report, first make sure you have
``pytest-cov`` installed in your virtualenv (``pip install pytest-cov``) then run::

pytest --ckan-ini=test.ini --cov=ckanext.saml2auth


----------------------------------------
Releasing a new version of ckanext-saml2auth
----------------------------------------

ckanext-saml2auth should be available on PyPI as https://pypi.org/project/ckanext-saml2auth.
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
git push

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
65 changes: 65 additions & 0 deletions bin/travis-build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/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-saml2auth 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."
12 changes: 12 additions & 0 deletions bin/travis-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/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-saml2auth

pytest --ckan-ini=subdir/test.ini \
--cov=ckanext.saml2auth

# strict linting
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics --exclude ckan,ckanext-saml2auth
9 changes: 9 additions & 0 deletions ckanext/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# encoding: utf-8

# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
Empty file added ckanext/saml2auth/__init__.py
Empty file.
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions ckanext/saml2auth/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit


class Saml2AuthPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)

# IConfigurer

def update_config(self, config_):
toolkit.add_template_directory(config_, 'templates')
toolkit.add_public_directory(config_, 'public')
toolkit.add_resource('fanstatic',
'saml2auth')
Empty file.
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions ckanext/saml2auth/tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Tests for plugin.py."""
import ckanext.saml2auth.plugin as plugin

def test_plugin():
pass
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake8 # for the travis build
Empty file added requirements.txt
Empty file.
21 changes: 21 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[extract_messages]
keywords = translate isPlural
add_comments = TRANSLATORS:
output_file = ckanext/saml2auth/i18n/ckanext-saml2auth.pot
width = 80

[init_catalog]
domain = ckanext-saml2auth
input_file = ckanext/saml2auth/i18n/ckanext-saml2auth.pot
output_dir = ckanext/saml2auth/i18n

[update_catalog]
domain = ckanext-saml2auth
input_file = ckanext/saml2auth/i18n/ckanext-saml2auth.pot
output_dir = ckanext/saml2auth/i18n
previous = true

[compile_catalog]
domain = ckanext-saml2auth
directory = ckanext/saml2auth/i18n
statistics = true
Loading

0 comments on commit 5dedc9e

Please sign in to comment.