Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use git clean in tox stages #556

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions vars/runJenkinsPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -502,32 +502,26 @@ def call(){
def image = docker.build(UUID.randomUUID().toString(), '-f ci/docker/python/linux/jenkins/Dockerfile .')
try{
image.inside('--mount source=python-tmp-speedwagon,target=/tmp'){
try{
sh( label: 'Running Tox',
script: """python3 -m venv venv && venv/bin/pip install --disable-pip-version-check uv
. ./venv/bin/activate
uv python install cpython-${version}
uvx -p ${version} --with tox-uv tox run -e ${toxEnv}
"""
)
} catch(e) {
sh(script: '''. ./venv/bin/activate
uv python list
'''
)
throw e
} finally{
cleanWs(
patterns: [
[pattern: 'venv/', type: 'INCLUDE'],
[pattern: '.tox/', type: 'INCLUDE'],
[pattern: '**/__pycache__/', type: 'INCLUDE'],
]
sh( label: 'Running Tox',
script: """python3 -m venv venv && venv/bin/pip install --disable-pip-version-check uv
trap "rm -rf venv" EXIT
. ./venv/bin/activate
uv python install cpython-${version}
trap "rm -rf ./venv ./.tox" EXIT
uvx -p ${version} --with tox-uv tox run -e ${toxEnv}
"""
)
}
}
} finally {
sh "docker image rm --force ${image.imageName()}"
sh "${tool(name: 'Default', type: 'git')} clean -dfx"
cleanWs(
patterns: [
[pattern: 'venv/', type: 'INCLUDE'],
[pattern: '.tox/', type: 'INCLUDE'],
[pattern: '**/__pycache__/', type: 'INCLUDE'],
]
)
}
}
}
Expand All @@ -553,7 +547,7 @@ def call(){
script{
def envs = []
node('docker && windows'){
docker.image('python').inside('--mount source=python-tmp-speedwagon,target=C:\\Users\\ContainerUser\\Documents'){
docker.image('python').inside("--mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){
try{
checkout scm
bat(script: 'python -m venv venv && venv\\Scripts\\pip install --disable-pip-version-check uv')
Expand Down Expand Up @@ -581,26 +575,35 @@ def call(){
{
node('docker && windows'){
try{
docker.image('python').inside('--mount source=python-tmp-speedwagon,target=C:\\Users\\ContainerUser\\Documents --mount source=msvc-runtime,target=$VC_RUNTIME_INSTALLER_LOCATION'){
docker.image('python').inside("--mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){
checkout scm
retry(3){
bat(label: 'Running Tox',
script: """python -m venv venv && venv\\Scripts\\pip install --disable-pip-version-check uv
venv\\Scripts\\uv python install cpython-${version}
venv\\Scripts\\uvx -p ${version} --with tox-uv tox run -e ${toxEnv}
rmdir /S /Q venv
"""
)
}
}
} finally{
cleanWs(
patterns: [
[pattern: 'venv/', type: 'INCLUDE'],
[pattern: '.tox', type: 'INCLUDE'],
[pattern: '**/__pycache__/', type: 'INCLUDE'],
]
)
retry(3){
try{
bat "${tool(name: 'Default', type: 'git')} clean -dfx"
} catch(e) {
echo 'failed to run git clean, sleeping for one second before moving forward to see if any processes are still running'
sleep 1
throw e
} finally{
cleanWs(
patterns: [
[pattern: 'venv/', type: 'INCLUDE'],
[pattern: '.tox', type: 'INCLUDE'],
[pattern: '**/__pycache__/', type: 'INCLUDE'],
]
)
}
}
}
}
}
Expand Down Expand Up @@ -730,7 +733,7 @@ def call(){
docker {
image 'python'
label "${OS} && ${ARCHITECTURE} && docker"
args "--mount source=python-tmp-speedwagon,target=${['windows'].contains(OS) ? 'C:\\Users\\ContainerUser\\Documents': '/tmp'} ${['windows'].contains(OS) ? '--mount source=msvc-runtime,target=c:\\msvc_runtime\\': ''}"
args "--mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR} ${['windows'].contains(OS) ? '--mount source=msvc-runtime,target=c:\\msvc_runtime\\': ''}"
}
}
steps {
Expand Down
Loading