Skip to content

Conversation

@polfeliu
Copy link
Contributor

@polfeliu polfeliu commented Dec 22, 2025

Description

This pull request is a proposal to organize pipelines that depend on venvs and poetry. It has been implemented here as a previous step to demonstrate that this can be done with groovy closure patterns as a previous step to migrate it to cicdlib.

Type of change

Please add a description and delete options that are not relevant.

  • Create class that is able to create virtualenvironments and manage
  • Installer of poetry
  • Test Manager (extra, as I needed access to venvmanager every time)

I will also list some possible improvements that could be done. I would encourage that this be done before the migration:

  • Try to initialize (maybe it's not possible) the venv without the activate script. The activate script only modifies some env variables that could be set with withEnv()
  • Partially move the coverage stashing and merging logic to the test manager.
  • Move markersExcludeString or any possbile marker helper to test manager
  • Run all tests with the same, or variant methods of runTestHW. Maybe rename the method (INGK-1219)
  • Make the test more generic so it could also be migrated to cicdlib. Right now it contains references to ingenialink. I would do the assumption that test manager is for any pytest, and possibly uses the framework (not required)

Tests

  • Run pipeline with min, max , min_max, and all python configs

Please describe the manual tests that you ran to verify your changes if it applies.

Documentation

Please update the documentation.

  • Update docstrings of every function, method or class that change.
  • Build documentation locally to verify changes.
  • Add the changes at the [Unreleased] section of the CHANGELOG.

@polfeliu polfeliu marked this pull request as ready for review December 22, 2025 13:46
Copy link
Contributor

@julieta-prieto julieta-prieto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the other PR, I believe this goes beyond the scope of the original issue.

While I understand the intent behind this proposal, it feels somewhat overcomplicated for our current needs and would require significant effort to adapt across all repositories.
I’m also concerned that it may not be very intuitive for quick adoption.

Additionally, as noted in the PR description, further development in the test manager is needed before this approach can be broadly useful.

* folder: Folder path to change to (optional)
* body: Closure to execute inside the folder
*/
def runInFolder(folder = null, body) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the point of this method is to run a piece of code in a folder, why is folder optional?

activateCmd = "call ${venvName}\\Scripts\\activate\n "
}
this.runInFolder(workingDir) { folderCtx ->
folderCtx.run(activateCmd + cmd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is activateCmd + cmd concatenating commands or doing something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, cd folder and python activation are the exceptions to the rule we are doing.
Although we can explore to avoid the activate cmd with the point I mention on the PR:

  • Try to initialize (maybe it's not possible) the venv without the activate script. The activate script only modifies some env variables that could be set with withEnv()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it have to be an exception?
What is the difference with the rest of commands that don't need to be concatenated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it retains a context in the powershell and luckily the exit code is not as relevant in terms of validation. Its not that i dont want to get rid of it, its that i dont see how

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it retains a context in the powershell and luckily the exit code is not as relevant in terms of validation. Its not that i dont want to get rid of it, its that i dont see how

Comment on lines +346 to +348
def wiresharkScope = ""
def clearSuccessfulWiresharkLogs = true
def startWiresharkTimeoutS = 10.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to configure each of these in each pipeline, we could add that to the constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, there's a lot of work to be done specially on the pytestManager to make it generic enought to be migrated to cicdlib. I have focused on the venvmanager but it was easier to wrap this here locally too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just pointing that same as runPythonVersions, this should be there too.
If you intend to merge this PR, I would not leave the pytestManager half way. I would add everything we need to be configurable, or remove it and leave it for the future.

def lin_marker = markersExcludeString(HARDWARE_MARKERS + ["virtual", "no_pcap"])
venvManager.withPython(DEFAULT_PYTHON_VERSION, env.WORKING_FOLDER) { venv ->
venv.run("poetry run poe install-wheel")
venv.run("""poetry run poe tests --junitxml=pytest_reports/junit-tests-${venv.name}.xml --junit-prefix=${venv.name} -m '${lin_marker}' -o log_cli=True""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why """ is needed here rather than single quotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not needed. I've been mininmal regarding what to change in the pipeline

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "what to change in the pipeline"?
Isn't this line a new addition from this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those lines have been changed, not fully new. but yes, we can change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those lines have been changed, not fully new. but yes, we can change

Comment on lines 681 to 684
sh """
mkdir -p pytest_reports
cp ${LIN_DOCKER_TMP_PATH}/pytest_reports/* pytest_reports/
cp ${env.WORKING_FOLDER}/pytest_reports/* pytest_reports/
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to change this to single-line commands as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point we should

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not now? Isn't it possible with the architecture you proposed?

"""
venvManager.forPythons(env.WORKING_FOLDER, testManager.runPythonVersions) { venv ->
venv.run("poetry run poe install-wheel")
venv.run("""poetry run poe tests --junitxml=pytest_reports/junit-tests-${venv.version}.xml --junit-prefix=${venv.version} -m virtual --setup summit_testing_framework.setups.virtual_drive.TESTS_SETUP -o log_cli=True""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question regarding the quotes

Comment on lines 705 to 708
sh """
mkdir -p pytest_reports
cp ${LIN_DOCKER_TMP_PATH}/pytest_reports/* pytest_reports/
cp ${env.WORKING_FOLDER}/pytest_reports/* pytest_reports/
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to change this to single-line commands as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants