openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

[ci] Investigate and brainstorm ways to speed up CI

Open pandafy opened this issue 8 months ago • 13 comments

The CI pipeline is currently running over 1000 tests, which can result in prolonged build and feedback times. This issue is for brainstorming and tracking ideas to optimize, speed up, or parallelize the CI process.

Potential discussion points:

  • Identifying the slowest parts of the CI
  • Opportunities for test parallelism or sharding
  • Caching dependencies or test results
  • Removing unnecessary or redundant tests
  • Leveraging incremental or selective test runs for PRs
  • CI configuration or workflow improvements

Contributions and suggestions from the community are welcome!

pandafy avatar Mar 24 '26 20:03 pandafy

Hi, I would like to contribute to this discussion.

I noticed that the CI runs a large number of tests (1000+), which likely increases execution time significantly. Based on this, I have a few suggestions:

  1. Test Parallelization If not already implemented, splitting the test suite across multiple jobs could reduce total runtime.

  2. Caching Improvements It may help to cache Python dependencies (pip) and possibly Docker layers to avoid repeated installations.

  3. Identify Slow Tests Running tests with profiling (e.g., pytest --durations) could help identify bottlenecks in the slowest tests.

  4. Selective Test Execution For certain PRs, it might be possible to run only relevant tests based on changed modules.

I would be interested in helping analyze the current CI workflow and identifying specific slow points or improvements.

Please let me know if I can proceed with profiling or investigating the CI setup further.

Thank you!

k-sumayya avatar Mar 24 '26 20:03 k-sumayya

@k-sumayya tests already run in parallel AFAIK and selenium tests are run only once, so I don't think there's much room for 1 and 4 but feel free to explore if you think you can find anything positive.

2 and 3 are probably the most relevant points. However, please keep in mind that letting LLM tools handle this without understanding what is really going on will not be considered a valid contribution, will be flagged as spam and closed. We need real effort, not LLM prompting.

nemesifier avatar Mar 24 '26 21:03 nemesifier

Thanks for the clarification!

That makes sense about parallelization and Selenium tests. I’ll focus on caching and understanding how tests are currently executed.

I’m going to go through the CI workflow files and also try running the test suite locally to see where most of the time is spent (using pytest durations).

Once I have some concrete observations, I’ll share specific findings instead of assumptions.

Appreciate the guidance!

k-sumayya avatar Mar 25 '26 03:03 k-sumayya

I would personally focus on :

  • Identifying the slowest parts of the CI
  • Removing unnecessary or redundant tests
  • CI configuration or workflow improvements

over the other points, as I think they carry a risk to make the test setup more complex and fragile than it currently is.

Also the number of test isn't a problem in itself, but the time they take versus the amount of confidence they provide the developer might not feel worth it sometimes... => we should look for ways to make tests more meaningful and useful.

For improvements I would look at :

  • Give detailed feedback to the developer earlier in the workflow, before tests, via type hints (I already started doing this in the extended version I m working on)
  • Reduce the matrix of tests. We probably don't need all django / python version tests all the time on all branches (I'm also doing this, focusing on packaged versions in debian releases). Not sure if it will actually speedup the CI though, depending on how github allocates resources for a project... Might be worth a try, if it wasn't done before ?
  • Simplify the test setup if possible and make tool usage consistent across all repos (django test / selenium / pytest / coverage / --parallel / etc.)
  • Simplify the test setup by (gradually) making tests/openwisp2/settings.py similar in all repos. The aim is to force the developer to embed all necessary, specific, settings for a test with the test code (via override_settings or modify_settings as context manager), which shall in turn give us more isolated/modular sets of tests. Hopefully these tests can, in time, be run in various ways with more confidence, and shall eventually prove more reliable and useful. Maybe we also will, along the way, find a better way to organize tests... Full disclosure: The lack of isolation in tests is the biggest time sink for me currently, as it forces me to rerun them multiple times in various contexts to find subtle issues (or just a missing setting)...

And finally, we can investigate potential simplifications/optimizations of the whole software stack, which we can start only after identifying the actual bottlenecks.

I can help with some of these, let me know what you think.

asmodehn avatar Apr 13 '26 08:04 asmodehn

Hi @nemesifier @pandafy is anyone working on this issue? If not I would like to help with this as I have some experience with CI's.

It may take me a time to come up with a concrete solution but I'll keep you updated on the way

CodingWithSaksham avatar May 12 '26 09:05 CodingWithSaksham

