Skip to content

Commit

Permalink
build: use a docker image for kroki when building
Browse files Browse the repository at this point in the history
The kroki server is currently a bit intermittent, switching to a the
docker image to avoid issues.
  • Loading branch information
aucampia committed Mar 17, 2023
1 parent 334787b commit d66563b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
os: ubuntu-latest
extensive-tests: true
TOXENV_SUFFIX: "-docs"
WITH_KROKI_CONTAINER: true
- python-version: "3.7"
os: ubuntu-latest
extensive-tests: true
Expand All @@ -44,6 +45,7 @@ jobs:
os: ubuntu-latest
TOX_EXTRA_COMMAND: "- isort --check-only --diff ."
TOXENV_SUFFIX: "-docs"
WITH_KROKI_CONTAINER: true
- python-version: "3.9"
os: ubuntu-latest
TOX_EXTRA_COMMAND: "- black --check --diff ./rdflib"
Expand All @@ -52,9 +54,11 @@ jobs:
os: ubuntu-latest
TOX_EXTRA_COMMAND: "flake8 --exit-zero rdflib"
TOXENV_SUFFIX: "-docs"
WITH_KROKI_CONTAINER: true
- python-version: "3.11"
os: ubuntu-latest
TOXENV_SUFFIX: "-docs"
WITH_KROKI_CONTAINER: true
steps:
- uses: actions/checkout@v3
- name: Cache XDG_CACHE_HOME
Expand Down Expand Up @@ -92,6 +96,7 @@ jobs:
EXTENSIVE=${{ matrix.extensive-tests || 'false' }} \
TOX_PYTHON_VERSION=${{ matrix.python-version }} \
TOXENV_SUFFIX=${{ matrix.TOXENV_SUFFIX }} \
WITH_KROKI_CONTAINER=${{ matrix.WITH_KROKI_CONTAINER || 'false' }} \
TOX_JUNIT_XML_PREFIX=${{ matrix.python-version }}-${{ matrix.os }}${{matrix.suffix}}- \
gha:validate
env:
Expand Down
8 changes: 8 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ vars:
PIP_COMPILE: pip-compile
DOCKER: docker
OCI_REFERENCE: ghcr.io/rdflib/rdflib
WITH_KROKI_CONTAINER: "false"
KROKI_URL: "{{if (mustFromJson .WITH_KROKI_CONTAINER)}}http://localhost:15258/{{end}}"
tasks:
install:system-deps:
desc: Install system dependencies
Expand Down Expand Up @@ -96,6 +98,7 @@ tasks:
desc: Run tox
cmds:
- echo "TOXENV=${TOXENV}"
- echo "KROKI_URL=${KROKI_URL}"
- |
{{if .TOX_PYTEST_ARGS}}TOX_PYTEST_ARGS={{shellQuote .TOX_PYTEST_ARGS}}{{end}} \
{{if .TOX_EXTRA_COMMAND}}TOX_EXTRA_COMMAND={{shellQuote .TOX_EXTRA_COMMAND}}{{end}} \
Expand All @@ -106,6 +109,7 @@ tasks:
-m tox \
{{.CLI_ARGS}}
env:
KROKI_URL: '{{.KROKI_URL}}'
TOXENV: '{{if .TOX_PYTHON_VERSION}}py{{mustRegexReplaceAll "^([0-9]+)[.]([0-9]+).*" .TOX_PYTHON_VERSION "${1}${2}"}}{{if (mustFromJson .EXTENSIVE)}}-extensive{{end}}{{.TOXENV_SUFFIX | default ""}}{{end}}'
test:
desc: Run tests
Expand Down Expand Up @@ -175,6 +179,8 @@ tasks:

docs:
desc: Build documentation
env:
KROKI_URL: '{{.KROKI_URL}}'
cmds:
- echo "PYTHONPATH=${PYTHONPATH}"
- "{{.VENV_PYTHON}} -m sphinx.cmd.build -T -W -b html -d docs/_build/doctree docs docs/_build/html {{.CLI_ARGS}}"
Expand Down Expand Up @@ -251,6 +257,8 @@ tasks:
vars:
WITH_GITHUB_ACTIONS: true
- cmd: "{{.PYTHON}} -m pip install coveralls"
- cmd: "{{if (mustFromJson .WITH_KROKI_CONTAINER)}}docker compose up --detach kroki{{end}}"
- defer: "{{if (mustFromJson .WITH_KROKI_CONTAINER)}}docker compose down{{end}}"
- task: tox
vars:
COVERAGE_FILE: ".coverage"
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ services:
volumes:
- .:/srv/workspace:z,cached
- workspace-var:/srv/workspace-var
kroki:
image: docker.io/yuzutech/kroki:latest
ports:
- 15258:8000
volumes:
workspace-var: {}
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
apidoc_module_dir = "../rdflib"
apidoc_output_dir = "apidocs"

if os.environ.get("KROKI_URL", ""):
kroki_url = os.environ["KROKI_URL"]
logging.warning(f"Using kroki_url={kroki_url}")

# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
autodoc_default_options = {"special-members": True}

Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ toxworkdir={env:TOX_WORK_DIR:{tox_root}/.tox}
[testenv]
passenv =
DBUS_SESSION_BUS_ADDRESS # This is needed for keyring acccess on Linux.
KROKI_URL # This is so that we can use a local Kroki server.
allowlist_externals = poetry
setenv =
extensive: BERKELEYDB_DIR = /usr
Expand Down Expand Up @@ -50,7 +51,8 @@ commands =
[testenv:docs]
passenv =
TERM
DBUS_SESSION_BUS_ADDRESS
DBUS_SESSION_BUS_ADDRESS # This is needed for keyring acccess on Linux.
KROKI_URL # This is so that we can use a local Kroki server.
setenv =
PYTHONHASHSEED = 0
commands_pre =
Expand Down

0 comments on commit d66563b

Please sign in to comment.