CI: running your checks on every pull request (GitHub Actions)
Add a GitHub Actions workflow that runs TaskKit's type check, linter, formatter and tests on a fresh machine for every pull request, read which step failed and why, find the file a commit left out, and make GitHub refuse to merge until the check passes.
TypeScript
GitHub
CI: running your checks on every pull request (GitHub Actions). Read this lesson at .
Tested with TypeScript 7.x · Node.js LTS
Last week your friend sent a pull request: tasks in progress should
show in blue. You read it on the Files changed tab, three new
lines in print.ts, and they looked right, so you merged it. The next
morning you ran npm run check (npm, the Node package manager) on
main, and TypeScript stopped on
one of her three lines. She had run npm test and npm run lint,
and both passed. She had not run npm run check, and you had not run
it on her branch.
Nobody did anything strange. Lesson A2.2 left TaskKit with four
commands to run before every commit, and two people sending changes:
sooner or later one command gets skipped. By the end of this lesson
GitHub runs TaskKit's checks itself, on every pull request, on a
computer that has only what you pushed. A mistake like hers gets a red
cross on the pull request before anyone merges it.
A computer that runs your checks
CI, short for continuous integration, is a service that runs
your project's checks every time someone sends a change. Integration
is bringing everyone's changes together into main; continuous
means doing it all the time, in small pieces, each one checked before
it joins. The checks are the ones you already have: npm run check,
npm run lint and npm test, plus the formatter of lesson A2.2, in a
mode that only reports.
GitHub Actions is the CI built into GitHub. On 26 November 2026
GitHub's billing page listed it as free for a public repository like TaskKit
(plans change, so check the page for a private one). You describe the checks
in a file in your repository. Each time a pull request is opened or gets a new
commit, GitHub starts a runner: a fresh virtual machine, a computer that
exists only as a program on GitHub's servers. The runner downloads your
repository, installs what it needs, runs your commands one after another, and
is thrown away when it is done. One such start, from the first step to the
last, is a run.
How does it know whether a command passed? By its exit code, the
number every command hands back when it ends (Part 1's lesson A1.6
showed it): 0 means it worked, anything else means it failed. That
is all CI reads. tsc (the TypeScript compiler) ends with 1 when it
finds an error, Biome does when a rule at error level is broken,
and node --test does when a test fails. On the pull request, GitHub
shows the run's result as a status check: a tick if every command
passed, a red cross if one failed.
A runner is not your computer, and that difference matters:
Your computer
Has every file in your folder
Committed or not, and the checks run only when you remember them.
The runner
Has only what is in Git
A fresh clone on every run, and every check, every time.
Your computer has everything in your folder; the runner has
only what Git has
Think of a bakery that sends a sample of every batch to a lab before
it reaches the shops. The baker tastes the dough too, but the baker is
busy and sometimes forgets. The lab never forgets, and it tests only
what was actually sent, never what is still on the baker's table.
Here is what the runner does with each pull request. The first
command that ends with a non-zero exit code stops the rest and fails
the status check. In the third case, your friend's editor writes
single quotes, as in lesson A2.2, and the formatter stops the run: on
the runner it only reports, as the next section shows. Switch
between the three cases, and press Next step to follow each, or
let it play:
npm ci: reachedInstalls exactly the lock
npm run check: passes✓Do the types fit?
npm run lint: passes✓A likely mistake?
npx biome format .: passes✓Laid out as biome.json says?
npm test: passes✓Do the tests pass?
On every pull request, a fresh machine runs the checks in
order; the first one that fails stops the rest and fails the status
check
All 9 steps shown.Step 1 of 9: npm ciStep 2 of 9: npm run checkStep 3 of 9: npm run check: passesStep 4 of 9: npm run lintStep 5 of 9: npm run lint: passesStep 6 of 9: npx biome format .Step 7 of 9: npx biome format .: passesStep 8 of 9: npm testStep 9 of 9: npm test: passes
All 9 steps shown.
npm ci: reachedInstalls exactly the lock
npm run check: stops here✕Do the types fit?
npm run lint: never reachedA likely mistake?
npx biome format .: never reachedLaid out as biome.json says?
npm test: never reachedDo the tests pass?
npm run check stops hereTS2367: This comparison appears to be unintentional because
the types '"todo"' and '"doing"' have no overlap.
On every pull request, a fresh machine runs the checks in
order; the first one that fails stops the rest and fails the status
check
All 3 steps shown.Step 1 of 3: npm ciStep 2 of 3: npm run checkStep 3 of 3: npm run check: stops here. TS2367: This comparison appears to be unintentional because
the types '"todo"' and '"doing"' have no overlap.
All 3 steps shown.
npm ci: reachedInstalls exactly the lock
npm run check: passes✓Do the types fit?
npm run lint: passes✓A likely mistake?
npx biome format .: stops here✕Laid out as biome.json says?
npm test: never reachedDo the tests pass?
npx biome format . stops hereFormatter would have printed the following content
On every pull request, a fresh machine runs the checks in
order; the first one that fails stops the rest and fails the status
check
All 7 steps shown.Step 1 of 7: npm ciStep 2 of 7: npm run checkStep 3 of 7: npm run check: passesStep 4 of 7: npm run lintStep 5 of 7: npm run lint: passesStep 6 of 7: npx biome format .Step 7 of 7: npx biome format .: stops here. Formatter would have printed the following content
All 7 steps shown.
A workflow, written in YAML
The file that describes the checks is a workflow. GitHub looks for
workflows in one folder, .github/workflows, and reads every file
there. A workflow is written in YAML, a name that stands for
YAML Ain't Markup Language (a joke: the name contains itself). It is
a format for settings, like the JSON (JavaScript Object Notation)
of package.json, but with fewer brackets and quotes. Three rules cover
everything this lesson writes:
name: value is one setting, as "name": "value" is in JSON.
A setting that holds other settings has them on the lines below it,
indented by two spaces more. The indentation does the job of JSON's
braces, so it has to be exact.
A line starting with - is one item of a list, as an array holds
items in JSON. [main] is a list written on one line.
In taskkit, on main, after git pull, start a branch for the new
file, as lesson A2.1 does for every change:
bash
git switch -c add-ci
In VS Code (Visual Studio Code, your editor), make a folder .github in
taskkit (the dot is part of the name), a folder workflows inside it, and a
file checks.yml inside that. On macOS and Linux, the file manager and plain
ls hide names that start with a dot; Windows shows them, and VS Code shows
them everywhere. Write this into the file:
.github/workflows/checks.ymlyaml
name: Checkson: push: branches: [main] pull_request:jobs: checks: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version: 24 - run: npm ci - run: npm run check - run: npm run lint - run: npx biome format . - run: npm test
Read it from the top. name is what GitHub calls the workflow. Lines
3 to 6, on, name the events that start a run: a push to the
main branch, and every pull_request, when it is opened and each
time a commit is pushed to it. pull_request: holds nothing, and that
is allowed: it means every pull request, with no conditions.
jobs lists the work. A job is one runner with its own list of steps, and
this workflow has one job, named checks on line 9. Line 10, runs-on, picks
the runner's system: ubuntu-latest is the version of Ubuntu, one kind of
Linux, that GitHub uses by default: Ubuntu 26.04 on 26 November 2026 (the list
on GitHub's actions/runner-images page), and GitHub moves it to a newer
version from time to time. So every run happens on Linux, whichever system you
work on, and everything it prints is the same for every reader of this lesson.
Line 11, steps, starts the list of what the job does, one - per
step, in order. A step does one of two things:
uses runs an action: a ready-made step someone else wrote and
published on GitHub. actions/checkout downloads your repository
onto the runner, and actions/setup-node installs Node. The part
after @ is the version of the action, as @latest is in
npm create vite@latest. The settings an action takes go under
with: here, node-version: 24, the Node of this course. v7 was
the newest version of both actions on 26 November 2026; each
action's page on GitHub lists its releases, and a newer number may
be out when you read this.
run runs a command, the way you type it in your terminal.
The commands are yours. npm ci installs exactly what
package-lock.json names, as Level 1's lesson 14.2 taught: on a fresh
machine there is no node_modules, and the runner must get the same
versions you have. The figure above starts at npm ci: the two uses
steps before it are what give it a fresh clone and Node. Then come the
checks of lesson A2.2, and one of them is easy to get wrong.
Bad — the formatter's script, which
passes any layout.
yaml
- run: npm run format
Good — Biome without --write,
which reports a file that is not laid out as biome.json says.
yaml
- run: npx biome format .
npm run format is biome format --write .: on the runner it
rewrites the files on a machine that is thrown away and ends with 0
whatever the layout, so single quotes pass. Without --write, Biome changes
nothing, prints what it would have changed, and ends with 1.
A project with a build adds it as one more step. The page of lesson
A2.4, taskkit-web, would end its list with - run: npm run build,
so the tsc -b at the front of its build stops a wrong prop before
anyone merges it.
TaskKit runs with Node as it is, so it has no build.
The first run
Commit the workflow, push the branch, and open its pull request, as in
lesson A2.1:
bash
git add .github/workflows/checks.ymlgit commit -m "Run the checks on every pull request"git push -u origin add-cigh pr create --fill
The pull request starts the workflow at once: this very pull request
is the first one it checks. gh, the GitHub CLI (command-line
interface) of lessons 15.2 and A2.1, has a command for it:
gh pr checks shows the status checks of the pull request for the
branch you are on. Add --watch, and it waits
and prints again every ten seconds until every check is done. If it
answers no checks reported on the 'add-ci' branch, the run has not
started yet: wait a few seconds and run it again.
bash
gh pr checks --watch
The end of the outputtext
All checks were successful0 cancelled, 0 failing, 1 successful, 0 skipped, and 0 pending checks NAME DESCRIPTION ELAPSED URL✓ Checks/checks (pull_req... 17s https://github.com/ana...
Checks/checks is the workflow's name, then the job's, and after it
comes the event that started the run, (pull_request). gh cuts a
column that does not fit your terminal with ..., so a wider
terminal shows more of it, the run's address included. Your time will
differ. The same tick stands beside the status check on the pull
request's page on GitHub.
gh run view shows one run. With --verbose it lists every step of
it, even when all of them passed. It first asks which run, with a list
of the latest runs under this line:
bash
gh run view --verbose
Its questiontext
? Select a workflow run [Use arrows to move, type to filter]
The newest is at the top, already chosen, so press Enter
(on a Mac the key says return).
Part of the outputtext
✓ checks in 17s (ID 124851755820) ✓ Set up job ✓ Run actions/checkout@v7 ✓ Run actions/setup-node@v7 ✓ Run npm ci ✓ Run npm run check ✓ Run npm run lint ✓ Run npx biome format . ✓ Run npm test ✓ Post Run actions/setup-node@v7 ✓ Post Run actions/checkout@v7 ✓ Complete job
Your seven steps are there, between the steps GitHub adds to prepare
the runner and clean it up. Merge the pull request, as in lesson A2.1:
bash
gh pr merge --merge --delete-branch
The merge is a push to main, so the workflow runs once more, on
main itself: after every merge, main shows a tick or a cross of
its own, and a merge that breaks it is seen at once. From now on every
pull request to TaskKit is checked, yours and your friend's.
A red cross before the merge
Now make your friend's mistake again, on purpose, to see what CI does
with it. On a new branch:
bash
git switch -c doing-in-blue
In print.ts, paintStatus colours a task's status. Add her three
lines, which show a task in progress in blue:
print.tsts
function paintStatus(status: Status): string { if (status === "done") { return chalk.green(status); } if (status === "doing") { return chalk.blue(status); } return chalk.yellow(status);}
Run what she ran, npm test and npm run lint. npm test prints ℹ pass 19
and ℹ fail 0, and npm run lint finds nothing: no test asks about
"doing", and the code breaks no rule. Commit, push, and open the pull
request:
bash
git commit -am "Show tasks in progress in blue"git push -u origin doing-in-bluegh pr create --fillgh pr checks --watch
The end of the outputtext
Some checks were not successful0 cancelled, 1 failing, 0 successful, 0 skipped, and 0 pending checks NAME DESCRIPTION ELAPSED URLX Checks/checks (pull_req... 10s https://github.com/ana...
X is the red cross, and the pull request's page on GitHub shows it
too. To see which step failed, run gh run view and pick the newest run,
the one with the X. A failed run lists its steps without
--verbose:
Part of the outputtext
X checks in 10s (ID 124852373131) ✓ Set up job ✓ Run actions/checkout@v7 ✓ Run actions/setup-node@v7 ✓ Run npm ci X Run npm run check - Run npm run lint - Run npx biome format . - Run npm test - Post Run actions/setup-node@v7 ✓ Post Run actions/checkout@v7 ✓ Complete job
npm run check failed, and every one of your steps after it shows -: it
never ran. setup-node's last step, which saves a download cache, is skipped
too, since it runs only after a success; the checkout's clean-up and
Complete job still run. To read what the failed step printed, ask for its
log. It asks which run in the same way:
bash
gh run view --log-failed
The last two lines of the outputtext
checks Run npm run check 2026-11-01T12:46:06.6455810Z ##[error]print.ts(13,7):error TS2367: This comparison appears to be unintentional because thetypes '"todo"' and '"doing"' have no overlap.checks Run npm run check 2026-11-01T12:46:06.6935045Z ##[error]Processcompleted with exit code 1.
Each is one line in your terminal, broken here to fit. A line starts
with the job, the step and the moment it was printed; your date and
time will differ. ##[error] is GitHub's mark for an error line. The
rest of the first line is what tsc printed. In your terminal, tsc
prints print.ts:13:7 - error TS2367 with the line of code under it.
On the runner no terminal shows its output, so it prints the place as
print.ts(13,7): the file, line 13, column 7, all on one line. Your
line numbers may differ by one or two. The second line is the exit
code that failed the step.
Status is "todo" | "done", and after the first if returns for
"done", TypeScript knows status is "todo": comparing it with
"doing" can never be true. GitHub also pins the error to line 13
on the pull request's Files changed tab, so whoever reviews it
sees it there.
Nothing reached main. The fix is a commit on the same branch: add
the status to the type in tasks.ts.
tasks.tsts
export type Status = "todo" | "done";export type Status = "todo" | "doing" | "done";
The new commit joins the open pull request, the workflow runs again,
and this time the output ends with a tick beside Checks/checks.
Merge it with gh pr merge --merge--delete-branch, as in lesson
A2.1.
Make the status check required
A red cross warns; it does not lock. On a pull request with a failing
status check, GitHub still lets you press Merge pull request, and
gh pr merge still merges. To make GitHub refuse, add a ruleset:
rules GitHub enforces for a branch. Rulesets work on every public
repository; on a private one, a free account cannot use them
(GitHub's plans as its docs gave them on 26 November 2026; they may
change). The names below are GitHub's on 26 November 2026; if one has
moved or changed, GitHub Docs' page "Creating rulesets for a
repository" has the current path.
1
Open the rulesets
On GitHub, open the taskkit repository and click Settings. In the left
sidebar, under Code, planning, and automation, click Rulesets (if it
opens a group, click Rulesets inside it). Click New ruleset, then
New branch ruleset.
2
Name it and turn it on
Under Ruleset name, type Checks before merging. The enforcement
status starts as Disabled: click it and choose Active, or the
ruleset does nothing.
3
Pick the branch
Under Target branches, click Add a target, then Include
default branch: that is main.
4
Require the status check
Under Branch protections, tick Require status checks to pass
before merging. In its settings, type checks, the name of your job, and
click the + beside it. Then click Create.
From now on GitHub merges a pull request into main only after the
checks job has passed on it: on a pull request with a red cross,
the merge stays blocked until a new commit makes the status check
pass.
Predict before you run
TaskKit's workflow is the one above. You start a new branch, commit a
change and push it, and you do not open a pull request yet.
The runner has only what is in Git. A file you forgot to commit is on
your computer and nowhere else, so every check passes for you and
fails for everyone else.
Common mistake
A new file left out of the commit
print.ts grows, so you move paintStatus into a file of its own,
colors.ts, export it there, and in print.ts import it instead; take
Status out of the import type line, since only colors.ts uses it now:
print.ts (part)ts
import { paintStatus } from "./colors.ts";import type { Task } from "./tasks.ts";
npm run check, npm run lint and npm test all pass. You commit
with -am, as in lesson A2.2, push the branch, and open its pull
request. gh pr create prints one line you could miss,
Warning: 1 uncommitted change, and the pull request gets a red
cross. gh run view --log-failed shows this line just before the
exit code. Here it is without the job, the step and the time, and
broken to fit:
The log of the failed steptext
##[error]print.ts(6,29): error TS2307: Cannot find module './colors.ts'or its corresponding type declarations.
-a adds every changed file Git already tracks, and colors.ts is
new: Git has never tracked it. The commit holds the changed
print.ts, which imports colors.ts, and not colors.ts itself.
error TS2307: Cannot find module './colors.ts' or its corresponding type declarations.
The fix
Ask Git what it has not saved:
bash
git status --short
Outputtext
?? colors.ts
--short prints one line per file, and ?? means untracked: Git
has never saved it. Add it, commit, and push to the same branch:
bash
git add colors.tsgit commit -m "Add the colors file"git push
The pull request runs again and passes.
When CI fails and your computer passes, look for what the runner does
not have. Run git status first: an untracked file, or a
package-lock.json you changed and did not commit, is the most
common answer.
Pass all four tasks to complete the lesson with practice. Reach the end without them and it counts as read only.
Exercises
This page cannot run a workflow, so two exercises write its parts in
TypeScript, as console.log lines and as an object, and two ask you
to read what GitHub shows.
Exercise · Fix the error
Each step needs the one before
This program prints the commands of a job's steps in an order that fails on a
fresh runner: it installs packages before the repository is there and before
the course's Node is set up. Change the order of the lines, without changing
any line itself, so each step has what it needs.
Loading the editor…
Exercise · Fix the error
Pull requests start no run
A teammate's workflow starts a run only after a merge, when a broken change is
already on main. Its on part is written here as a TypeScript object, the
way JSON would write the YAML: a setting that holds nothing, such as
pull_request:, is written as an empty object, {}, and GitHub reads
pull_request: {} the same way as pull_request: (every pull request, with
no conditions). Add the one event that is missing, so every pull request
starts a run too, and keep the push to main.
Loading the editor…
Exercise · Read the code
Did the tests pass?
Your friend's pull request has a red cross, and gh run view shows
this. She says the tests pass, since npm test has no X. Is she
right?
text
X checks in 12s (ID 124863122759) ✓ Set up job ✓ Run actions/checkout@v7 ✓ Run actions/setup-node@v7 ✓ Run npm ci ✓ Run npm run check X Run npm run lint - Run npx biome format . - Run npm test - Post Run actions/setup-node@v7 ✓ Post Run actions/checkout@v7 ✓ Complete job
Exercise · Read the code
A workflow that never runs
Your friend adds CI to a project of her own. She pushes a branch and
opens a pull request, and no run starts: gh pr checks finds no
checks at all. Her workflow is right, line for line, and git status
shows it committed, in this file:
text
.github/workflow/checks.yml
Why does it never run?
Recap
Recap · 3 questions
Check yourself
What does the runner check?
Check yourself
How does CI decide that a step failed?
Check yourself
A status check failed. What stops you from merging?
0 of 0 answered.
A cheat sheet to keep
Cheat sheet
CI: running your checks on every pull request
What things are
Word
What it means
CI
Checks that run on every change, before it joins main
GitHub Actions
The CI built into GitHub
Workflow
A YAML file in .github/workflows
Job
One runner and its list of steps
Step
One action or one command, in order
Action
A ready-made step: actions/checkout@v7
Runner
A fresh machine that runs one job, then is thrown away
Ruleset
Rules GitHub enforces for a branch
The workflow file
Write
To
pull_request:
Under on: every pull request and its new commits
branches: [main]
Under push: only pushes to main
runs-on:ubuntu-latest
Run the job on Linux
uses: actions/checkout@v7
Download the repository
uses: actions/setup-node@v7
Install Node: node-version: 24
run: npm ci
Install exactly what package-lock.json names
run: npx biome format .
Report bad layout; never rewrite
Commands
Write
To
gh pr checks --watch
Wait for this pull request's checks
gh run view --verbose
Pick a run and see every step
gh run view --log-failed
Read what the failed step printed
git status --short
One line per file; ?? is untracked
Rules
Rule
What it means
Exit code 0
The step passed; anything else fails it
A step fails
Your later steps show - and never run
Red in CI, green at home
Something is not in Git: run git status
A red cross does not lock
A ruleset makes the status check required
Where to go next
You can now write a workflow that runs TaskKit's checks on every pull
request, read which step failed and why, and make GitHub refuse to
merge until the checks pass.
Next is A package for npm: build TaskKit, describe it and try it,
where TaskKit becomes a package you can install with one command, and
you find out why a package ships JavaScript instead of .ts files.
Before you move on, open a small pull request of your own, such as a
new line in README.md, watch its checks with gh pr checks --watch,
and merge it only once it has its tick.