News for hackers. Stuff that matters.
Re:I'll think twice before using GitHub Actions again by hinkley on Monday January 20, 2025 @06:08PM (#42774235)
Re: monorepo

> In GitHub you can specify a "required check", the name of the step in your pipeline that always has to be green before a pull request is merged. As an example, I can say that web-app1 - Unit tests are required to pass. The problem is that this step will only run when I change something in the web-app1 folder. So if my pull request only made changes in api1 I will never be able to merge my pull request!

Continuous Integration is not continuous integration if we don’t test that a change has no deleterious side effects on the rest of the system. That’s what integration is. So if you aren’t running all of the tests because they’re slow, then you’re engaging in false economy. Make your tests run faster. Modern hardware with reasonable test runners should be able to whack out 10k unit tests in under a minute. The time to run the tests goes up by a factor of ~7-10 depending on framework as you climb each step in the testing pyramid. And while it takes more tests to cover the same ground, with a little care you can still almost halve the run time replacing one test with a handful of tests that check the same requirement one layer down, or about 70% moving down two layers.

One thing that’s been missing from most of the recent CI pipelines I’ve used is being able to see that a build is going to fail before the tests finish. The earlier the reporting of the failure the better the ergonomics for the person who triggered the build. That’s why the testing pyramid even exists.

Re:I'll think twice before using GitHub Actions again by rustd on Monday January 20, 2025 @06:27PM (#42774404)
Agreed, most of the CI tools don't help in getting feedback early to the developers. I shouldn't have to wait hours for my CI job to complete. Harness is a tool that can reduce build times by caching build artifacts, docker layers and only running a subset of tests that were impacted the by the code change.
Re:I'll think twice before using GitHub Actions again by maccard on Monday January 20, 2025 @06:31PM (#42774442)
I agree hardware should be that quick, but CI and cloud hardware is woefully underpowered unless you actively seek it out. I’ve also never seen a test framework spew out even close to that in practice. I’m not even sure most frameworks would do that with noop tests, which is sad.
Re:I'll think twice before using GitHub Actions again by hinkley on Monday January 20, 2025 @08:04PM (#42775140)
10 years ago my very testing-competent coworker had us running 4200 tests in 37 seconds. In NodeJS. We should be doing as well that today without a gifted maintainer.
Re:I'll think twice before using GitHub Actions again by maccard on Tuesday January 21, 2025 @06:40AM (#42779043)
I've got an i9 and an NVMe drive. running npm test with 10k no-op tests takes 30 seconds, which is much quicker than I expected it to be (given how slow everything else in the node world is).

Running dotnet test on the other hand with 10k empty tests took 95 seconds.

Honestly, 10k no-op tests should be limited by disk IO, and in an ideal world would be 10 seconds.

Re:I'll think twice before using GitHub Actions again by hinkley on Tuesday January 21, 2025 @03:21PM (#42784763)
> disk IO

How many tests did you put in each file?

Re:I'll think twice before using GitHub Actions again by maccard on Tuesday January 21, 2025 @04:57PM (#42785606)
2500!
Re:I'll think twice before using GitHub Actions again by ecosystem on Tuesday January 21, 2025 @12:17AM (#42776882)
This comment is way too far down the page.

If the unit tests are slow enough to want to skip them, they likely are not unit tests but some kind of service-level tests or tests that are hitting external APIs or some other source of a bad smell. If the slow thing is the build, then cache the artifact keyed off the directory contents so the step is fast if code is unchanged. If the unit tests only run for a package when the code changes, there is a lack of e2e/integration testing. So, what is OP's testing strategy? Caching? It seems like following good testing practices would make this problem disappear.

Re:I'll think twice before using GitHub Actions again by jcarrano on Tuesday January 21, 2025 @07:58AM (#42779609)
That is true for most cases, which nowadays is web and backend software. As you get into embedded or anything involving hardware things get slower and you need to optimize.

For example, tests involving read hardware can only run at 1x speed, so you will want to avoid running those if you can. If you are building a custom compiler toolchain, that is slow and you will want to skip it if the changes cannot possibly affect the toolchain.