Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor development setup #11

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on:
push:
branches:
- master
pull_request:
# run CI only if files in these whitelisted paths are changed
paths:
- '.github/workflows/**'
- 'rdmo_plugins/**'
- .pre-commit-config.yaml
- pyproject.toml

# Ref: https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHONDONTWRITEBYTECODE: 1
FORCE_COLOR: 1 # colored output by pytest etc.
CLICOLOR_FORCE: 1 # colored output by ruff

jobs:

lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: pip
- run: python -m pip install --upgrade pip setuptools wheel
- run: python -m pip install -e .[dev]
- name: Set up pre-commit cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: lint-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run linters via pre-commit (ruff, eslint)
run: pre-commit run --all-files --color=always

dev-setup:
# Ref: structlog (MIT licensed) <https://github.com/hynek/structlog/blob/main/.github/workflows/ci.yml>
name: "Test dev setup on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: pip
- run: python -Im pip install -e .[dev]
- run: python -Ic 'import rdmo_plugins; print(rdmo_plugins.__version__)'

required-checks-pass:
if: always()
needs:
- lint
- dev-setup
runs-on: ubuntu-22.04
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
30 changes: 0 additions & 30 deletions .github/workflows/django.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ dist
*.egg-info

/env

.pytest_cache
.ruff_cache
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

repos:
- repo: meta
hooks:
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-ast
- id: check-xml
- id: check-yaml
- id: end-of-file-fixer
exclude: \.html$|\.txt$
- id: trailing-whitespace
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
# rdmo-plugins

