Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cube-doctor
Commits
9a093a7759cd
Commit
e58ec5c7
authored
May 21, 2022
by
Laurent Peuch
Browse files
feat: add a pip-compile command
parent
58588365c7a2
Pipeline
#135517
failed with stage
in 1 minute and 46 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cube_doctor/transforms/pip_compile.py
0 → 100644
View file @
9a093a77
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
()
+
"
\n
include 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
}
cube_doctor/utils.py
View file @
9a093a77
...
...
@@ -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
,
]
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment