Compare commits

..

2 Commits

Author SHA1 Message Date
03ecab9755 Rename tox target for pdf build
All checks were successful
gl/check check status: success (03ecab9755562d7f4efc3c3b914b787c73a48eb8)
zuul jobs require target to be called pdf-docs instead of docs-pdf
2023-03-23 12:37:25 +01:00
ec59663c39 Include pdf filenames into zuul config
Zuul jobs expect to know PDF filenames to be fetching from artifacts.
Best way is to include them into the project config while managing zuul
config.
2023-03-23 12:37:25 +01:00
11 changed files with 31 additions and 514 deletions

View File

@ -1,9 +1,6 @@
============
otc-metadata
============
Link: ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
===============================
ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
===============================
Metadata about OTC for Ecosystem
@ -16,39 +13,6 @@ Note that this is a hard requirement.
* Source: https://github.com/infra/ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
Features
========
--------
* TODO
Overview: service.yaml
======================
The :code:`service.yaml` file contains all data about services, service
categories and the related documents of each service. The file is
used as a base for several internal and external applications or
websites like the Helpcenter 3.0 where the information about the document
repositories and its properties are stored.
File structure
--------------
The file is based on the yaml-file format and has three main sections
which can be compared with database tables in a relational database.
* documents: contains the information about every single document and its type
like umn, api-ref etc.
* service category: contains the keyword and title of the service category
* services: contains the repository information about the internal (Gitea) and
external location (GitHub) and all the necessary parameters of the service itself
These sections, or better "tables" have
their own keys and foreign keys so that the tables are linked together and
the related information can be fetched.
For the :code:`services` table
the key is :code:`service_type` which has the foreign key in the
:code:`documents` table. So a service can have multiple documents and each
document can only be linked to one service.
The key :code:`service_category` table is :code:`name` of the service category
which is then used in the :code:`services` table as foreign key.

File diff suppressed because it is too large Load Diff

View File

@ -18,10 +18,7 @@ import os
import sys
extensions = [
'otcdocstheme',
{%- if otc_sbv %}
'otc_sphinx_directives'
{%- endif %}
'otcdocstheme'
]
otcdocs_auto_name = False
@ -37,15 +34,6 @@ otcdocs_git_fqdn = '{{ git_fqdn }}'
otcdocs_git_type = '{{ git_type }}'
{%- endif %}
# Those variables are needed for indexing into OpenSearch
otcdocs_doc_environment = '{{ doc_environment }}'
otcdocs_doc_link = '{{ doc_link }}'
otcdocs_doc_title = '{{ doc_title }}'
otcdocs_doc_type = '{{ doc_type }}'
otcdocs_service_category = '{{ service_category }}'
otcdocs_service_title = '{{ service_title }}'
otcdocs_service_type = '{{ service_type }}'
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

View File

@ -2,6 +2,3 @@ sphinx>=2.0.0,!=2.1.0 # BSD
otcdocstheme # Apache-2.0
# releasenotes
reno>=3.1.0 # Apache-2.0
otc-sphinx-directives>=0.1.0
git+https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata.git#egg=otc_metadata

View File

@ -1,7 +0,0 @@
{{ sbv_title }}
.. directive_wrapper::
:class: container-sbv
.. service_card::
:service_type: {{ service_type }}

View File

@ -29,17 +29,13 @@ allowlist_externals =
mkdir
cp
sh
rm
sphinx-build
commands =
rm -rf doc/build/html doc/build/doctrees
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
{%- for doc in docs %}
{[testenv:{{ doc.type }}]commands}
{[testenv:json-{{ doc.type }}]commands}
{%- endfor %}
[testenv:docs-pdf]
[testenv:pdf-docs]
deps = -r{toxinidir}/doc/requirements.txt
allowlist_externals =
rm
@ -119,7 +115,3 @@ commands =
cp {{ loc }}/build/pdf/{{ doc.pdf_name }}.pdf doc/build/pdf/
{% endif %}
{% endfor %}
[doc8]
ignore = D001
extensions = .rst, .yaml

View File

@ -21,45 +21,8 @@ Tests for `otc-metadata` module.
from unittest import TestCase
from otc_metadata import services
class TestOtcMetadata(TestCase):
def setUp(self):
self.data = services.Services()
def test_data_is_sorted(self):
curr = self.data
new = services.Services()
new._sort_data()
self.assertEqual(
curr._service_data, new._service_data, "Data is sorted properly"
)
def test_service_categories(self):
category = dict()
for cat in self.data._service_data["service_categories"]:
category[cat["name"]] = cat["title"]
for srv in self.data.all_services:
self.assertTrue(
srv["service_category"] in category,
f"Category {srv['service_category']} is present",
)
def test_doc_contains_required_data(self):
srv_types = dict()
for srv in self.data.all_services:
srv_types[srv["service_type"]] = srv
for doc in self.data.all_docs:
for attr in [
"rst_location",
"service_type",
"title",
"type",
]:
self.assertIn(attr, doc, f"Document {doc} contains {attr}")
self.assertIn(
doc["service_type"],
srv_types,
f"Document {doc} contains valid service_type",
)
def test_something(self):
pass

File diff suppressed because it is too large Load Diff

View File

@ -130,6 +130,7 @@ def process_repositories(args, service):
zuul_templates = None
zuul_jobs = dict()
zuul_new_jobs = list()
zuul_vars = dict()
zuul_config_updated = False
for item in zuul_config:
if "project" in item.keys():
@ -137,10 +138,11 @@ def process_repositories(args, service):
zuul_templates = project.setdefault("templates", [])
if not zuul_templates:
zuul_templates = []
zuul_vars = project.setdefault("vars", {})
elif "job" in item.keys():
job = item["job"]
zuul_jobs[job["name"]] = job
print(f"Existing jobs {zuul_jobs}")
logging.debug(f"Existing jobs {zuul_jobs}")
if "helpcenter-base-jobs" not in zuul_templates:
zuul_templates.append("helpcenter-base-jobs")
zuul_config_updated = True
@ -148,6 +150,7 @@ def process_repositories(args, service):
job_suffix = (
"-hc-int-jobs" if args.environment == "internal" else "-hc-jobs"
)
sphinx_pdf_files = zuul_vars.setdefault('sphinx_pdf_files', [])
for doc in data.docs_by_service_type(service["service_type"]):
logging.debug(f"Analyzing document {doc}")
if not doc.get("type"):
@ -156,6 +159,12 @@ def process_repositories(args, service):
doc_type = "dev-guide"
else:
doc_type = doc["type"]
# Collect all PDF files into sphinx_pdf_files var
pdf_name = doc.get('pdf_name')
if pdf_name and f"{pdf_name}.pdf" not in sphinx_pdf_files:
sphinx_pdf_files.append(f"{pdf_name}.pdf")
zuul_config_updated = True
template_name = f"{doc_type}{job_suffix}"
if doc_type in ["api-ref", "umn", "dev-guide"]:
if template_name not in zuul_templates:
@ -190,6 +199,7 @@ def process_repositories(args, service):
if "project" in item.keys():
project = item["project"]
project["templates"] = zuul_templates
project["vars"] = zuul_vars
# Ensure new jobs are in check
if len(zuul_new_jobs) > 0:
project.setdefault(

View File

@ -19,6 +19,7 @@ commands = {posargs}
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125,W503
builtins = _

View File

@ -1,4 +1,3 @@
---
- project:
merge-mode: squash-merge
default-branch: main
@ -9,4 +8,4 @@
gate:
jobs:
- otc-tox-pep8
- otc-tox-py39
- otc-tox-py39