Continuous integration for a full-stack repo

Intermediate · 11 min

Wire a GitHub Actions pipeline for Taskboard that type-checks, runs API tests, then browser tests, with caching, a fast-fail order and uploaded traces.

Before thisEnd-to-end tests with PlaywrightMonorepo layout for full-stack projectsEnvironment variables and secrets across layers

Artem Bondar · 11 min

Continuous integration for a full-stack repo

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Artem BondarReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Continuous integration runs the same checks you run locally on a clean machine for every pull request, so a green main branch means something.
  • Order jobs from cheapest to most expensive so a type error fails in seconds instead of after a ten-minute browser run.
  • Use npm ci with a lockfile and the setup-node cache so CI installs exactly what you tested and does not download the world each time.
  • Upload Playwright traces only when a run fails, because a trace is the difference between debugging a CI failure and guessing.
  • Keep secrets out of the repo and out of pull requests from forks, and give CI its own test-only values.

What CI is for

You have tests. They pass on your laptop. That is a weaker statement than it sounds: your machine has a cached build, a database from last week, an environment variable you set once and forgot, and the dependency versions you happened to install. Continuous integration is the habit of running the same checks on a clean, disposable machine for every change, before anyone merges.

The problem it solves is trust. If main is always green, anyone can start a branch from it and know any red they see is theirs. If main is sometimes red and nobody knows why, people stop reading the signal.

For a full-stack repo there is a second job. The client, the server and the shared types live in one place (see monorepo layout), and a change to a shared Zod schema can break both sides. CI is where you find out that the client still sends the old field name.

Order jobs by cost

Think of an airport. Security checks are quick and catch most problems, so they come before the expensive step of boarding a plane. A pipeline should work the same way. For Taskboard:

  1. Install and type-check. Seconds. Catches the largest class of mistakes.
  2. API integration tests. Seconds to a minute, using the PGlite setup from earlier in this group.
  3. Browser tests. Minutes, because they install a browser and start the app.

Here is the workflow I wrote for the Taskboard repo:

name: ci
on:
  pull_request:
  push:
    branches: [main]

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  check:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version-file: .nvmrc
          cache: npm
      - run: npm ci
      - run: npx tsc --noEmit
      - run: npx vitest run

  e2e:
    needs: check
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version-file: .nvmrc
          cache: npm
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npx playwright test
      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: playwright-traces
          path: test-results/

I parsed this YAML and ran each command (tsc --noEmit, vitest run, playwright test) locally in order, and they pass. I did not run it on GitHub, so the action versions and the ubuntu-latest image are from the GitHub Actions docs rather than something I observed. Check the current major versions of the actions before you copy it.

The parts that matter

needs: check makes the browser job wait for the cheap one. A commit with a type error never pays for a browser download.

npm ci plus cache: npm. npm ci installs exactly what the lockfile says and errors if package.json and the lockfile disagree. That is the point: CI should test the dependency tree you committed. The cache option on setup-node stores npm’s download cache between runs so installs are fast.

node-version-file: .nvmrc pins the Node version in one file that your laptop, your Dockerfile and CI all read. A version mismatch between local and CI is a classic “works on my machine” cause.

concurrency with cancel-in-progress. If you push twice in a minute, the first run is already about outdated code. Cancelling it saves time and keeps the status check on the pull request honest.

timeout-minutes. A hung test will otherwise burn the default limit, which is much longer than you want.

if: failure() on the upload. A Playwright trace is the single best artifact for a CI-only failure. Upload it when something fails, download it from the run page, and open it locally with npx playwright show-trace.

A real database in CI

The API tests in this roadmap use PGlite, so CI needs nothing extra. If you chose a containerised Postgres instead, GitHub Actions can start one as a service container on the job and you pass its connection string in an environment variable. Either way, build the test schema by running your migrations, so a broken migration fails CI instead of production.

Secrets and forks

CI needs configuration but not your production secrets. Give the pipeline test-only values: a throwaway session secret, a Stripe test key if you need one, a local database URL. Set them in the workflow’s env or in the repository’s secrets store. Two rules:

  • Never commit a .env file. See environment variables and secrets across layers.
  • Be careful with workflows triggered by pull requests from forks. By default GitHub does not expose repository secrets to them, and you should not work around that to make a test pass. A test that needs a real secret should run on push to main, not on untrusted pull requests.

What to add next

The pipeline above is the minimum. Reasonable next steps, in the order I would add them: a lint step; a build step for the client (vite build) so a broken import fails before deploy; a migration check that applies all migrations to an empty database; and a required-status rule on main so a red run blocks merging. Deployment can run from the same workflow after the checks pass, which the next group covers starting with deploying the three tiers.

For how the testing tools themselves work, see the sibling lessons on frontend testing strategies and the built-in Node test runner.

What the video covers

Artem Bondar’s “Playwright and GitHub Actions Setup FROM SCRATCH (Run Your Tests For Free)” is about eleven minutes and was published in September 2025. By its title it takes a Playwright project and sets up a GitHub Actions workflow that runs the tests on GitHub’s free runners. That is the browser-test job in this lesson’s workflow, which is the part people most often get stuck on. The description is mostly links to the channel’s courses and has no chapters, and I could not read a transcript, so I cannot say whether it covers caching, pnpm or unit tests. Take those commands from the section above. The channel teaches test automation for QA engineers, so expect Playwright to be the focus. Tom Shaw’s video adds a deployment step, and Web Dev Cody’s older Jest video shows the plain unit-test workflow.

Where this fits

You can now prove, on every pull request, that the repo builds and behaves. That closes the testing group. The next group is about getting it in front of users, and begins with where each of the three tiers actually runs: deploying the three tiers.

Check yourself

  1. 01Why does the e2e job declare needs: check?

    So the slow browser job only starts after the quick type-check and API tests pass, which saves minutes and CI time on commits that were already broken.

  2. 02What is the difference between npm install and npm ci in a pipeline?

    npm ci installs exactly what the lockfile says and fails if it disagrees with package.json, so CI tests the same dependency tree you committed.

  3. 03Why upload test results with if: failure()?

    Traces and screenshots are only useful when a test fails, and keeping them for green runs wastes storage and time.

  4. 04What does the concurrency setting with cancel-in-progress do?

    It cancels an older run of the same branch when a new push arrives, so you do not wait for a result about code that has already been replaced.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark