Skip to article content
FrontendXLesson 02 / 16

Push and Pull Request Quality Gates

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.

beginner · about 30 minutes · 4 exercises

  • Predict
  • Implement
  • Debug
  • Test

What you will be able to do

#
  • Choose between pull_request and push triggers.
  • Explain why required status checks are matched by name.
  • Cancel superseded runs with a concurrency group.

Overview

#

Gate the change, not the merge

A quality gate is a check that must pass before a change can merge or deploy. The strongest place to gate is the pull request, because the check runs against the proposed merge result before it reaches the protected branch.

Triggers differ. pull_request runs against the merge of the branch into the base. push runs on the branch after a merge. Running both gives fast feedback on the PR and a safety net on main.

snippet.yaml
name: pr-gate
on:
  pull_request:
    branches: [main]
concurrency:
  group: pr-${{ github.ref }}
  cancel-in-progress: true
jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: corepack enable && pnpm install --frozen-lockfile
      - run: pnpm lint && pnpm check-types && pnpm test

Required status checks are named

Branch protection names the exact checks that must pass. The name is the job or check name, not the workflow file name. If you rename a job, the protection rule silently waits for a check that no longer reports, and pull requests can hang.

Concurrency and cancellation

A rapid series of pushes can queue many runs of the same workflow. A concurrency group with cancel-in-progress: true cancels superseded runs so only the newest commit is verified.

Skipped is not passed

Path filters can skip a workflow when only documentation changes. A required check that is skipped can leave a pull request permanently pending unless the rule treats a skipped result as success. Prefer running the job and exiting early over skipping the job entirely.

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 1Predict

    Branch protection requires a check named verify. You rename the job to test. What happens to pull requests?

    Choose the best answer
  2. Exercise 2Implement

    Add a concurrency group to this pull-request workflow so a new push cancels the previous run.

    starter.yaml
    name: pr-gate
    on:
      pull_request:
    jobs:
      verify:
        runs-on: ubuntu-latest
        steps:
          - run: echo verify
    

    Reveal the reference answer
    reference.yaml
    name: pr-gate
    on:
      pull_request:
    concurrency:
      group: pr-${{ github.ref }}
      cancel-in-progress: true
    jobs:
      verify:
        runs-on: ubuntu-latest
        steps:
          - run: echo verify

    Authored expected output: The workflow has a concurrency group keyed by the ref with cancel-in-progress true.

    Keying the group by the ref means each branch or PR has its own queue, and a newer run cancels the older one.

  3. Exercise 3Debug

    Branch protection requires a check named verify, but the job is named checks. Fix the workflow so the required check reports.

    starter.yaml
    name: pr-gate
    on: [pull_request]
    jobs:
      checks:
        runs-on: ubuntu-latest
        steps:
          - run: pnpm test
    

    Reveal the reference answer
    reference.yaml
    name: pr-gate
    on: [pull_request]
    jobs:
      verify:
        runs-on: ubuntu-latest
        steps:
          - run: pnpm test

    Authored expected output: The job is renamed to verify so it matches the required status check.

    The check name must match the protection rule exactly. Renaming the job to the required name satisfies the gate.

  4. Exercise 4Test

    Write a function assertWorkflowShape(workflow) that returns true only when the object has an on key, a jobs object and at least one job with a steps array. This pure function runs in the browser sandbox; the pipeline it describes does not.

    starter.javascript
    function assertWorkflowShape(workflow) {
      // return true or false
    }

    Reveal the reference answer
    reference.javascript
    function assertWorkflowShape(workflow) {
      if (!workflow || typeof workflow !== 'object') return false;
      if (!workflow.on || typeof workflow.on !== 'object') return false;
      if (!workflow.jobs || typeof workflow.jobs !== 'object') return false;
      return Object.values(workflow.jobs).some(
        (job) => job && Array.isArray(job.steps)
      );
    }

    Authored expected output: assertWorkflowShape({ on: {}, jobs: { verify: { steps: [] } } }) is true; a workflow with no jobs entries is false.

    The function validates the parsed structure only. It does not start a runner, so it is honest about being a structural check, not a CI execution.

Common misconceptions

#
  • A required check that is skipped still counts as passed.
  • The workflow file name is the required check name.
  • Concurrency groups slow down a pipeline.

Follow-up practice

#
  • cicd-03-lint-gates

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.