Hi @nemesifier @pandafy is anyone working on this issue? If not I would like to help with this as I have some experience with CI's.

It may take me a time to come up with a concrete solution but I'll keep you updated on the way

We're open to improvements, given the fact that it seems you don't have experience with openwisp I'd focus on small demonstrable improvements for your first PR.

nemesifier avatar May 12 '26 17:05 nemesifier

Hi @nemesifier @pandafy is anyone working on this issue? If not I would like to help with this as I have some experience with CI's. It may take me a time to come up with a concrete solution but I'll keep you updated on the way

We're open to improvements, given the fact that it seems you don't have experience with openwisp I'd focus on small demonstrable improvements for your first PR.

Makes sense. I'll focus on some smaller PR first, if you have any small issues in mind, please do point me to them. Thanks!

CodingWithSaksham avatar May 12 '26 17:05 CodingWithSaksham

@CodingWithSaksham please join the OpenWISP dev chat and let's keep the github issues on topic.

nemesifier avatar May 12 '26 17:05 nemesifier

Hi @nemesifier @asmodehn @pandafy, can i work on this ?

What I Understood:

  • The Pipeline: Each of the 11 matrix jobs runs ./run-qa-checks and ./runtests (which runs standard tests -> Selenium pass -> SAMPLE_APP=1 pass).
  • The Redundancies:
    • Running ./run-qa-checks (including NPM prettier and APT geospatial packages installation) on all 11 matrix cells is highly repetitive.
    • Selenium tests run sequentially in every single matrix job (~11× per PR/Push).
    • The pip cache is already enabled; the main time sink is environment setups and running duplicate Selenium/QA work.

Solution

  1. QA in a Single, Standalone Job (Matrix-Independent)

    • Run ./run-qa-checks once (e.g., in a single job on Python 3.12) instead of in every matrix cell.
    • Goal: Avoid duplicate npm, pip, apt, and lint/migration work across the matrix.
  2. Slimmer Matrix on PRs, Full Matrix on Master

    • PRs: Run only the boundary environments (e.g., Python 3.10 + Django 4.2 and Python 3.13 + Django 5.2).
    • Master: Keep the current full 11-cell compatibility matrix.
    • Goal: Blazing-fast PR feedback loop for contributors; comprehensive compatibility checking upon merge.
  3. Selenium Once per PR/Push

    • Run the selenium_tests pass only on a single matrix environment (e.g., Python 3.13 + Django 5.2) and exclude it from the other cells.
    • Goal: Browser tests check admin/UI behavior which is independent of minor Python/Django combinations. Binding it to one common environment ensures it runs exactly once per pipeline run.

prathmeshkulkarni-coder avatar May 21 '26 17:05 prathmeshkulkarni-coder

Hi @prathmeshkulkarni-coder 👋,

Thank you for your interest in contributing to OpenWISP! 🎉

According to our contributing guidelines, you don't need to wait to be assigned to start working on an issue. We encourage you to:

  1. Fork the repository and start working on your solution
  2. Open a Pull Request (PR) as soon as possible - even as a draft if it's still in progress
  3. Link your PR to this issue by including one of the following in the PR description:
    • Closes #1317 for features/changes
    • Fixes #1317 for bugs
    • Related to #1317 for PRs that contribute but don't completely solve the issue

Once you open a PR that references this issue, you will be automatically assigned to it.

This approach helps us:

  • See your progress and provide early feedback
  • Avoid multiple contributors working on the same issue unknowingly
  • Keep the contribution process moving smoothly

We look forward to your contribution! If you have any questions, feel free to ask in the PR or check our documentation.

Happy coding! 🚀

openwisp-companion avatar May 21 '26 17:05 openwisp-companion

This issue has been automatically assigned to @CodingWithSaksham who opened PR #1381 to address it. 🎯

openwisp-companion avatar May 28 '26 10:05 openwisp-companion

  • Run the selenium_tests pass only on a single matrix environment (e.g., Python 3.13 + Django 5.2) and exclude it from the other cells.

I don't agree with this. The CSS styles in Django evolve over time. Tests which passes in Django 5.2 may fail in Django 6.2 and so on. So, we need to run selenium tests in all environments.

pandafy avatar May 29 '26 10:05 pandafy

Let's discuss in https://github.com/orgs/openwisp/discussions/1383.

nemesifier avatar Jun 04 '26 17:06 nemesifier