Automated Test Runs on Pull Requests: CI Pipeline & Code Protection

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
Automated Test Runs on Pull Requests: CI Pipeline & Code Protection
Simple
from 1 day to 3 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1358
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1250
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    956
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1188
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    947

Automated Test Runs on Pull Requests

Imagine this: you just merged a PR into main, and a minute later production goes down with an error. It turns out the new module overwrote an old endpoint, and no test caught it. This scenario is familiar to many teams. We've been through it and since then have enforced a hard rule: every PR goes through an automated test pipeline. No green light — no merge. Automated test runs on PR are the basic defense against regressions. A developer cannot merge code that breaks existing functionality. This is not a replacement for code review, but a supplement: reviewers focus on logic, not on catching obvious bugs.

According to GitHub Actions documentation, dependency caching cuts installation time from 90 seconds to 5 seconds — 18 times faster. Matrix test execution lets you check different environment versions in parallel, speeding up the overall run by 3–4 times. This saves up to 40 hours per month on debugging. Our experience — over 5 years in CI/CD and 100+ configured pipelines — confirms that automated test runs pay off within the first sprint.

Why Automated Test Runs on PR Are Critical

Without this protection, you risk:

  • A broken CI on main — if a bug gets merged, the entire next sprint goes to fixing it.
  • Wasted time on code review — reviewers get distracted by errors that tests could catch.
  • Manual testing — the less routine, the higher the delivery speed.

Which Tests to Run and Which to Skip

Test Type Mandatory? When to Run Purpose
Linting Yes On every commit Consistent style, catch potential bugs
Unit tests Yes On every PR Check isolated logic
Integration tests Yes (DB/API) On every PR Component interaction
E2E No (on demand) Only for critical scenario changes Full user path check
Security tests Recommended Once a day or on release Find vulnerabilities

Pipeline Structure

A well-designed pipeline splits into parallel jobs with a fail-fast strategy:

# .github/workflows/pr.yml
name: PR Tests
on:
  pull_request:
    branches: [main, develop]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true  # Cancel old runs on new push

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: npm }
      - run: npm ci
      - run: npm run lint && npm run type-check

  unit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: npm }
      - run: npm ci
      - run: npm test -- --coverage
      - uses: codecov/codecov-action@v4
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

  integration:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_DB: testdb
          POSTGRES_PASSWORD: test
        options: >-
          --health-cmd pg_isready
          --health-interval 5s
          --health-timeout 5s
          --health-retries 5
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: npm }
      - run: npm ci
      - run: npm run test:integration
        env:
          DATABASE_URL: postgresql://postgres:test@localhost:5432/testdb

How to Set Up Caching to Speed Up the Pipeline

Without caching, npm ci on a cold runner takes 60–90 seconds. With caching — 5–10 seconds. Use the built-in cache in actions/setup-node or explicit via actions/cache:

# Cache node_modules based on package-lock.json
- uses: actions/setup-node@v4
  with:
    node-version: 20
    cache: npm  # Built-in cache in actions/setup-node

# Or explicitly via actions/cache
- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

Impact of caching on speed:

Method Dependency installation time Total pipeline time
No cache 60–90 s 3–5 min
With cache (actions/setup-node) 5–10 s 1–2 min
Built-in cache + matrix 5–10 s per job 1–2 min (parallel)

Matrix Testing and Supporting Multiple Stacks

If the application must work on multiple Node.js or PHP versions, use a matrix:

strategy:
  matrix:
    node-version: [18, 20, 22]
  fail-fast: false  # Run all versions even if one fails

For Laravel projects, use parallel PHPUnit execution:

- name: Run PHPUnit
  run: php artisan test --parallel --coverage-clover=coverage.xml
  env:
    DB_CONNECTION: pgsql
    DB_DATABASE: testing

- name: Upload coverage
  uses: codecov/codecov-action@v4
  with:
    files: coverage.xml

--parallel runs tests in parallel via brianium/paratest. On 200+ tests, it speeds up by 3–4 times.

Status Checks and Branch Protection

In GitHub Settings → Branches → Branch protection rules, add required status checks: lint, unit, integration. Merging into main without these checks is impossible.

Speed Optimization: Path Filtering and Test Splitting

  • Path filtering — run tests only when relevant files change (e.g., via paths in GitHub Actions).
  • Test splitting — distribute tests across multiple runners (GitHub Actions matrix).
  • Only changed modules — Jest --changedSince, pytest --testpaths.

Goal: pipeline completes within 5 minutes. Slower pipelines cause developers to ignore them.

Process of Setting Up and What’s Included in the Work

  1. Analyze current tests and project infrastructure.
  2. Design the pipeline: define jobs, matrices, caching.
  3. Implement GitHub Actions configuration tailored to your stack.
  4. Set up branch protection and required status checks.
  5. Test on a real PR, debug.
  6. Document the process and hand over to the team.

As a result, you get:

  • GitHub Actions configuration with caching and matrix
  • Status checks and branch protection rules
  • Coverage reports (Codecov, Coveralls)
  • Documentation for running tests locally
  • Access to our quick-start template for new projects
  • Two weeks of post-release support

Timeline and Cost

Basic setup with unit and integration tests for Node.js or PHP takes 1–2 days. Adding coverage and badge — another half day. Final timeline depends on project complexity (number of services, test types). Cost is discussed individually.

Order CI pipeline setup from our engineers — we guarantee a stable pipeline and documentation. Get a consultation on implementation — contact us to discuss your project.

Why are unit tests important but not a panacea?

