Commit 1038a2ec authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat(qa): check commands with have in tox.ini

parent d22f1dc6e663
Pipeline #12326 passed with stages
in 1 minute and 46 seconds
......@@ -3,6 +3,9 @@
import os
import gitlab
import jinja2
import tempfile
from tox.config import parseconfig
gl = gitlab.Gitlab("https://forge.extranet.logilab.fr", oauth_token=os.environ.get("TOKEN"))
......@@ -10,22 +13,19 @@ context = {"cubes": {}}
all_cubes = [x for x in gl.projects.list(all=True) if x.namespace["name"] == "cubes"]
for cube in all_cubes:
# black
# check-manifest
# tests
for number, cube in enumerate(all_cubes):
# python3
# flake8
# doc8
# a de la doc
# safety
# deprecation warnings ?
try:
cube.files.get("tox.ini", ref="branch/default")
tox_content = cube.files.get("tox.ini", ref="branch/default").decode().decode("Utf-8")
has_tox = True
except (gitlab.GitlabHttpError, gitlab.GitlabGetError):
has_tox = False
tox_content = None
try:
cube.files.get(".gitlab-ci.yml", ref="branch/default")
......@@ -43,11 +43,44 @@ for cube in all_cubes:
except (gitlab.GitlabHttpError, gitlab.GitlabGetError):
has_readme_rst = False
if tox_content is not None:
with tempfile.TemporaryDirectory() as temporary_directory_path:
# TODO pyproject.toml
tox_path = os.path.join(temporary_directory_path, "tox.ini")
open(tox_path, "w").write(tox_content)
tox_config = parseconfig(["-c", tox_path])
has_py2_tests = any([x.startswith("py2") for x in tox_config.envlist])
has_py3_tests = any([x.startswith("py3") for x in tox_config.envlist])
has_check_manifest = "check-manifest" in tox_config.envlist
has_black = "black" in tox_config.envlist
has_mypy = "mypy" in tox_config.envlist
has_flake8 = "flake8" in tox_config.envlist
has_from_forge = any(["from-forge" in x for x in tox_config.envlist])
# has_doc8, check if has doc first
# has_pytest_html
# has_pytest_capture_deprecationwarnings
else:
has_py2_tests = False
has_py3_tests = False
has_check_manifest = False
has_black = False
has_mypy = False
has_flake8 = False
has_from_forge = False
context["cubes"][cube.name] = {
"cube": cube.attributes,
"has_tox": has_tox,
"has_gitlab_ci": has_gitlab_ci,
"has_readme_rst": has_readme_rst,
"has_py2_tests": has_py2_tests,
"has_py3_tests": has_py3_tests,
"has_check_manifest": has_check_manifest,
"has_black": has_black,
"has_mypy": has_mypy,
"has_flake8": has_flake8,
"has_from_forge": has_from_forge,
}
os.system("mkdir -p public") # XXX lazy
......
......@@ -14,6 +14,13 @@
<th>has tox?</th>
<th>has gitlab-ci?</th>
<th>README.rst? (or md)</th>
<th>has py2 tests?</th>
<th>has py3 tests?</th>
<th>has check manifest?</th>
<th>has flake8?</th>
<th>has black?</th>
<th>has mypy?</th>
<th>has from forge?</th>
</tr>
{% for cube in cubes.values() %}
{% if "project-dependency" in cube["cube"]["tag_list"] %}
......@@ -22,6 +29,23 @@
<td class="{{ "true" if cube["has_tox"] else "false" }}"></td>
<td class="{{ "true" if cube["has_gitlab_ci"] else "false" }}"></td>
<td class="{{ "true" if cube["has_readme_rst"] else "false" }}"></td>
{% if cube["has_tox"] %}
<td class="{{ "true" if cube["has_py2_tests"] else "" }}"></td>
<td class="{{ "true" if cube["has_py3_tests"] else "false" }}"></td>
<td class="{{ "true" if cube["has_check_manifest"] else "false" }}"></td>
<td class="{{ "true" if cube["has_flake8"] else "false" }}"></td>
<td class="{{ "true" if cube["has_black"] else "false" }}"></td>
<td class="{{ "true" if cube["has_mypy"] else "false" }}"></td>
<td class="{{ "true" if cube["has_from_forge"] else "false" }}"></td>
{% else %}
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
......@@ -36,6 +60,13 @@
<th>has tox?</th>
<th>has gitlab-ci?</th>
<th>README.rst? (or md)</th>
<th>has py2 tests?</th>
<th>has py3 tests?</th>
<th>has check manifest?</th>
<th>has flake8?</th>
<th>has black?</th>
<th>has mypy?</th>
<th>has from forge?</th>
</tr>
{% for cube in cubes.values() %}
{% if "project-dependency" not in cube["cube"]["tag_list"] %}
......@@ -44,6 +75,23 @@
<td class="{{ "true" if cube["has_tox"] else "false" }}"></td>
<td class="{{ "true" if cube["has_gitlab_ci"] else "false" }}"></td>
<td class="{{ "true" if cube["has_readme_rst"] else "false" }}"></td>
{% if cube["has_tox"] %}
<td class="{{ "true" if cube["has_py2_tests"] else "" }}"></td>
<td class="{{ "true" if cube["has_py3_tests"] else "false" }}"></td>
<td class="{{ "true" if cube["has_check_manifest"] else "false" }}"></td>
<td class="{{ "true" if cube["has_flake8"] else "false" }}"></td>
<td class="{{ "true" if cube["has_black"] else "false" }}"></td>
<td class="{{ "true" if cube["has_mypy"] else "false" }}"></td>
<td class="{{ "true" if cube["has_from_forge"] else "false" }}"></td>
{% else %}
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment