Skip to content
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
120 changes: 120 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: CI

on:
push:
branches:
- main
pull_request:
# run CI only if files in these whitelisted paths are changed
paths:
- '.github/workflows/**'
- 'rdmo/**'
- .pre-commit-config.yaml
- conftest.py
- pyproject.toml
workflow_dispatch:
repository_dispatch:
schedule:
- cron: '0 5 * * *'

# Permissions required for GitHub Pages official actions
permissions:
contents: read
pages: write
id-token: write

# Ensure only one run per ref at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHONDONTWRITEBYTECODE: 1
FORCE_COLOR: 1

jobs:
build_html:
name: Build HTML (convert from rdmo-catalog)
runs-on: ubuntu-24.04
env:
# elements.py:
# catalog_path = Path(os.getenv('CATALOG_PATH')) / 'rdmorganiser'
# We checkout rdmo-catalog into ./rdmo-catalog
CATALOG_PATH: rdmo-catalog
# elements.py:
# public_path = Path(os.getenv('PUBLIC_PATH', 'public'))
PUBLIC_PATH: public
# elements.py (optional override):
# templates_path = Path(os.getenv('TEMPLATE_PATH', 'templates'))
# TEMPLATE_PATH: templates
steps:
# 1) Checkout this repo (rdmo-terms)
- name: Checkout rdmo-terms
uses: actions/checkout@v4

# 2) Checkout rdmo-catalog into subfolder
- name: Checkout rdmo-catalog
uses: actions/checkout@v4
with:
repository: rdmorganiser/rdmo-catalog
path: rdmo-catalog

# 3) Python setup
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'

- name: Install Python deps
run: |
python -m pip install --upgrade pip
python -m pip install .

# 4) Run build scripts (they write into PUBLIC_PATH = public/)
# all: index element elements static
# 5) Copy static assets into public/
- name: Run make all
run: make

# 6) Configure Pages (official action)
- name: Setup Pages
uses: actions/configure-pages@v5

# 7) Upload public/ as the Pages artifact
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: public

# 8) Upload a downloadable artifact for this run
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: site-build
path: public
if-no-files-found: error

# 9) Add a summary with download hints
- name: Post build summary
run: |
{
echo "## Build summary";
echo "- ✅ Static site generated in \`public/\`.";
echo "- 📦 Download the build artifact named **site-build** from this run.";
echo "- 🔗 [View all artifacts for this run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts).";
} >> "$GITHUB_STEP_SUMMARY"

deploy:
name: Deploy to GitHub Pages
needs: build_html
runs-on: ubuntu-24.04
# Only deploy on pushes to main (not PRs)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__/
*.py[cod]
*.egg-info

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

# do not touch the migration files at all: these are auto-generated by Django
exclude: \/migrations\/

repos:
- repo: meta
hooks:
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-ast
# - id: check-json
# - id: check-xml
exclude: error\.xml$
- id: check-yaml
- id: end-of-file-fixer
exclude: \.html$|\.txt$
- id: trailing-whitespace
exclude: \.dot$
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.3
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: v9.39.1
# hooks:
# - id: eslint
# args: [--fix, --color]
# additional_dependencies:
# - eslint@8.56.0
# - eslint-plugin-react@7.37.0
# - react@18.3.1
- repo: https://github.com/crate-ci/typos
rev: f6708081b566d3e93f9b6ed2b66235ee47349889 # frozen: v1.39.2
hooks:
- id: typos
exclude: |
(?x)^(
rdmo/locale/.*|
rdmo/.*_de.html$|
rdmo/.*_es.html$|
rdmo/.*_fr.html$|
rdmo/.*_it.html$|
testing/.*.json|
testing/.*.xml
)$
# - repo: https://github.com/zizmorcore/zizmor-pre-commit
# rev: v1.16.3
# hooks:
# - id: zizmor
# args: [--fix, --offline]
ci:
autoupdate_schedule: monthly
autofix_prs: false
autoupdate_branch: 'dependency-updates'
autoupdate_commit_msg: 'build(pre-commit): pre-commit autoupdate by ci'
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
all: index element elements static

index:
python build/index.py
python src/terms/index.py

element:
python build/element.py
python src/terms/element.py

