Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
6d88b7ab
Unverified
Commit
6d88b7ab
authored
1 year ago
by
Norbert Szulc
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(manager/pip-compile): Handle isLockfileUpdate in updateArtifacts (#27353)
parent
82651110
Loading
Loading
Loading
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/modules/manager/pip-compile/artifacts.spec.ts
+46
-1
46 additions, 1 deletion
lib/modules/manager/pip-compile/artifacts.spec.ts
lib/modules/manager/pip-compile/artifacts.ts
+10
-1
10 additions, 1 deletion
lib/modules/manager/pip-compile/artifacts.ts
with
56 additions
and
2 deletions
lib/modules/manager/pip-compile/artifacts.spec.ts
+
46
−
1
View file @
6d88b7ab
...
...
@@ -9,7 +9,7 @@ import { logger } from '../../../logger';
import
*
as
docker
from
'
../../../util/exec/docker
'
;
import
type
{
StatusResult
}
from
'
../../../util/git/types
'
;
import
*
as
_datasource
from
'
../../datasource
'
;
import
type
{
UpdateArtifactsConfig
}
from
'
../types
'
;
import
type
{
UpdateArtifactsConfig
,
Upgrade
}
from
'
../types
'
;
import
{
constructPipCompileCmd
}
from
'
./artifacts
'
;
import
{
updateArtifacts
}
from
'
.
'
;
...
...
@@ -272,6 +272,33 @@ describe('modules/manager/pip-compile/artifacts', () => {
]);
});
it
(
'
uses --upgrade-package only for isLockfileUpdate
'
,
async
()
=>
{
fs
.
readLocalFile
.
mockResolvedValueOnce
(
simpleHeader
);
const
execSnapshots
=
mockExecAll
();
git
.
getRepoStatus
.
mockResolvedValue
(
partial
<
StatusResult
>
({
modified
:
[
'
requirements.txt
'
],
}),
);
fs
.
readLocalFile
.
mockResolvedValueOnce
(
'
New requirements.txt
'
);
expect
(
await
updateArtifacts
({
packageFileName
:
'
requirements.in
'
,
updatedDeps
:
[
{
depName
:
'
foo
'
,
newVersion
:
'
1.0.2
'
,
isLockfileUpdate
:
true
},
{
depName
:
'
bar
'
,
newVersion
:
'
2.0.0
'
},
]
satisfies
Upgrade
[],
newPackageFileContent
:
'
{}
'
,
config
:
{
...
lockMaintenanceConfig
,
lockFiles
:
[
'
requirements.txt
'
]
},
}),
).
not
.
toBeNull
();
expect
(
execSnapshots
).
toMatchObject
([
{
cmd
:
'
pip-compile --no-emit-index-url requirements.in --upgrade-package=foo==1.0.2
'
,
},
]);
});
it
(
'
uses pip-compile version from config
'
,
async
()
=>
{
fs
.
readLocalFile
.
mockResolvedValueOnce
(
simpleHeader
);
GlobalConfig
.
set
(
dockerAdminConfig
);
...
...
@@ -408,5 +435,23 @@ describe('modules/manager/pip-compile/artifacts', () => {
),
).
toThrow
(
/custom/
);
});
it
(
'
add --upgrade-package to command if Upgrade[] passed
'
,
()
=>
{
expect
(
constructPipCompileCmd
(
getCommandInHeader
(
'
pip-compile --output-file=requirements.txt requirements.in
'
,
),
'
subdir/requirements.txt
'
,
false
,
[
{
depName
:
'
foo
'
,
newVersion
:
'
1.0.2
'
},
{
depName
:
'
bar
'
,
newVersion
:
'
2.0.0
'
},
]
satisfies
Upgrade
[],
),
).
toBe
(
'
pip-compile --no-emit-index-url --output-file=requirements.txt requirements.in --upgrade-package=foo==1.0.2 --upgrade-package=bar==2.0.0
'
,
);
});
});
});
This diff is collapsed.
Click to expand it.
lib/modules/manager/pip-compile/artifacts.ts
+
10
−
1
View file @
6d88b7ab
...
...
@@ -10,7 +10,7 @@ import {
}
from
'
../../../util/fs
'
;
import
{
getRepoStatus
}
from
'
../../../util/git
'
;
import
*
as
pipRequirements
from
'
../pip_requirements
'
;
import
type
{
UpdateArtifact
,
UpdateArtifactsResult
}
from
'
../types
'
;
import
type
{
UpdateArtifact
,
UpdateArtifactsResult
,
Upgrade
}
from
'
../types
'
;
import
{
extractHeaderCommand
,
getExecOptions
,
...
...
@@ -21,6 +21,7 @@ export function constructPipCompileCmd(
content
:
string
,
outputFileName
:
string
,
haveCredentials
:
boolean
,
upgradePackages
:
Upgrade
[]
=
[],
):
string
{
const
compileArgs
=
extractHeaderCommand
(
content
,
outputFileName
);
if
(
compileArgs
.
isCustomCommand
)
{
...
...
@@ -56,12 +57,18 @@ export function constructPipCompileCmd(
)
{
compileArgs
.
argv
.
splice
(
1
,
0
,
'
--no-emit-index-url
'
);
}
for
(
const
dep
of
upgradePackages
)
{
compileArgs
.
argv
.
push
(
`--upgrade-package=
${
quote
(
dep
.
depName
+
'
==
'
+
dep
.
newVersion
)}
`
,
);
}
return
compileArgs
.
argv
.
map
(
quote
).
join
(
'
'
);
}
export
async
function
updateArtifacts
({
packageFileName
:
inputFileName
,
newPackageFileContent
:
newInputContent
,
updatedDeps
,
config
,
}:
UpdateArtifact
):
Promise
<
UpdateArtifactsResult
[]
|
null
>
{
if
(
!
config
.
lockFiles
)
{
...
...
@@ -89,12 +96,14 @@ export async function updateArtifacts({
if
(
config
.
isLockFileMaintenance
)
{
await
deleteLocalFile
(
outputFileName
);
}
const
upgradePackages
=
updatedDeps
.
filter
((
dep
)
=>
dep
.
isLockfileUpdate
);
const
packageFile
=
pipRequirements
.
extractPackageFile
(
newInputContent
);
const
registryUrlVars
=
getRegistryUrlVarsFromPackageFile
(
packageFile
);
const
cmd
=
constructPipCompileCmd
(
existingOutput
,
outputFileName
,
registryUrlVars
.
haveCredentials
,
upgradePackages
,
);
const
execOptions
=
await
getExecOptions
(
config
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment