Splitting CI into multiple fast checks
This lesson preview is part of the Bundling and Automation in Monorepos course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to Bundling and Automation in Monorepos, plus 90+ \newline books, guides and courses with the \newline Pro subscription.

[00:00 - 00:08] In the previous lesson, we added the sherif check. There are two more checks that I want to add as separate checks that don't run in the same runner as our main CI.
[00:09 - 00:24] Let's do that. I'm going to first check out the branch called add-more-checks, and then I'm going to open our workflow CI. And the first one that I want to add is Knip.
[00:25 - 00:30] So let me do that quickly. Knip uses the checkout.
[00:31 - 00:38] Unfortunately, Knip does need to do a full pnpm install. There's no way around it. And then we just run "pnpm knip".
[00:39 - 00:48] So now we have three checks. "Add Knip check" is the way that I'm going to commit this.
[00:49 - 00:58] And then push origin/add-more-checks. And let's go to the pull request.
[00:59 - 01:10] Now we have three concurrent checks that are run. We have our CI check that runs linting, testing, building and TypeScript.
[01:11 - 01:19] We have the sherif check, that's an extremely fast check. And we have the Knip check that verifies that we don't have unused code.
[01:20 - 01:31] There is one more that I want to add as a separate check. And that is Prettier. So again we need the same setup as for Knip.
[01:32 - 01:43] But then we run "prettier --check ." on the root. Add everything commit "Add Prettier check".
[01:45 - 01:59] Push this to GitHub and we should see this action trigger in a moment. There it is. We now have four checks.
[02:00 - 02:18] We have our main CI check that does setting of types linting, testing of unit unit tests and build. We have then our sherif, Knip, and Prettier checks that as you can see are extremely fast. They're all 10s to 20s.
[02:19 - 02:42] While the main check can be quite a bit slower. The reason why I like to do it this way is because these three can often fail for reasons unrelated to code, while this one fails only for reasons related to code. Either there is a type error or there is some build error, something that necessitates a more serious fix.
[02:43 - 03:10] These three, however, can fail for, I would say, almost silly reasons, but we still want to capture those reasons, and putting them in separate jobs that execute faster just gives developers a faster feedback loop to then fix anything raised by any of those. Of course, now that we have added other checks in here, we need to update our branch rules.
[03:11 - 03:30] If I go under rules, rule sets, we have our Main Branch Rule that currently requires the CI check to pass. We need to also add the knip check, the sherif check, and the prettier check.
[03:31 - 03:53] Like this. So now all of these are required checks that need to pass for a pull request to be mergeable. I'm going to save this change. Go back to my pull request and you can see that now all checks are marked as required and are passing, and we can merge our pull request.
[03:54 - 03:57] This is it for this one, and I'll see you in the next lesson.