Compare commits

..

1 Commits

Author SHA1 Message Date
d0fbe9a838 Update tox template
All checks were successful
gl/check check status: success (d0fbe9a83828b2ced0ae751df5edcd7895738439)
2023-01-06 14:31:14 +01:00
8 changed files with 53 additions and 214 deletions

File diff suppressed because it is too large Load Diff

View File

@ -209,22 +209,3 @@ class Services(object):
doc_struct[srv["service_category"]].append(srv_res) doc_struct[srv["service_category"]].append(srv_res)
return dict(categories=doc_struct) return dict(categories=doc_struct)
def get_service_with_docs_by_service_type(self, service_type):
"""Retrieve service and service docs by service_type
:param str service_type: Filter by service_type
"""
res = dict()
res['service'] = {}
docs = []
services = self._service_data
for doc in services['documents']:
if doc['service_type'] == service_type:
docs.append(doc)
res['documents'] = docs
for service in services['services']:
if service['service_type'] == service_type:
res['service'] = service
break
return res

View File

@ -104,9 +104,6 @@ html_title = "{{ title }}"
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ['_static']
# Do not include sources into the rendered results
html_copy_source = False
# -- Options for PDF output -------------------------------------------------- # -- Options for PDF output --------------------------------------------------
latex_documents = [ latex_documents = [
{%- if pdf_name is defined %} {%- if pdf_name is defined %}

View File

@ -21,21 +21,19 @@ deps =
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
commands = {posargs} commands = {posargs}
# This env is invoked in the periodic pipeline and is therefore responsible to
# build all relevant docs at once.
[testenv:docs] [testenv:docs]
deps = -r{toxinidir}/doc/requirements.txt deps = -r{toxinidir}/doc/requirements.txt
allowlist_externals = allowlist_externals =
mkdir mkdir
cp cp
sh find
commands = commands =
{%- for doc in docs %} {%- for doc in docs %}
{[testenv:{{ doc.type }}]commands} {[testenv:{{ doc.type }}]commands}
{[testenv:json-{{ doc.type }}]commands} {[testenv:json-{{ doc.type }}]commands}
{%- endfor %} {%- endfor %}
[testenv:pdf-docs] [testenv:docs-pdf]
deps = -r{toxinidir}/doc/requirements.txt deps = -r{toxinidir}/doc/requirements.txt
allowlist_externals = allowlist_externals =
rm rm
@ -59,8 +57,10 @@ deps = -r{toxinidir}/doc/requirements.txt
allowlist_externals = allowlist_externals =
cp cp
mkdir mkdir
find
commands = commands =
sphinx-build -W --keep-going -b html {{ loc }}/source doc/build/html/{{ doc.type }} sphinx-build -W --keep-going -b html {{ loc }}/source doc/build/html/{{ doc.type }}
find doc/build/html -type d -name '_sources' -exec rm -rf {:} ;
{%- if doc.type == 'api-ref' %} {%- if doc.type == 'api-ref' %}
mkdir -p api-ref/build/html mkdir -p api-ref/build/html
cp -av doc/build/html/api-ref api-ref/build/html cp -av doc/build/html/api-ref api-ref/build/html
@ -78,12 +78,11 @@ deps = -r{toxinidir}/doc/requirements.txt
allowlist_externals = allowlist_externals =
cp cp
mkdir mkdir
sh find
commands = commands =
sphinx-build -W --keep-going -b json {{ loc }}/source doc/build/json/{{ doc.type }} sphinx-build -W --keep-going -b json {{ loc }}/source doc/build/json/{{ doc.type }}
# Drop data useless for the search - wrap it also with sh/xargs due to bugs # Drop data useless for the search
# in tox find doc/build/json -type d -and ( -name '_images' -or -name '_static' -or -name '_sources' ) -exec rm -rf {:} ;
sh -c "find doc/build/json -type d -and '(' -name '_images' -or -name '_static' -or -name '_sources' ')' -print0 | xargs -0 rm -rf"
{%- if doc.type == 'api-ref' %} {%- if doc.type == 'api-ref' %}
mkdir -p api-ref/build/json mkdir -p api-ref/build/json
cp -av doc/build/json/api-ref api-ref/build/json cp -av doc/build/json/api-ref api-ref/build/json

View File

@ -1,6 +1,2 @@
GitPython GitPython
ruamel.yaml ruamel
requests
jinja2
dirsync
cookiecutter

View File

@ -46,7 +46,7 @@ def process_services(args, services):
has_wiki=False, has_wiki=False,
default_delete_branch_after_merge=True, default_delete_branch_after_merge=True,
allow_merge_commit=False, allow_merge_commit=False,
allow_squash_merge=True, allow_squash_merge=False,
allow_rebase_merge=False, allow_rebase_merge=False,
default_merge_style="squash", default_merge_style="squash",
branch_protections=[], branch_protections=[],

View File

@ -18,9 +18,9 @@ import argparse
import logging import logging
import os import os
import pathlib import pathlib
import shutil
import subprocess import subprocess
import warnings import warnings
from dirsync import sync
from git import Repo from git import Repo
from git import SymbolicReference from git import SymbolicReference
@ -111,21 +111,13 @@ def process_repositories(args, service):
new_branch.set_tracking_branch(remote_ref) new_branch.set_tracking_branch(remote_ref)
new_branch.checkout() new_branch.checkout()
source_path = pathlib.Path(copy_from, doc["rst_location"]) shutil.copytree(
target_path = pathlib.Path(copy_to, doc["rst_location"]) pathlib.Path(copy_from, doc["rst_location"]),
sync( pathlib.Path(copy_to, doc["rst_location"]),
source_path, ignore=lambda a, b: ["conf.py"],
target_path, dirs_exist_ok=True,
'sync',
purge=True,
create=True,
content=True,
ignore=['conf.py']
) )
repo_to.index.add([doc["rst_location"]]) repo_to.index.add([doc["rst_location"]])
for obj in repo_to.index.diff(None).iter_change_type('D'):
repo_to.index.remove([obj.b_path])
if len(repo_to.index.diff("HEAD")) == 0: if len(repo_to.index.diff("HEAD")) == 0:
# Nothing to commit # Nothing to commit
logging.debug("No changes.") logging.debug("No changes.")

View File

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