Skip to article content
FrontendXLesson 16 / 16

Hardening, Cost and Continuous Improvement

Take one task-board application from local tests to a real delivery pipeline: continuous integration fundamentals, push and pull-request quality gates, lint, type-check, unit, component and end-to-end gates, dependency caching, matrix builds, artifacts and checksums, secrets and supply-chain security, release promotion, staging and production, rollback and observability.

advanced · about 30 minutes · 4 exercises

  • Explain
  • Implement
  • Test
  • Interview

What you will be able to do

#
  • Bound jobs with timeouts and cancel superseded runs.
  • Quarantine flaky tests instead of disabling them.
  • Use delivery metrics to guide improvement, not to score people.

Overview

#

Hardening and cost

A working pipeline is not a finished pipeline. Two forces push on it: reliability and cost. Hardening makes the pipeline trustworthy; cost control keeps it affordable. Both are ongoing.

Bound every job

A job with no timeout can hang until the platform kills it, wasting minutes and blocking the queue. Set a timeout-minutes on jobs and steps that could stall, such as installs and browser tests.

snippet.yaml
jobs:
  e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - run: pnpm test:e2e

Cancel superseded runs

A concurrency group with cancel-in-progress: true stops older runs when a newer commit arrives. This saves cost and removes confusing mixed results from stale commits.

Quarantine flaky tests, do not disable them

A flaky test that is disabled is lost coverage. Move it to a quarantine suite that runs on a schedule, file a tracking issue and fix the root cause. A retry policy on the main gate hides the defect and is not a fix.

Measure the pipeline

Track how long the pipeline takes, how often it fails and how often a failure is rerun to pass. A rising rerun rate is a signal of flakiness. Delivery metrics such as deploy frequency, lead time, change failure rate and time to restore describe the health of the delivery process; use them to decide where to invest, not to score individuals.

Keep it maintainable

Pin action versions, update them deliberately, and remove jobs that no longer catch anything. A pipeline with fifty always-green jobs is expensive theater. Each job should exist because it has caught a real defect or protects a stated requirement.

Sandbox boundary

The browser sandbox cannot measure pipeline duration, cancel runs or quarantine tests. It can run the pure logic, such as deciding whether a job needs a timeout.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Explain

    Explain what delivery metrics such as deploy frequency, lead time, change failure rate and time to restore are for.

    Reveal the reference answer
    reference.text
    They describe the health of the delivery process over time. A low deploy frequency or a high change failure rate shows where the pipeline or the release process is weak. They are used to decide where to invest, not to rank people, because they measure the system rather than an individual.

    Authored expected output: A correct answer frames the metrics as system health signals used for improvement, not individual scoring.

    Delivery metrics point at bottlenecks in the process. Used as a scoreboard they distort behavior; used as a signal they guide investment.

  2. Exercise 2Implement

    Add a bounded timeout and a concurrency group to this job so a stuck run cannot block the queue and superseded runs are cancelled.

    starter.yaml
    name: ci
    on: [pull_request]
    jobs:
      e2e:
        runs-on: ubuntu-latest
        steps:
          - run: pnpm test:e2e
    

    Reveal the reference answer
    reference.yaml
    name: ci
    on: [pull_request]
    concurrency:
      group: ci-${{ github.ref }}
      cancel-in-progress: true
    jobs:
      e2e:
        runs-on: ubuntu-latest
        timeout-minutes: 20
        steps:
          - run: pnpm test:e2e

    Authored expected output: The workflow has a concurrency group with cancel-in-progress and the job has timeout-minutes: 20.

    The timeout bounds a hung job and the concurrency group cancels superseded runs, reducing both cost and confusing stale results.

  3. Exercise 3Test

    Write a function needsTimeout(job) that returns true when job has no timeout-minutes value or the value is greater than 30.

    starter.javascript
    function needsTimeout(job) {
      // return true or false
    }

    Reveal the reference answer
    reference.javascript
    function needsTimeout(job) {
      if (!job || typeof job !== 'object') return true;
      const value = job['timeout-minutes'];
      if (typeof value !== 'number') return true;
      return value > 30;
    }

    Authored expected output: needsTimeout({ 'timeout-minutes': 20 }) is false; needsTimeout({}) is true; needsTimeout({ 'timeout-minutes': 45 }) is true.

    The check flags jobs that could hang for too long. It is pure logic and runs in the browser sandbox.

  4. Exercise 4Interview

    How do you handle a chronically flaky test without disabling it forever?

    Reveal the reference answer
    reference.text
    Move it to a quarantine suite that runs on a schedule so it stops blocking the main gate, file a tracking issue with the failure traces, and fix the root cause, usually a race, a real timer or an unstable selector. Remove it from quarantine once it passes consistently. Disabling it permanently loses the coverage; retrying it on the main gate hides the defect.

    Authored expected output: A correct answer quarantines with a tracking issue and a fix, and rejects permanent disabling and blanket retries.

    Quarantine preserves the test and the signal while unblocking the gate. The fix restores the coverage.

Common misconceptions

#
  • A hanging job is harmless.
  • Disabling a flaky test is the correct long-term fix.
  • Delivery metrics should rank individual engineers.

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.