Index of every page on this site: llms.txt
All skills
Run it yourself

Audits a repository's GitHub Actions workflows for CI optimization opportunities — missing caches, redundant setup, sleep-based readiness, long test jobs without sharding, full-history checkout, dead env vars, build-cache misconfig, and ~60 more patterns across caching, redundancy, parallelization, conditional execution, trigger scope, and hidden failures. Use when: (1) analyzing a repo's CI for optimization opportunities, (2) producing a prioritized report with measured wall-clock and runner-minute savings, (3) re-auditing after upstream CI changes. Do not trigger for: general CI setup help, writing new workflows from scratch, non-GitHub-Actions CI systems, or security/posture audits — use `ci-secure` for those.

Use this Skill: https://skilld.dev/gh/starslingdev/skills/ci-speedup

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencespatternsopt19-test-source-sleep-dominance-includes-playwright-waitfortimeo.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

OPT19 — Test Source Sleep Dominance (includes Playwright waitForTimeout)

TL;DR: Tests waste time on fixed sleeps baked into the test code — waiting a flat number of seconds instead of waiting for the thing to actually be ready.

Anti-pattern: Test steps spend significant time sleeping inside the test source (fixed-ms setTimeout, page.waitForTimeout, cy.wait, raw sleep(), polling loops) — not in workflow YAML. OPT17 only detects sleep in workflow files; this pattern catches the much larger category of sleep embedded in test source.

Subtypes (all count; use the BROADEST scope — do not pick just one):

  • Playwright hardcoded waits — page.waitForTimeout(N) or bare waitForTimeout(N). These are the most common offender in e2e test suites.
  • Cypress — cy.wait(N) (note: cy.wait('@alias') waiting on a network intercept is OK; numeric ms is the anti-pattern).
  • Node/Jest/Vitest — await new Promise(r => setTimeout(r, N)), await sleep(N), await delay(N) in *.test.ts / *.spec.ts.
  • Integration-test fixtures — sleep N in shell wrappers, time.sleep(N) in Python tests, fixed waits before assertion retries.
  • Go tests — on a drilled long pole whose log runs go test (plain, -v or -json): constant time.Sleep / <-time.After waits in a _test.go body that dominate the measured test or package time; repeated, equally spaced wait/poll/retry output inside one test; or a -race job whose test files synchronously re-execute the race-built test binary, so each child pays the race runtime's exit sleep.

Detection heuristic (run ALL greps; aggregate matches; sum sleep_ms across every file):

# Playwright (the dominant case in monorepos with an e2e package)
grep -rn 'page\.waitForTimeout(\|waitForTimeout([0-9]' \
  packages/ e2e/ playwright/ tests/ integration-tests/ \
  --include='*.ts' --include='*.spec.ts' --include='*.test.ts' 2>/dev/null

# Cypress
grep -rn 'cy\.wait([0-9]' cypress/ e2e/ --include='*.ts' --include='*.js' 2>/dev/null

# Raw setTimeout / sleep / delay inside test files (large N only — 1000ms+)
grep -rn 'setTimeout(.*,\s*[1-9][0-9]\{3,\}\|await sleep(\|await delay(' \
  packages/ e2e/ tests/ --include='*.test.ts' --include='*.spec.ts' 2>/dev/null

# Python test sleeps (when repo has Python tests)
grep -rn 'time\.sleep([0-9]' tests/ --include='*.py' 2>/dev/null

Canonical search paths for monorepos: packages/*/e2e/tests/**, packages/*/tests/**, packages/*/src/**/*.test.ts, packages/playground/**, packages/memory/integration-tests/**, top-level e2e/**, playwright/**, cypress/**, integration-tests/**. Do NOT stop after the first directory — iterate through each of these before finalizing the finding.

Aggregation: Sum sleep_ms across EVERY matched file. Compute total sleep per full test run (if test is a single script, sum is the per-run cost; if test is sharded, divide by shard count only if each shard runs a non-overlapping subset). Report the per-run total and the source-of-truth file list in evidence.

Fix: Replace with event-driven waits. For Playwright: page.waitForSelector, page.waitForLoadState, expect(locator).toBeVisible({ timeout }). For Cypress: cy.wait('@alias') on route aliases. For DB/service readiness: ping the service in a bounded retry loop (e.g. @testcontainers readiness probes).

For a Go test that reaches production poll intervals or grace periods, run the waiting test on testing/synctest's virtual clock. If that dependency cannot use the virtual clock, expose only the interval as a package variable that the test shortens and restores with t.Cleanup; keep the production default and timeout assertions unchanged. For synchronous race-built helper children, preserve every inherited GORACE option and append atexit_sleep_ms=0 only to the child environment. Do not apply that override to the parent race job or asynchronous children.

The Go routes fail closed. A test-body sleep counts only when its duration is a literal or a package const (a var interval may already be shortened by the tests), it runs unconditionally (not in a loop, branch, select, goroutine or closure other than an inline t.Run body), and the test does not call t.Parallel, skip, return early or use testing/synctest; the constant total must be at most, and at least half of, the measured test time (or, without -v, the package time from a go test line with no -run/-skip filter; a (cached) package ran nothing), and at least one fifth of the job. The poll route needs at least two consistent intervals inside one test, timed by go test -json or the runner's own line timestamps, with the same shares. The race route needs a -race go test (or GOFLAGS) line, a package the job ran, at least three synchronous call sites that re-execute os.Args[0] (directly or through a helper returning *exec.Cmd), no asynchronous Start, and no atexit_sleep_ms anywhere in the package or the log. Sleep and poll findings state the runner-minute saving as a ceiling from one representative run and the workflow's 30-day run count; the race finding is unsized, because the log does not count helper re-execs.

Public examples cut a detached-seed matrix under -race from 558.58 s to 297.99 s (one local run each side) in openclaw/crabbox#2969, move fixture waits to virtual time in openclaw/crabbox#2455, and remove the race exit sleep only for synchronous helper children in openclaw/crabbox#1761.

Real-world example (mastra golden 2026-04-09): 37 page.waitForTimeout() calls across packages/playground/e2e/tests/ totaling 65,500ms per full run. On E2E kitchen-sink (2,368 runs/mo × 65.5s/run) this is 2,585 min/mo. Initial detection required grepping page.waitForTimeout in the packages/playground/e2e/ scope — looking only at stores/*.test.ts misses it entirely.


Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 alert2d3 checks · Risk SAFE
  • Gen Agent Trust Hub2d

    The skill is a robust CI optimization tool that audits GitHub Actions workflows. It identifies performance bottlenecks using deterministic logic and provides analysis of job logs. While it processes untrusted log data, it includes strong defensive instructions to mitigate indirect prompt injection. A minor best-practice issue regarding unsafe YAML loading was identified in a utility script.

  • Socket2d

    No alerts

  • Snyk2d

    Risk: CRITICAL · 2 issues

Signed by skilld at 9a84115. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 16 hours ago.

Activeupdated yesterday

README badge

README badge for starslingdev/skills/ci-speedup