Commit e58ec5c7 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat: add a pip-compile command

parent 58588365c7a2
Pipeline #135517 failed with stage
in 1 minute and 46 seconds
import subprocess
from loguru import logger
from cube_doctor import Command
class PipCompile(Command):
command_name = "pip-compile"
BRANCH_NAME = "topic/default/update-pip-compile"
commit_message = "chore: update requirements.txt"
TARGETS = ()
AUTO_MR_AUTO_MERGE = False
def pre_check(self, root_files):
if "setup.py" not in root_files:
return "continue"
def modify_code(self, cube, repo, root_files, branches, other_args):
try:
repo.run_command("pip-compile setup.py > requirements.txt")
except subprocess.CalledProcessError:
import traceback
traceback.print_exc()
logger.error(f"Failed to run pip-compile on cube {cube.name}")
return
if "MANIFEST.in" in root_files:
manifest_content = repo.read_file("MANIFEST.in")
if "requirements.txt" not in manifest_content:
manifest_content = (
manifest_content.rstrip() + "\ninclude requirements.txt\n"
)
repo.write_file("MANIFEST.in", manifest_content)
repo.run_command("hg add requirements.txt")
yield {"branch_name": self.BRANCH_NAME, "commit_message": self.commit_message}
......@@ -19,6 +19,7 @@ from cube_doctor.transforms.run_script_no_mr import RunScriptNoMr
from cube_doctor.transforms.regenerate_gitlab_ci import RegenerateGitlabCI
from cube_doctor.transforms.rebase_all import RebaseAllMyMRs
from cube_doctor.transforms.set_cubes_cw_max_version import SetCubeCubicWebMaxVersion
from cube_doctor.transforms.pip_compile import PipCompile
COMMANDS = {
......@@ -37,6 +38,7 @@ COMMANDS = {
RegenerateGitlabCI,
RebaseAllMyMRs,
SetCubeCubicWebMaxVersion,
PipCompile,
]
}
......
Supports Markdown
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