elements:
python build/elements.py
python src/terms/elements.py

static:
python build/static.py
python src/terms/static.py

serve:
python3 -m http.server 4000 -d public
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RDMO is a tool to support the systematic planning, organisation and implementati
## Setup

```bash
pip install -r requirements.txt
pip install -e .
```

Create `.env` with:
Expand All @@ -17,6 +17,6 @@ CATALOG_PATH=../rdmo-catalog
## Usage

```bash
python build/elements.py
python build/index.py
python src/terms/elements.py
python src/terms/index.py
```
25 changes: 0 additions & 25 deletions build/index.py

This file was deleted.

54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[tool.setuptools]
include-package-data = true

[tool.setuptools.package-data]
"terms" = ["templates/*", "static/**/*"]

[project]
name = "terms"
version = "0.1.0"
description = "A search and filter interface for https://github.com/rdmorganiser/rdmo-catalog"
readme = "README.md"
keywords = [
"data management plan",
"dmp",
"rdmo",
"research data",
"research data management",
]

license = "Apache-2.0"
authors = [
{name = "RDMO Arbeitsgemeinschaft", email = "rdmo-team@listserv.dfn.de"},
]
requires-python = ">=3.12"
dependencies = [
"httpx>=0.28.1",
"jinja2>=3.1.6",
"python-dotenv>=1.2.1",
]


[tool.ruff]
line-length = 120

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"DJ", # flake8-django
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"RUF", # ruff
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
"G", # flake8-logging-format
"INT" # flake8-gettext
]
ignore = [
"RUF012", # mutable-class-default
]
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

File renamed without changes.
35 changes: 18 additions & 17 deletions build/static.py → src/terms/config.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import os
import shutil
from pathlib import Path

import httpx
from dotenv import load_dotenv

load_dotenv('.env')

base_url = os.getenv('BASE_URL', '/')
catalog_path = Path(os.getenv('CATALOG_PATH')) / 'rdmorganiser'
public_path = Path(os.getenv('PUBLIC_PATH', 'public'))

assets = [
('bootstrap.min.css', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css'),
('bootstrap.min.css.map', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css.map'),
('bootstrap.bundle.min.js', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js'),
('minisearch.min.js', 'https://cdn.jsdelivr.net/npm/minisearch@7.2.0/dist/umd/index.min.js')
]
ns_dc = '{http://purl.org/dc/elements/1.1/}'

catalog_path = Path(os.getenv('CATALOG_PATH')) / 'rdmorganiser'
public_path = Path(os.getenv('PUBLIC_PATH', 'public'))
static_path = Path(os.getenv('STATIC_PATH', 'static'))

shutil.copytree(static_path, public_path / 'static', dirs_exist_ok=True)

for asset_name, asset_url in assets:
with httpx.Client() as client:
response = client.get(asset_url)
response.raise_for_status()

asset_path = public_path / 'static' / 'vendor' / asset_name
asset_path.parent.mkdir(exist_ok=True, parents=True)
with asset_path.open('wb') as fp:
fp.write(response.content)
module_map = {
'condition': 'conditions',
'attribute': 'domain',
'optionset': 'options',
'option': 'options',
'catalog': 'questions',
'section': 'questions',
'page': 'questions',
'questionset': 'questions',
'question': 'questions',
'task': 'tasks',
'view': 'views'
}
20 changes: 3 additions & 17 deletions build/element.py → src/terms/element.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import json
import os

from pathlib import Path
import json

from dotenv import load_dotenv
from jinja2 import Environment, FileSystemLoader
from config import base_url, catalog_path, public_path
from jinja import jinja2_env
from jinja2.exceptions import TemplateNotFound

from utils import gather_elements

load_dotenv('.env')

base_url = os.getenv('BASE_URL', '/')

catalog_path = Path(os.getenv('CATALOG_PATH')) / 'rdmorganiser'

public_path = Path(os.getenv('PUBLIC_PATH', 'public'))
templates_path = Path(os.getenv('TEMPLATE_PATH', 'templates'))

jinja2_env = Environment(loader=FileSystemLoader(templates_path))

for element in gather_elements(catalog_path):
template_path = str(Path(element['type']).with_suffix('.html'))
try:
Expand Down
Loading