A bug found by a unit test costs minutes to fix. The same bug in production costs hours of incident response, compensations, and lost trust. In an online store project, a discount calculation error passed manual testing, went to production, and processed 37 orders at zero price in 4 hours. An automated test for edge cases would have caught it on the first push. With 7+ years in web application testing and over 200 projects delivered, we’ve seen this pattern repeat across industries.

Jest is the standard for JavaScript/TypeScript, but unit tests are justified only where there is isolated logic: transformation functions, validators, business rules, utilities. Testing React components with Jest + Testing Library is correct for behavioral tests: "button appears after loading", "form shows error on empty email". Snapshot tests (toMatchSnapshot) are a trap: they break on any layout change and become noise that developers update without looking. Code coverage is a poor quality metric: 80% coverage can be achieved with tests that check nothing. Coverage shows that code executed, not that it works correctly.

Criteria Jest Vitest
Speed for large projects Medium (Babel transformation) 10–20x faster (ES modules)
Integration with Vite Via plugin Native
Monorepos Requires configuration Out of the box

Vitest as an alternative to Jest for Vite projects: 10–20x faster due to native ES modules without Babel transformation. For monorepos with thousands of tests, the speed difference is noticeable. Wikipedia on unit testing describes the theoretical foundation — we apply it with real CI pipelines.

How to set up E2E tests that are not flaky?

Playwright outperforms Cypress on key parameters: native multi-tab, multi-origin, iframe support; parallel execution at test level; WebKit, Firefox, Chromium out of the box; no iframe for the app — tests run in a real browser.

Playwright codegen records actions and generates a test — a good starting point, but generated code needs refactoring. Locators by text content are fragile: getByRole('button', { name: 'Place order' }) is more robust than locator('.btn-primary').

Page Object Model is the standard for organizing E2E tests. Each page is a separate class with methods instead of direct locators. When a button moves from header to sidebar — change in one place, not across all tests.

Flaky tests typically arise from race conditions between request and render, animations without wait, and dependency on external APIs. Solution: page.waitForResponse() instead of page.waitForTimeout(), mocking external APIs via page.route().

// Bad
await page.click('#submit');
await page.waitForTimeout(2000);
await expect(page.locator('.success')).toBeVisible();

// Good
await page.click('#submit');
await page.waitForResponse(resp =>
  resp.url().includes('/api/orders') && resp.status() === 201
);
await expect(page.getByRole('alert', { name: /order created/i })).toBeVisible();

Our engineers guarantee test stability in CI. Playwright’s official documentation covers all API details — we use it daily on projects with millions of users.

How do Core Web Vitals affect ranking?

Google uses Core Web Vitals in ranking. Lighthouse CLI in CI pipeline: on every deploy we check that LCP < 2.5s, CLS < 0.1, INP < 200ms. Google Chrome study: 53% of users leave a site if it takes longer than 3 seconds to load — our tests prevent such losses.

Real problems that Lighthouse finds:

  • Hero image without width/height attributes: CLS 0.35 on load.
  • JavaScript bundle 2.1MB synchronously blocking parsing: INP 450ms.
  • Fonts without font-display: swap: invisible text until font loads (FOIT).
  • Unoptimized hero image 4MB: LCP 8.2s.

Lighthouse CI (lhci) saves metric history and posts a comment to PR with degradation. For one e‑commerce client, optimizing these metrics improved conversion by 18% and reduced server costs by $12k annually.

What does load testing solve?

k6 is a load testing tool with a JavaScript API. Scenarios are written as code, versioned in git, run in CI. Three main scenarios:

  • Spike test — sharp load increase: 0 → 1000 users in 30 seconds. Simulates a campaign launch. Shows system's ability to handle spikes.
  • Soak test — stable load for 2–4 hours. Detects memory leaks, connection pool exhaustion, performance degradation.
  • Stress test — load above expected (150–200% of peak). Shows breaking point and graceful degradation.

Thresholds:

thresholds: {
  http_req_duration: ['p95<500', 'p99<1000'],
  http_req_failed: ['rate<0.01'],
}

p95 < 500ms means 95% of requests respond faster than half a second. If threshold is not met, k6 exits with error code, CI pipeline fails.

In one online store project, we detected API degradation at the 4th hour of the test: p95 increased from 200ms to 2s due to connection leaks. After optimization, the client saved $15k per year on incident response and extra infrastructure.

Testing pyramid in a project

Level Tool Quantity Speed
Unit Vitest/Jest Many (thousands) <5 min
Integration Vitest + supertest Medium 5–15 min
E2E Playwright Few (happy path) 10–30 min
Load k6 On schedule 30–60 min
Performance Lighthouse CI On every deploy 5 min

What does the work include?

  • Audit of current coverage and identification of critical user flows.
  • Writing unit tests for key business logic, integration tests for API, E2E for user scenarios.
  • Setting up parallel execution in CI (sharded workers for Playwright).
  • Load testing with report and recommendations.
  • Test case documentation, training your team on test practices.
  • 1-month warranty support after implementation.
  • Delivery of all test artefacts (code, CI configs, run histories).

How do we work?

  1. Analysis — audit of current testing, identification of weak spots, priority setting.
  2. Design — tool selection, test plan writing, approval.
  3. Implementation — writing tests, CI integration.
  4. Testing — running all levels, result analysis, bug fixing.
  5. Deployment — going live, metric monitoring, team training.

Timeline

Setting up a full test pipeline (Jest + Playwright + k6 + Lighthouse CI) from scratch: 2–4 weeks. E2E test coverage of an existing project (20–30 scenarios): 3–6 weeks. Load testing with report and recommendations: 1–2 weeks. Cost calculated individually after audit.

Ready to discuss your project? Leave a request — we will audit your current web application testing for free and propose a plan that can save up to 60% on incident costs. Get a consultation on web application testing — contact us today.