QA Interview Hub · Knowledge base · Quizzes · Українська

CI/CD › GitHub Actions for a test framework

A workflow skeleton for Playwright in GitHub Actions

A Playwright workflow is YAML in .github/workflows/ with triggers and jobs that run in parallel by default, each on its own runner. A job is made of steps. A typical skeleton is checkout, Node, npm ci, browsers, tests and a report upload with the !cancelled() condition so it is saved even after a failure. timeout-minutes and minimal permissions are added.

CI/CD · GitHub Actions

Tests are green locally and red in Actions, with no report. What is a workflow made of?

A QA Engineer adds the first Playwright workflow to a repository. The tests fail, and the report button is empty: the artifact upload step did not run, because it came after a red step. A small detail like this if condition can cost an hour until you know how Actions decides what to run. This lesson walks through the skeleton of a workflow and its usual traps.

How it works and why. A workflow is a YAML file in .github/workflows/. It consists of jobs, which run in parallel by default, each on its own runner (a clean virtual machine). A job is a sequence of steps on one machine with a shared file system. A step is either run: (a shell command) or uses: (a ready-made action). Data does not flow between jobs on its own: that takes artifacts, a cache or outputs.

Workflow structure

Workflow: .github/workflows/e2e.ymlon: triggers and permissionsJob: runs-on + timeout-minutesits own machine, parallel with othersStep: run or usesrun in order, shared disk
Figure 1. Parallelism exists between jobs, not between steps.

Triggers (on:): pull_request (a PR), push with a branch filter, schedule (cron) and workflow_dispatch (a manual run). Cron runs in UTC by default, such runs start only from the default branch and may be late at peak hours. Another zone is set with a timezone key holding an IANA name.

A step after failing tests

Wrong

The default condition

A step has the success() condition: after a red test step it is skipped, and the report you need most is missing.

Right

if: !cancelled()

The step runs after failing tests, but not after a run was cancelled by hand or by concurrency.

Figure 2. The condition on the report upload step decides whether you see the cause of a failure.

Example: a working skeleton. Everything needed for a first Playwright run:

name: e2e
on:
  pull_request:
  push:
    branches: [main]
  schedule:
    - cron: '0 2 * * *'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: lts/*
          cache: npm
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npx playwright test
      - uses: actions/upload-artifact@v7
        if: ${{ !cancelled() }}
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 14

What matters here. timeout-minutes protects against hangs (by default a job may run up to 360 minutes). permissions: contents: read limits the GITHUB_TOKEN to a minimum. npm ci installs dependencies strictly from the lock file. cache: npm caches the global npm cache. playwright install --with-deps installs a browser with system libraries. Playwright's CI config (workers, retries) is in the lesson “CI: sharding, Docker and fast reruns”.

A nightly run on Kyiv time:

on:
  schedule:
    # every day at 02:00 Kyiv time
    - cron: '0 2 * * *'
      timezone: 'Europe/Kyiv'

Limits and alternatives. Actions can be pinned by a tag (@v7) or by a full commit SHA: a SHA protects against a moved tag, a tag is easier to update. Action versions change, so check them on the releases page before use and update them along with dependencies. For constant runs on your own hardware there are self-hosted runners, but then the team keeps the environment clean. Sharding and matrix are in the next lesson: “Cache, matrix, concurrency and sharding”.

Typical mistakes.

  • No timeout-minutes: a hung test holds a runner for six hours.
  • A report upload without !cancelled(): no report after a failure.
  • Token permissions wider than needed: permissions not set.
  • Cron expected in local time while it runs in UTC.
  • Expecting one job to see another job's files: artifacts are needed.

Check yourself

The tests failed, the npx playwright test step is red and the next upload-artifact is "skipped". Why, and how to fix it?

Answer

A step's default condition is success(): after a failed step the next ones are skipped. Add if: ${{ !cancelled() }} so the upload runs after failing tests.

Will a second job see files created by the first?

Answer

No: each job runs on its own runner. Data is passed through artifacts, a cache or outputs, and order is set with needs.

In an interview. Junior: A workflow is YAML with triggers and jobs, and a job is made of steps. For Playwright I do checkout, set up Node, run npm ci, install browsers, run the tests and upload the report. Middle/Senior: Jobs run on separate runners, so data moves between them through artifacts. I set timeout-minutes and minimal permissions, upload the report with !cancelled(), and remember that cron runs in UTC unless timezone is set. I check action versions on the releases page.

More articles in this chapter