Skip to content

Commit

Permalink
Merge pull request #764 from hvac/develop
Browse files Browse the repository at this point in the history
Release v0.11.1
  • Loading branch information
jeffwecan committed Sep 22, 2021
2 parents 0eca358 + 24c024d commit 7553c19
Show file tree
Hide file tree
Showing 25 changed files with 379 additions and 162 deletions.
File renamed without changes.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
github:
- jeffwecan
ko_fi: jeffwecan
40 changes: 39 additions & 1 deletion .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,44 @@ jobs:
- name: Lint with `flake8`
run: flake8 . --count --statistics

docs-tests:
name: Documentation Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Vault (for doctests)
run: |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update \
-o Dir::Etc::sourceparts="-" \
-o APT::Get::List-Cleanup="0" \
-o Dir::Etc::sourcelist="sources.list.d/hashicorp.list"
sudo apt install \
vault-enterprise=1.7.2+ent \
;
# We disble cap_ipc_lock here as its generally incompatabile with GitHub
# Actions' runtime environments.
sudo setcap cap_ipc_lock= /usr/bin/vault
- name: Install doctest dependencies
run: pip install -r docs/requirements.txt

- name: Sphinx - doctest Build
working-directory: ./docs
run: make doctest

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,7 +154,7 @@ jobs:
sudo apt install \
consul \
vault-enterprise \
vault-enterprise=${{ matrix.vault-version }}+ent \
;
# We disble cap_ipc_lock here as its generally incompatabile with GitHub
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ the latest `vault` binary is available in your `PATH`.

