Skip to content

Commit

Permalink
Fix auto build of docs (#1217)
Browse files Browse the repository at this point in the history
PR #1193 introduced a bug with readthedocs.org in relying on presenting
the MIN_PY_VER env var via the Makefile. However the Makefile isn't
invoked during automated build of readthedocs.

This commit fixes automatic builds of our docs again.
  • Loading branch information
dliappis committed Mar 26, 2021
1 parent 62595bd commit 3b3acde
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .ci/variables.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"python_versions": {
"PY38": "3.8.8",
"PY39": "3.9.2"
"PY39": "3.9.2",
"MIN_PY_VER": "3.8.8"
}
}
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ PY_BIN = python3
PIP_WRAPPER = $(PY_BIN) -m pip
export PY38 = $(shell jq -r '.python_versions.PY38' .ci/variables.json)
export PY39 = $(shell jq -r '.python_versions.PY39' .ci/variables.json)
export MIN_PY_VER = $(PY38)
VENV_NAME ?= .venv
VENV_ACTIVATE_FILE = $(VENV_NAME)/bin/activate
VENV_ACTIVATE = . $(VENV_ACTIVATE_FILE)
Expand Down
12 changes: 11 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from datetime import date
from os.path import join, dirname

from sphinx.config import ConfigError

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand All @@ -41,9 +43,17 @@
master_doc = 'index'
language = None

CI_VARS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".ci", "variables.json")


def read_min_python_version():
return os.environ["MIN_PY_VER"]
try:
with open(CI_VARS, "rt") as fp:
return json.load(fp)["python_versions"]["MIN_PY_VER"]
except KeyError as e:
raise ConfigError(
f"Failed building docs as required key [{e}] couldn't be found in the file [{CI_VARS}]."
)


GLOBAL_SUBSTITUTIONS = {
Expand Down
23 changes: 6 additions & 17 deletions it/installation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,22 @@
# under the License.

"""
These tests ensure the validatity of Rally installation instructions (as shown in docs)
These tests ensure the validity of Rally installation instructions (as shown in docs)
"""

import json
import os
import warnings

import it

ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
_CI_VARS = ".ci/variables.json"

# normally set by Makefile, be lenient to allow running from IDE
MIN_PY_VER = os.environ.get("MIN_PY_VER")
if not MIN_PY_VER:
with open(os.path.join(ROOT_DIR, _CI_VARS), "rt") as fp:
try:
MIN_PY_VER = json.load(fp)["python_versions"]["PY38"]
warnings.warn(
f"Environment variable [MIN_PY_VER] is missing. You should fix this problem "
f"if you are running these tests "
f"on anything else than through your IDE. Defaulting to [{MIN_PY_VER}].",
category=RuntimeWarning
)
except KeyError:
raise EnvironmentError(f"Installation tests require [python_versions.PY38] key in [{_CI_VARS}] or"
f"the [MIN_PY_VER] environment variable set.")
with open(os.path.join(ROOT_DIR, _CI_VARS), "rt") as fp:
try:
MIN_PY_VER = json.load(fp)["python_versions"]["MIN_PY_VER"]
except KeyError:
raise EnvironmentError(f"Installation tests require [python_versions.MIN_PY_VER] key in [{_CI_VARS}]")


def test_installs_inside_venv():
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ passenv =
JAVA13_HOME
JAVA14_HOME
JAVA15_HOME
MIN_PY_VER
RALLY_HOME
SSH_AUTH_SOCK
THESPLOG_FILE
Expand Down

0 comments on commit 3b3acde

Please sign in to comment.