News for hackers. Stuff that matters.

Show HN: Skip tests unaffected by code change.

https://github.com/nabaz-io/nabaz

Hi, we're Yuval and Roey. We are working on nabaz A CI/CD plugin that runs only the tests affected by a code change by looking at the code covered by each test. Skipping 80-95% of tests.

We started a few months ago, and have managed to get into a few production CI systems here in Israel. (startups only for now).

All our prospects and users are on holiday RN lol, October is a series of jewish holidays, the entire business-month doesn't exist, at least for scheduling meetings.

Scared of our progress halting completely for the whole month

we decided to repackage our CI/CD solution for dev local use, and open-source it.

Our test runner is available on GitHub (https://github.com/nabaz-io/nabaz) under MIT license.

Give us feedback. Stalk us on GitHub, or just Star us.

We encourage you to ask questions, we’ll both be here answering them.

Yuval and Roey from Israel. לילה טוב ומנב"ז

( 17 comments | 2 points | on HN )
Re:Show HN: Skip tests unaffected by code change. by metadat on Wednesday October 12, 2022 @06:47PM (#33184746)
Cool idea.. Has this strategy already been tried before?
Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Wednesday October 12, 2022 @06:56PM (#33184858)
Facebook and Google employ AI based methods for skipping tests (See): https://static.googleusercontent.com/media/research.google.c...

they are pretty much flawed in a way, because they require you to wait weeks/months to gain statistical sagnificance. And even then they are too costly to train to make sense in smaller scales.

There's an old ex-Google employee who came out with something similar in 2005 for JUnit java tests. We talked to him and ulitmatly he sunsetted the project because static analysis back then was basically copying language parser code from the Language distro and retro fitting it.

Static analysis has gone a long way since though... and no one has yet to deploy something that works for system tests and integration tests in this strategy.

Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Wednesday October 12, 2022 @06:51PM (#33184786)
How it works: First time you run nabaz:

1. Collects code coverage for every tests that runs, seperatly.

2. Saves code coverage in local sqlite db, along with commit ID as key.

Second to n runs later:

1. Traverse git tree and queries db via commit ID -> per test code coverage

2.a git diff between new code (code change) and the code coverage from the old commit, test case by test case.

2.b. If an intersection between new code and old code coverage is found, test is rerun. else, it will be skipped.

Re:Show HN: Skip tests unaffected by code change. by maxilevi on Wednesday October 12, 2022 @06:55PM (#33184839)
How do you deal with tests that interact with something external to the codebase? The result of those could potentially change without a code change.
Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Wednesday October 12, 2022 @07:05PM (#33184950)
That's a great point!

Depends on the what you define by "externality".

I like to look at it this way, what's being tested? I see three groups:

  - testing the software you wrote.
  - testing integration with other software you wrote (microservice interaction maybe?)
  - testing integration to third party software.
I'm telling you our current plan, feel free to poke holes:

In the first case the only externalities that seem to really matter are mostly resource and configuration files. We could detect I/O with such files and rerun the test if the underlying resource/config changed.

In the second case were planning on collecting coverage for all services being tested and then employ a more sophisticated diff heurastic.

For the third case you can mark the test as always run

We have a poc of a syscall tracer that gives us an I/O map of the test being run or the software being tested. this includes reading/writing to files, pipes, network etc...

Re:Show HN: Skip tests unaffected by code change. by metadat on Wednesday October 12, 2022 @07:13PM (#33185034)
This sounds like the best you could possibly do!

What are the odds this baby will be made compatible with Java?

Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Wednesday October 12, 2022 @07:19PM (#33185079)
java is scheduled next, would absolutely love to hear about your use-case?
Re:Show HN: Skip tests unaffected by code change. by metadat on Wednesday October 12, 2022 @07:48PM (#33185325)
I have a pretty large Java code base (40+ micro services) and the integration test suite takes hours, many hours, to run.

However they are usually testing components from end-to-end. This seems not very amenable to benefitting this approach, since "side effects" are an inherent part of nearly every integration test.

Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Wednesday October 12, 2022 @07:55PM (#33185387)
Wow! Seems like a challenge to test, would love to see what we can do.

Regarding side effects, completely fine as long as they're mapped out. Would love to hear more, nothing pitchy or salesy.

hmu [email protected]

Re:Show HN: Skip tests unaffected by code change. by bary12 on Thursday October 13, 2022 @03:59AM (#33188448)
This looks interesting and definitely something missing from our CI pipeline. What languages do you intend to support?
Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Thursday October 13, 2022 @07:00AM (#33189462)
Basically all of them as long as their used.

Would love to know more about your use case, email is somewhere in the comments

Re:Show HN: Skip tests unaffected by code change. by Spongego on Thursday October 13, 2022 @04:51AM (#33188732)
Sounds super cool! I’ll definitely show this to our devops guy in the company. However sounds like there might be a lot of edge cases that don’t include any code changes, e.g. some environment variable changes - have you thought about it?
Re:Show HN: Skip tests unaffected by code change. by Roeylalazar on Thursday October 13, 2022 @05:52AM (#33189105)
Hey, awsome! feel free to contact us at [email protected].

About the env vars: yes. We have a list of edge cases that might affect the tests. Env vars specifically is the next edge case we are about to cover.

Roey from nabaz.

Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Thursday October 13, 2022 @07:02AM (#33189474)
THIS point though, Im inclined to share our edge case doc with HN and let people add stuff.
Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Friday October 14, 2022 @09:40AM (#33203361)
Thanks guys for all your feedback!

We took all notes to heart, the main problem we identified that currently (at this stage of the product cycle we don't yet support all edge cases)

And this hurts usability and value, will figure out a way to deliver this kind of tech in a way that is still valuable at this early stage :)

Yuval

Re:Show HN: Skip tests unaffected by code change. by adamantinecog on Friday October 14, 2022 @01:42PM (#33206606)
I'm wondering if this works similar to https://github.com/digitalocean/gta which will do transitive analysis to find packages whose dependencies have changed and only run the tests for those packages?
Re:Show HN: Skip tests unaffected by code change. by yuvalsteuer on Saturday October 15, 2022 @04:34AM (#33212978)
We love gta! A few key differences though: 1. We analyze the effect of code changed on code coverage, which means we only compare changed code to runtime information (code that actually ran). gta analyzes statically.

Let's assume you have a function:

  func myFunction(a int) {

      if(a > 10) {  

          func1()  

      } else if (a < 4) {  

          func2()  

      } else {  

          func3()

      }  
  }
let's assume you changed func3 only, or func2, but during the run of the test only func1 ran.

The test will be skipped because no change could of affected it's result. NOT in gta.