Skip to content

Commit

Permalink
Merge pull request #93 from NaturalHistoryMuseum/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni authored Nov 7, 2022
2 parents 21c2b92 + a4e3081 commit ef5e712
Show file tree
Hide file tree
Showing 20 changed files with 282 additions and 112 deletions.
9 changes: 7 additions & 2 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

## Documentation
- [Our API documentation](https://naturalhistorymuseum.github.io/dataportal-docs)
- [CKAN documentation](http://docs.ckan.org/en/latest)
- [Official CKAN documentation](http://docs.ckan.org/en/latest)

## Issues
- [The NHM on Github](https://github.com/NaturalHistoryMuseum)
- [General issue tracker](https://github.com/NaturalHistoryMuseum/data-portal-issues/issues)
- [Our CKAN extensions](https://github.com/search?q=topic%3Ackan+org%3ANaturalHistoryMuseum&type=repositories) (for more specific issues)

## Contact Us
- [Gitter](https://gitter.im/nhm-data-portal/lobby)
- [Email _data@nhm.ac.uk_](mailto:data@nhm.ac.uk)
- [Twitter](https://twitter.com/nhm_data)
- [Twitter](https://twitter.com/nhm_data)
30 changes: 30 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Bump version

on:
push:
branches:
- main

jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
name: "Bump version and create changelog"
steps:
- name: Check out
uses: actions/checkout@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
changelog_increment_filename: CURRENT.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: "CURRENT.md"
tag_name: v${{ env.REVISION }}
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Tests

on:
push:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Build images
run: docker-compose build

- name: Run tests
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: docker-compose run -e COVERALLS_REPO_TOKEN ckan bash /opt/scripts/run-tests.sh -c ckanext.ldap
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*.egg-info
*.pyc
.noseids


.pytest_cache
.coverage
build/
dist/
.idea
**/node_modules/
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
- id: detect-private-key
- id: end-of-file-fixer
- id: name-tests-test
- id: trailing-whitespace
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.35.0
hooks:
- id: commitizen
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.0
hooks:
- id: docformatter
# these can't be pulled directly from the config atm, not sure why
args: ["-i", "--wrap-summaries=88", "--wrap-descriptions=88",
"--pre-summary-newline", "--make-summary-multi-line"]
9 changes: 9 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

python:
install:
- method: pip
path: .[docs]

mkdocs:
configuration: mkdocs.yml
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

# ckanext-ldap

[![Travis](https://img.shields.io/travis/NaturalHistoryMuseum/ckanext-ldap/master.svg?style=flat-square)](https://travis-ci.org/NaturalHistoryMuseum/ckanext-ldap)
[![Tests](https://img.shields.io/github/workflow/status/NaturalHistoryMuseum/ckanext-ldap/Tests?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-ldap/actions/workflows/main.yml)
[![Coveralls](https://img.shields.io/coveralls/github/NaturalHistoryMuseum/ckanext-ldap/master.svg?style=flat-square)](https://coveralls.io/github/NaturalHistoryMuseum/ckanext-ldap)
[![CKAN](https://img.shields.io/badge/ckan-2.9.1-orange.svg?style=flat-square)](https://github.com/ckan/ckan)
[![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/)
[![Docs](https://img.shields.io/readthedocs/ckanext-ldap?style=flat-square)](https://ckanext-ldap.readthedocs.io)

_A CKAN extension that provides LDAP authentication._

Expand Down
2 changes: 0 additions & 2 deletions dev_requirements.txt

This file was deleted.

6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ services:
- solr
- redis
volumes:
- .:/srv/app/src/ckanext-ldap
- ./ckanext:/base/src/ckanext-ldap/ckanext
- ./tests:/base/src/ckanext-ldap/tests

solr:
build:
context: https://github.com/okfn/docker-ckan.git#:solr
image: ckan/ckan-solr:2.9
logging:
driver: none

Expand Down
28 changes: 11 additions & 17 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
FROM openknowledge/ckan-dev:2.9
FROM naturalhistorymuseum/ckantest:0.2

RUN apk add openldap-dev
# required by python-ldap
RUN apt-get -q -y install libldap2-dev libsasl2-dev \
&& apt-get -q clean \
&& rm -rf /var/lib/apt/lists/*

# ckan is installed in /srv/app/src/ckan in the ckan-dev image we're basing this image on
WORKDIR /srv/app/src/ckanext-ldap
WORKDIR /base/src/ckanext-ldap

# copy over the ckanext-ldap source
# copy over the source
COPY . .

# might as well update pip while we're here!
RUN pip3 install --upgrade pip

# fixes this https://github.com/ckan/ckan/issues/5570
RUN pip3 install pytest-ckan

# install the dependencies
RUN python3 setup.py develop && \
pip3 install -r requirements.txt && \
pip3 install -r dev_requirements.txt
# install the base + test dependencies
RUN pip install -e .[test]

# this entrypoint ensures our service dependencies (postgresql, solr and redis) are running before
# running the cmd
ENTRYPOINT ["/bin/bash", "docker/entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "/opt/waits/basic.sh"]

# run the tests with coverage output
CMD ["pytest", "--cov=ckanext.ldap", "--ckan-ini=test.ini", "tests"]
CMD ["bash", "/opt/scripts/run-tests.sh", "ckanext.ldap"]
24 changes: 0 additions & 24 deletions docker/entrypoint.sh

This file was deleted.

45 changes: 45 additions & 0 deletions docs/_scripts/gen_api_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# !/usr/bin/env python
# encoding: utf-8

"""
Generate the code reference pages and navigation.
Adapted from https://mkdocstrings.github.io/recipes.
"""

from pathlib import Path

import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()

root = 'ckanext'

py_files = sorted(Path(root).rglob('*.py'))

for path in py_files:
module_path = path.relative_to(root).with_suffix('')
doc_path = path.relative_to(root).with_suffix('.md')
full_doc_path = Path('API', doc_path)

parts = tuple(module_path.parts)

if parts[-1] == '__init__':
if len(parts) == 1:
continue
parts = parts[:-1]
doc_path = doc_path.with_name('index.md')
full_doc_path = full_doc_path.with_name('index.md')
elif parts[-1] == '__main__':
continue

nav[parts] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = '.'.join(parts)
fd.write(f'::: ckanext.{ident}')

mkdocs_gen_files.set_edit_path(full_doc_path, path)

with mkdocs_gen_files.open('API/index.md', 'w') as nav_file:
nav_file.writelines(nav.build_literate_nav())
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# ckanext-ldap documentation
Empty file added docs/usage/index.md
Empty file.
36 changes: 36 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
site_name: ckanext-ldap

theme:
name: material
palette:
- scheme: default
toggle:
icon: material/lightbulb
primary: green
accent: green
- scheme: slate
toggle:
icon: material/lightbulb-outline
primary: green
accent: green

watch:
- ckanext

plugins:
- search
- mkdocstrings:
default_handler: python
handlers:
python:
options:
docstring_style: sphinx
- gen-files:
scripts:
- docs/_scripts/gen_api_pages.py
- section-index

markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
83 changes: 83 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[project]
name = "ckanext-ldap"
version = "3.1.2"
description = "A CKAN extension that provides LDAP authentication."
readme = "README.md"
requires-python = ">=3.6"
license = {text = "GPL-3.0-or-later"}
authors = [
{ name = "Natural History Museum", email = "data@nhm.ac.uk" }
]
keywords = ["CKAN", "data", "ldap"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8"
]
dependencies = [
"ckantools==0.2.0",
"python-ldap==3.4.0"
]

[project.optional-dependencies]
test = [
"mock",
"pytest>=4.6.5",
"pytest-cov>=2.7.1",
"coveralls"
]
docs = [
"mkdocs",
"mkdocstrings[python]",
"mkdocs-material",
"mkdocs-gen-files",
"mkdocs-section-index"
]

[project.urls]
repository = "https://github.com/NaturalHistoryMuseum/ckanext-ldap"
changelog = "https://github.com/NaturalHistoryMuseum/ckanext-ldap/blob/main/CHANGELOG.md"

[project.entry-points."ckan.plugins"]
ldap = "ckanext.ldap.plugin:LdapPlugin"


[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"


[tool]
[tool.setuptools]
zip-safe = false

[tool.setuptools.packages.find]
exclude = ["tests"]

[tool.commitizen]
name = "cz_conventional_commits"
version = "3.1.2"
tag_format = "v$version"
update_changelog_on_bump = true
changelog_incremental = false
version_files = [
"pyproject.toml:version"
]

[tool.black]
line-length = 88
skip_string_normalization = true

[tool.pylint]
max-line-length = 88
disable = ["C0114", "R0903"]

[tool.docformatter]
wrap-summaries = 88
wrap-descriptions = 88
pre-summary-newline = true
make-summary-multi-line = true
Loading

0 comments on commit ef5e712

Please sign in to comment.