```
cd hvac
pip install -r requirements.txt
pip install -r requirements-dev.txt
```
3. Run tests: `make test`

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ If you would like to be able to return parsed HCL data as a Python dict for meth
pip install "hvac[parser]"
```



## Documentation

Additional documentation for this module available at: [hvac.readthedocs.io](https://hvac.readthedocs.io/en/stable/usage/index.html):
Expand Down
42 changes: 21 additions & 21 deletions docs/ext/hvac_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
if PY2:

def doctest_encode(text, encoding):
# type: (str, unicode) -> unicode
# type: (str, str) -> str
if isinstance(text, text_type):
text = text.encode(encoding)
if text.startswith(codecs.BOM_UTF8):
Expand All @@ -68,12 +68,12 @@ def doctest_encode(text, encoding):
else:

def doctest_encode(text, encoding):
# type: (unicode, unicode) -> unicode
# type: (str, str) -> str
return text


def is_allowed_version(spec, version):
# type: (unicode, unicode) -> bool
# type: (str, str) -> bool
"""Check `spec` satisfies `version` or not.
This obeys PEP-440 specifiers:
Expand All @@ -94,7 +94,7 @@ def is_allowed_version(spec, version):
class Py23DocChecker(doctest.OutputChecker):
def check_output(self, want, got, optionflags):
if sys.version_info[0] < 3:
# Ignore unicode `u` prefix in repr to simplify Python 2.7 doctest coverage
# Ignore str `u` prefix in repr to simplify Python 2.7 doctest coverage
got = re.sub("u'(.*?)'", "'\\1'", got)
got = re.sub('u"(.*?)"', '"\\1"', got)
return doctest.OutputChecker.check_output(self, want, got, optionflags)
Expand Down Expand Up @@ -234,7 +234,7 @@ class TestoutputDirective(TestDirective):

class TestGroup(object):
def __init__(self, name):
# type: (unicode) -> None
# type: (str) -> None
self.name = name
self.setup = [] # type: List[TestCode]
self.tests = [] # type: List[List[TestCode]]
Expand All @@ -260,7 +260,7 @@ def add_code(self, code, prepend=False):
raise RuntimeError(__("invalid TestCode type"))

def __repr__(self): # type: ignore
# type: () -> unicode
# type: () -> str
return "TestGroup(name=%r, setup=%r, cleanup=%r, tests=%r)" % (
self.name,
self.setup,
Expand All @@ -271,15 +271,15 @@ def __repr__(self): # type: ignore

class TestCode(object):
def __init__(self, code, type, filename, lineno, options=None):
# type: (unicode, unicode, Optional[str], int, Optional[Dict]) -> None
# type: (str, str, Optional[str], int, Optional[Dict]) -> None
self.code = code
self.type = type
self.filename = filename
self.lineno = lineno
self.options = options or {}

def __repr__(self): # type: ignore
# type: () -> unicode
# type: () -> str
return "TestCode(%r, %r, filename=%r, lineno=%r, options=%r)" % (
self.code,
self.type,
Expand All @@ -291,7 +291,7 @@ def __repr__(self): # type: ignore

class SphinxDocTestRunner(doctest.DocTestRunner):
def __init__(self, *args, **kwargs):
# HACK: workaround unicode issues for testcode directives on Python 2.7 versus 3.x
# HACK: workaround str issues for testcode directives on Python 2.7 versus 3.x
doctest.DocTestRunner.__init__(self, *args, checker=Py23DocChecker(), **kwargs)

def summarize(self, out, verbose=None): # type: ignore
Expand All @@ -307,7 +307,7 @@ def summarize(self, out, verbose=None): # type: ignore
return res

def _DocTestRunner__patched_linecache_getlines(self, filename, module_globals=None):
# type: (unicode, Any) -> Any
# type: (str, Any) -> Any
# this is overridden from DocTestRunner adding the try-except below
m = self._DocTestRunner__LINECACHE_FILENAME_RE.match(filename) # type: ignore
if m and m.group("name") == self.test.name:
Expand Down Expand Up @@ -375,12 +375,12 @@ def init(self):
)

def _out(self, text):
# type: (unicode) -> None
# type: (str) -> None
logger.info(text, nonl=True)
self.outfile.write(text)

def _warn_out(self, text):
# type: (unicode) -> None
# type: (str) -> None
if self.app.quiet or self.app.warningiserror:
logger.warning(text)
else:
Expand All @@ -390,18 +390,18 @@ def _warn_out(self, text):
self.outfile.write(text)

def get_target_uri(self, docname, typ=None):
# type: (unicode, unicode) -> unicode
# type: (str, str) -> str
return ""

def get_outdated_docs(self):
# type: () -> Set[unicode]
# type: () -> Set[str]
return self.env.found_docs

def finish(self):
# type: () -> None
# write executive summary
def s(v):
# type: (int) -> unicode
# type: (int) -> str
return v != 1 and "s" or ""

repl = (
Expand Down Expand Up @@ -431,7 +431,7 @@ def s(v):
self.app.statuscode = 1

def write(self, build_docnames, updated_docnames, method="update"):
# type: (Iterable[unicode], Sequence[unicode], unicode) -> None
# type: (Iterable[str], Sequence[str], str) -> None
if build_docnames is None:
build_docnames = sorted(self.env.all_docs)

Expand All @@ -442,7 +442,7 @@ def write(self, build_docnames, updated_docnames, method="update"):
self.test_doc(docname, doctree)

def get_filename_for_node(self, node, docname):
# type: (nodes.Node, unicode) -> str
# type: (nodes.Node, str) -> str
"""Try to get the file which actually contains the doctest, not the
filename of the document it's included in."""
try:
Expand Down Expand Up @@ -473,8 +473,8 @@ def get_line_number(node):
return None

def test_doc(self, docname, doctree):
# type: (unicode, nodes.Node) -> None
groups = {} # type: Dict[unicode, TestGroup]
# type: (str, nodes.Node) -> None
groups = {} # type: Dict[str, TestGroup]
add_to_all_groups = []
self.setup_runner = SphinxDocTestRunner(verbose=False, optionflags=self.opt)
self.test_runner = SphinxDocTestRunner(verbose=False, optionflags=self.opt)
Expand Down Expand Up @@ -565,7 +565,7 @@ def condition(node):
self.cleanup_tries += res_t

def compile(self, code, name, type, flags, dont_inherit):
# type: (unicode, unicode, unicode, Any, bool) -> Any
# type: (str, str, str, Any, bool) -> Any
return compile(code, name, self.type, flags, dont_inherit)

def test_group(self, group):
Expand Down Expand Up @@ -676,7 +676,7 @@ def run_setup_cleanup(runner, testcodes, what):


def setup(app):
# type: (Sphinx) -> Dict[unicode, Any]
# type: (Sphinx) -> Dict[str, Any]
app.add_directive("testsetup", TestsetupDirective)
app.add_directive("testcleanup", TestcleanupDirective)
app.add_directive("doctest", DoctestDirective)
Expand Down

0 comments on commit 7553c19

Please sign in to comment.