Commit 65e27790 authored by Noé Gaumont's avatar Noé Gaumont 🐙
Browse files

feat(release-new): add a release-new transformation

parent 1dc89d3c26fd
......@@ -57,6 +57,12 @@ This command will:
- or if a dev-requirements.txt exist, add it into it instead
- modify .gitlag-ci.yml "py3" section to add "py3-deprecated-warnings.json" has an artifact
release-new
~~~~~~~~~~~
This command will modify the base tox.ini to add `release-new`.
This tox rule eases the creation of tag version correctly.
add-tox
~~~~~~~
......
......@@ -18,6 +18,7 @@ from cube_doctor.transforms.add_pytest_deprecated_warnings import (
from cube_doctor.transforms.readme_rst import READMERst
from cube_doctor.transforms.update_cube_licence_dates import UpdateCubeLicenceDates
from cube_doctor.transforms.add_yamllint import AddYamlLint
from cube_doctor.transforms.add_release_new import AddReleaseNew
from cube_doctor.transforms.run_script import RunScript
from cube_doctor.transforms.regenerate_gitlab_ci import RegenerateGitlabCI
from cube_doctor.transforms.rebase_all import RebaseAllMyMRs
......@@ -92,6 +93,7 @@ commands = {
"add-pypi-publish": AddPypiPublish().workflow,
"add-deb-publish": AddDebPublish().workflow,
"add-yamllint": AddYamlLint().workflow,
"add-release-new": AddReleaseNew().workflow,
"replace-set-attributes": ReplaceSetAttributesWithSetCW().workflow,
"update-licence-dates": UpdateCubeLicenceDates().workflow,
"auto-upgrade-dependencies": AutoUpgradeDependencies().workflow,
......
from tox.config import parseconfig
from cube_doctor import Command
RELEASE_NEW = """
[testenv:release-new]
basepython = python3
skip_install = true
passenv =
EDITOR
deps =
release-new
commands = release-new {posargs:-r auto}
"""
class AddReleaseNew(Command):
BRANCH_NAME = "topic/default/add_release_new"
commit_message = "chore(tox): add release-new"
base_query = "?project lgg:is_cube true . ?project lgg:has_tox true"
AUTO_MR_AUTO_MERGE = False
def pre_check(self, root_files):
if "tox.ini" in root_files:
return "continue"
def modify_code(self, cube, repo, root_files, branches, other_args):
tox_ini_path = repo.path / "tox.ini"
tox = parseconfig(["-c", str(tox_ini_path)])
if "release-new" in tox.envconfigs:
return
tox_content = repo.read_file("tox.ini")
tox_content = tox_content.rstrip() + RELEASE_NEW
repo.write_file("tox.ini", tox_content)
yield {"branch_name": self.BRANCH_NAME, "commit_message": self.commit_message}
[tox]
envlist = py3
[testenv]
deps =
pytest
commands =
{envpython} -m pytest {posargs:test}
[tox]
envlist = py3
[testenv]
deps =
pytest
commands =
{envpython} -m pytest {posargs:test}
[testenv:release-new]
basepython = python3
skip_install = true
passenv =
EDITOR
deps =
release-new
commands = release-new {posargs:-r auto}
import unittest
from cube_doctor.transforms.add_release_new import AddReleaseNew
from . import BaseCommandTC, TEST_DATA
class AddReleaseNewTC(BaseCommandTC):
def test_addrelease_new(self):
data_input = TEST_DATA / "add_release_new" / "in"
data_output = TEST_DATA / "add_release_new" / "out"
self.base_execution(AddReleaseNew(), data_input, data_output)
def test_addrelease_new_indempotent(self):
data_output = TEST_DATA / "add_release_new" / "out"
self.base_execution(AddReleaseNew(), data_output, data_output)
if __name__ == "__main__":
unittest.main()
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