Skip to content

Commit

Permalink
Merge pull request #1722 from open-contracting/profile-template
Browse files Browse the repository at this point in the history
build: Update to latest profile template
  • Loading branch information
jpmckinney authored Nov 27, 2024
2 parents 0871878 + b7aaa4b commit ad9b2c6
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 188 deletions.
53 changes: 11 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,15 @@ name: CI
on: [push, pull_request]
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: pip
cache-dependency-path: '**/requirements*.txt'
# Don't install editable projects in the current working directory.
# https://pip.pypa.io/en/latest/reference/pip_install/#install-src
- run: pip install --src $GITHUB_WORKSPACE/../src -r requirements.txt
- if: github.repository == 'open-contracting/standard_profile_template'
run: make update extract
- run: make
# Disable linkcheck as it is too slow for development.
# - run: |
# make linkcheck
# rm -f output.json output.txt
uses: open-contracting/.github/.github/workflows/ci-profile.yml@main
secrets:
private-key: ${{ secrets.PRIVATE_KEY }}
elasticsearch-password: ${{ secrets.ELASTICSEARCH_PASSWORD }}
with:
path-prefix: ''
version: '1.1'
production-refs: '["refs/heads/1.0", "refs/heads/1.1"]'
# Linkcheck is slow for development.
linkcheck: false
# "ResourceWarning: unclosed file <_io.BufferedWriter name='/dev/null'>"
- run: pytest -W error -W ignore::ResourceWarning
# Deploy the built documentation to the staging directory.
- if: github.event_name == 'push'
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PRIVATE_KEY }}
known_hosts: standard.open-contracting.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGveFGTJ9yyObNGDUCUyzyFkm6Kzh3YqIt1qB7B/KU6E
- if: github.event_name == 'push'
uses: bcomnes/netrc-creds@v3
with:
machine: standard.open-contracting.org
login: manage
password: ${{ secrets.ELASTICSEARCH_PASSWORD }}
- if: github.event_name == 'push' && success() && github.repository != 'open-contracting/standard_profile_template'
env:
PATH_PREFIX: ""
PRODUCTION: ${{ startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/latest' || github.ref == 'refs/heads/1.0' || github.ref == 'refs/heads/1.1' }}
RELEASE: ${{ startsWith(github.ref, 'refs/tags') }}
VERSION: "1.1"
shell: bash
run: curl -sS https://raw.githubusercontent.com/open-contracting/deploy/main/deploy-docs.sh | bash -
pytest-options: -W ignore::ResourceWarning
11 changes: 4 additions & 7 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Lint JavaScript
on: [push, pull_request]
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: biomejs/setup-biome@v2
- run: biome ci --indent-style=space --line-width=119 docs/_static/script.js
lint:
uses: open-contracting/.github/.github/workflows/js.yml@main
with:
filenames: docs/_static/script.js
36 changes: 6 additions & 30 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
name: Lint
on: [push, pull_request]
env:
BASEDIR: https://raw.githubusercontent.com/open-contracting/standard-maintenance-scripts/main
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
env:
PAT: ${{ secrets.PAT }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || github.token }}
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: pip
cache-dependency-path: '**/requirements*.txt'
- id: changed-files
uses: tj-actions/changed-files@v45
- uses: pre-commit/[email protected]
continue-on-error: true
with:
extra_args: pip-compile --files ${{ steps.changed-files.outputs.all_changed_files }}
- if: ${{ env.PAT }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: '[github-actions] pre-commit autoupdate'
- shell: bash
run: curl -s -S --retry 3 $BASEDIR/tests/install.sh | bash -
- shell: bash
run: curl -s -S --retry 3 $BASEDIR/tests/script.sh | bash -
lint:
uses: open-contracting/.github/.github/workflows/lint.yml@main
permissions:
contents: write
with:
python-version: '3.10'
13 changes: 2 additions & 11 deletions .github/workflows/shell.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
name: Lint Shell
on: [push, pull_request]
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
sudo apt update
sudo apt install devscripts shellcheck shfmt
- run: checkbashisms $(shfmt -f .)
- run: shellcheck $(shfmt -f .)
- run: shfmt -d -i 4 -sr $(shfmt -f .)
lint:
uses: open-contracting/.github/.github/workflows/shell.yml@main
15 changes: 5 additions & 10 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: Spell-check
on: [push, pull_request]
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install codespell
- run: codespell -S .git,docson,locale,examples,country.csv,currency.csv,language.csv,mediaType.csv -L fo,sme,zar,SME .
lint:
uses: open-contracting/.github/.github/workflows/spellcheck.yml@main
with:
ignore: fo,sme,zar
skip: docson,locale,examples,country.csv,currency.csv,language.csv,mediaType.csv
2 changes: 1 addition & 1 deletion common-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
standard-theme @ git+https://github.com/open-contracting/standard_theme.git@07ca0e39979a244656dd6df0658f2ead428184b9#egg=standard_theme
standard-theme @ git+https://github.com/open-contracting/standard_theme.git@c3cbd1b8ba6db24624e5d838ed18147db63f5d1b#egg=standard_theme
# via -r common-requirements.in
starlette==0.40.0
# via sphinx-autobuild
Expand Down
144 changes: 73 additions & 71 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

# -- Path setup --------------------------------------------------------------

# 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.

import csv
import json
import os
Expand All @@ -24,12 +20,12 @@

# -- Project information -----------------------------------------------------

project = 'Open Contracting Data Standard'
copyright = 'Open Contracting Partnership'
author = 'Open Contracting Partnership'
project = "Open Contracting Data Standard"
copyright = "Open Contracting Partnership"
author = "Open Contracting Partnership"

version = '1.1'
release = '1.1.5'
version = "1.1"
release = "1.1.5"


# -- General configuration ---------------------------------------------------
Expand All @@ -38,137 +34,143 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'myst_parser',
'sphinx.ext.ifconfig',
'sphinxcontrib.jsonschema',
'sphinxcontrib.opencontracting',
'sphinxcontrib.opendataservices',
'sphinx_design',
"myst_parser",
"sphinx.ext.ifconfig",
"sphinxcontrib.jsonschema",
"sphinxcontrib.opencontracting",
"sphinxcontrib.opendataservices",
"sphinx_design",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**/docson/[!p]**', '**/docson/package*.json']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**/docson/[!p]**", "**/docson/package*.json"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'standard_theme' # 'pydata_sphinx_theme'
html_theme = "standard_theme" # 'pydata_sphinx_theme'
html_theme_path = [standard_theme.get_html_theme_path()]
html_favicon = '_static/favicon-16x16.ico'
html_favicon = "_static/favicon-16x16.ico"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Local configuration -----------------------------------------------------

_ = get_translation('theme')
_ = get_translation("theme")

profile_identifier = ''
repository_url = 'https://github.com/open-contracting/standard'
profile_identifier = ""
repository_url = "https://github.com/open-contracting/standard"

# Internationalization.
gettext_compact = False
# `DOMAIN_PREFIX` from `config.mk`.
gettext_domain_prefix = f'{profile_identifier}-' if profile_identifier else ''
locale_dirs = ['locale/', os.path.join(standard_theme.get_html_theme_path(), 'locale')]
gettext_domain_prefix = f"{profile_identifier}-" if profile_identifier else ""
locale_dirs = ["locale/", os.path.join(standard_theme.get_html_theme_path(), "locale")]
# We use single quotes for codes, which docutils will change to double quotes.
# https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/utils/smartquotes.py
smartquotes = False

# MyST configuration.
myst_enable_extensions = ['linkify']
myst_enable_extensions = ["linkify"]
myst_heading_anchors = 6
myst_heading_slug_func = make_id
# https://github.com/executablebooks/MyST-Parser/issues/357
suppress_warnings = ['myst.anchor']
suppress_warnings = ["myst.anchor"]

# Theme customization.
navigation_with_keys = False # restore the Sphinx default
html_context = {
'analytics_id': 'HTWZHRIZ',
"analytics_id": "HTWZHRIZ",
}
html_theme_options = {
'analytics_id': 'HTWZHRIZ',
'display_version': True,
'root_url': f'/profiles/{profile_identifier}' if profile_identifier else '',
'short_project': project.replace('Open Contracting Data Standard', 'OCDS'),
'copyright': copyright,
'license_name': 'Apache License 2.0',
'license_url': f'{repository_url}/blob/HEAD/LICENSE',
'repository_url': repository_url,
"analytics_id": "HTWZHRIZ",
"display_version": True,
"root_url": f"/profiles/{profile_identifier}" if profile_identifier else "",
"short_project": project.replace("Open Contracting Data Standard", "OCDS"),
"copyright": copyright,
"license_name": "Apache License 2.0",
"license_url": f"{repository_url}/blob/HEAD/LICENSE",
"repository_url": repository_url,
}
html_short_title = f'{html_theme_options["short_project"]} v{release}'
html_short_title = f"{html_theme_options['short_project']} v{release}"

# List the extension identifiers and versions that should be part of this specification. The extensions must be in
# the extension registry: https://github.com/open-contracting/extension_registry/blob/main/extension_versions.csv
default_extension_version = f'v{release}'
default_extension_version = f"v{release}"
extension_versions = {
'bids': default_extension_version,
'enquiries': default_extension_version,
'location': default_extension_version,
'lots': default_extension_version,
'milestone_documents': default_extension_version,
'participation_fee': default_extension_version,
'process_title': default_extension_version,
"bids": default_extension_version,
"enquiries": default_extension_version,
"location": default_extension_version,
"lots": default_extension_version,
"milestone_documents": default_extension_version,
"participation_fee": default_extension_version,
"process_title": default_extension_version,
}

# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder
# Ignore Google Sheets.
linkcheck_anchors_ignore = [r'^gid=']
linkcheck_anchors_ignore = [r"^gid="]
linkcheck_ignore = [
# Avoid GitHub.com rate limiting.
r'^https://github.com/open-contracting/standard/(?:issues|pull)/\d+$',
r"^https://github.com/open-contracting/standard/(?:issues|pull)/\d+$",
# Ignore irreproducible false positives.
r'^https://www.fcny.org/fcny/$',
r'^http://www.eprocurementtoolkit.org/sites/default/files/2016-11/OCDS_Implemetation_Methodology_0.pdf#page=27$',
r"^https://www.fcny.org/fcny/$",
r"^http://www.eprocurementtoolkit.org/sites/default/files/2016-11/OCDS_Implemetation_Methodology_0.pdf#page=27$",
# Ignore unwanted links created by linkify.
r'^http://vnd\.',
r"^http://vnd\.",
# Ignore expected redirects.
r'^https://docs.google.com/spreadsheets/d/[^/]+/pub?gid=\d+&single=true&output=csv$',
r"^https://docs.google.com/spreadsheets/d/[^/]+/pub?gid=\d+&single=true&output=csv$",
]


def setup(app):
# The root of the repository.
basedir = Path(__file__).resolve().parents[1]
# `LOCALE_DIR` from `config.mk`.
localedir = basedir / 'docs' / 'locale'
localedir = basedir / "docs" / "locale"

language = app.config.overrides.get('language', 'en')
language = app.config.overrides.get("language", "en")

headers = ['Title', 'Description', 'Extension']
headers = ["Title", "Description", "Extension"]
# The gettext domain for schema translations. Should match the domain in the `pybabel compile` command.
schema_domain = f'{gettext_domain_prefix}schema'
schema_domain = f"{gettext_domain_prefix}schema"
# The gettext domain for codelist translations. Should match the domain in the `pybabel compile` command.
codelists_domain = f'{gettext_domain_prefix}codelists'

standard_dir = basedir / 'schema'
standard_build_dir = basedir / 'build' / language

branch = os.getenv('GITHUB_REF_NAME', 'latest')

translate([
# The glob patterns in `babel_ocds_schema.cfg` should match these filenames.
(glob(str(standard_dir / '*-schema.json')), standard_build_dir, schema_domain),
# The glob patterns in `babel_ocds_codelist.cfg` should match these.
(glob(str(standard_dir / 'codelists' / '*.csv')), standard_build_dir / 'codelists', codelists_domain),
], localedir, language, headers, version=branch)

with (standard_build_dir / 'release-schema.json').open() as f:
codelists_domain = f"{gettext_domain_prefix}codelists"

standard_dir = basedir / "schema"
standard_build_dir = basedir / "build" / language

branch = os.getenv("GITHUB_REF_NAME", "latest")

translate(
[
# The glob patterns in `babel_ocds_schema.cfg` should match these filenames.
(glob(str(standard_dir / "*-schema.json")), standard_build_dir, schema_domain),
# The glob patterns in `babel_ocds_codelist.cfg` should match these.
(glob(str(standard_dir / "codelists" / "*.csv")), standard_build_dir / "codelists", codelists_domain),
],
localedir,
language,
headers,
version=branch,
)

with (standard_build_dir / "release-schema.json").open() as f:
fieldnames, rows = mapping_sheet(json.load(f), infer_required=True)

with (standard_build_dir / 'release-schema.csv').open('w') as f:
with (standard_build_dir / "release-schema.csv").open("w") as f:
writer = csv.DictWriter(f, fieldnames)
writer.writeheader()
writer.writerows(rows)
Loading

0 comments on commit ad9b2c6

Please sign in to comment.