<!--- mdtoc: toc begin -->
[![Python Versions](https://img.shields.io/pypi/pyversions/rdmo.svg?style=flat)](https://www.python.org/)
[![Django Versions](https://img.shields.io/pypi/frameworkversions/django/rdmo)](https://pypi.python.org/pypi/rdmo/)
[![License](https://img.shields.io/github/license/rdmorganiser/rdmo?style=flat)](https://github.com/rdmorganiser/rdmo/blob/master/LICENSE) \
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![CI Workflow Status](https://github.com/rdmorganiser/rdmo-plugins/actions/workflows/ci.yml/badge.svg)](https://github.com/rdmorganiser/rdmo-plugins/actions/workflows/ci.yml)

<!--- mdtoc: toc begin -->
1. [Synopsis](#synopsis)
2. [Setup](#setup)
3. [Other plugins](#other-plugins)
1. [RDMO Sensor AWI optionset plugin](#rdmo-sensor-awi-optionset-plugin)<!--- mdtoc: toc end -->
1. [RDMO Sensor AWI optionset plugin](#rdmo-sensor-awi-optionset-plugin)
<!--- mdtoc: toc end -->

## Synopsis

Import and export plugins for [RDMO](https://github.com/rdmorganiser/rdmo). Included are plugins for [maDMP](https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard), [DataCite (Kernel 4.3)](https://schema.datacite.org/meta/kernel-4.3/), and the [Radar metadata schema](https://www.radar-service.eu/de/radar-schema).

**Since the RDMO questionaires and the domain does not contain all information needed for maDMP, DataCite, or Radar, the exports will not produce valid files. We will fix this in the future.**
**Since the RDMO questionnaires and the domain does not contain all information needed for maDMP, DataCite, or Radar, the exports will not produce valid files. We will fix this in the future.**

Please visit the [RDMO documentation](https://rdmo.readthedocs.io/en/latest/plugins/index.html#project-export-plugins) for detailed information.

Please note that the re3data plugin was moved to a [seperate repository](https://github.com/rdmorganiser/rdmo-re3data).
Please note that the re3data plugin was moved to a [separate repository](https://github.com/rdmorganiser/rdmo-re3data).

## Setup

Install the plugins in your RDMO virtual environment using pip (directly from GitHub):

```bash
pip install git+https://github.com/rdmorganiser/rdmo-plugins
python -m pip install git+https://github.com/rdmorganiser/rdmo-plugins
```

Add the `rdmo_plugins` to the `INSTALLED_APPS` in `config/settings/local.py`:

```python
from . import INSTALLED_APPS
INSTALLED_APPS = ['rdmo_plugins'] + INSTALLED_APPS
INSTALLED_APPS = ["rdmo_plugins", *INSTALLED_APPS]
```

Add the export plugins to the `PROJECT_EXPORTS` in `config/settings/local.py`:

```python
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from . import PROJECT_EXPORTS

PROJECT_EXPORTS += [
Expand All @@ -50,7 +57,7 @@ PROJECT_EXPORTS += [
Add the import plugins to the `PROJECT_IMPORTS` in `config/settings/local.py`:

```python
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from . import PROJECT_IMPORTS

PROJECT_IMPORTS += [
Expand Down
108 changes: 108 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel"]

[project]
name = "rdmo-plugins"
description = "Import and export plugins for RDMO."
readme = "README.md"
keywords = [
"data management plan",
"dmp",
"rdmo",
"research data",
"research data management",
]
license = {text = "Apache-2.0"}
authors = [
{name = "RDMO Arbeitsgemeinschaft", email = "[email protected]"},
]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django :: 4.2",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = [
"version",
]
dependencies = [
"rdmo"
]

[project.optional-dependencies]
ci = [
"rdmo-plugins[dev]",
]
dev = [
"pre-commit~=3.5",
"rdmo[allauth]",
"rdmo-plugins[pytest]",
]

[project.urls]
documentation = "https://rdmo.readthedocs.io/en/latest/plugins/"
homepage = "https://rdmorganiser.github.io"
issues = "https://github.com/rdmorganiser/rdmo-plugins/issues"
repository = "https://github.com/rdmorganiser/rdmo-plugins.git"
slack = "https://rdmo.slack.com"

[tool.setuptools.packages.find]
include = ["rdmo_plugins*"]

[tool.setuptools.package-data]
"*" = ["*"]

[tool.setuptools.dynamic]
version = {attr = "rdmo_plugins.__version__"}

[tool.ruff]
target-version = "py38"
line-length = 120
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"PGH", # pygrep-hooks
"RUF", # ruff
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
]
ignore = [
"B006", # mutable-argument-default
"B007", # unused-loop-control-variable
"B018", # useless-expression
"E501", # line-too-long
"RUF012", # mutable-class-default
]

[tool.ruff.isort]
known-first-party = ["rdmo_plugins"]
section-order = [
"future",
"standard-library",
"pytest",
"django",
"rdmo",
"third-party",
"first-party",
"local-folder"
]

[tool.ruff.isort.sections]
pytest = ["pytest"]
django = ["django"]
rdmo = ["rdmo"]
9 changes: 1 addition & 8 deletions rdmo_plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
__title__ = 'rdmo-plugins'
__version__ = '1.0.0'
__author__ = 'Jochen Klar'
afuetterer marked this conversation as resolved.
Show resolved Hide resolved
__email__ = '[email protected]'
__license__ = 'Apache-2.0'
__copyright__ = 'Copyright 2020 RDMO-Arbeitsgemeinschaft'

VERSION = __version__
__version__ = "1.0.1"
3 changes: 2 additions & 1 deletion rdmo_plugins/exports/datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict

from django.http import HttpResponse

from rdmo.core.exports import prettify_xml
from rdmo.core.renderers import BaseXMLRenderer
from rdmo.projects.exports import Export
Expand Down Expand Up @@ -374,7 +375,7 @@ def get_datasets(self):
'title':
self.get_text('project/dataset/title', set_index=set_index) or
self.get_text('project/dataset/id', set_index=set_index) or
'Dataset #{}'.format(set_index + 1)
f'Dataset #{set_index + 1}'
}]

# publisher
Expand Down
Loading