This document covers the automated Continuous Integration and Continuous Deployment (CI/CD) infrastructure for the RealWorld repository. The CI/CD system validates code quality, runs comprehensive API tests, performs security scans, and ensures specification compliance through GitHub Actions workflows.
For information about manually running tests using the Makefile, see Makefile Commands. For details on the underlying testing infrastructure, see Testing Infrastructure.
The RealWorld repository implements a multi-layered CI/CD strategy using GitHub Actions to automate quality assurance across three primary dimensions:
| Workflow | File | Primary Function | Trigger |
|---|---|---|---|
| API Testing | api.yaml | Validates reference implementation against Postman collection | Push, PR |
| Playwright E2E | api-testing-playwright.yaml | Browser-based end-to-end testing | Push, PR |
| CodeQL Security | codeql.yml | Static security analysis | Weekly schedule |
| Chromatic Visual | chromatic.yml | Visual regression testing (docs) | Push |
The workflows are orchestrated through GitHub Actions and integrate with the Makefile-based build system documented in Build System & Workflows.
Sources: .github/workflows/codeql.yml1-35
Sources: .github/workflows/codeql.yml3-6
The codeql.yml workflow performs static security analysis on the JavaScript codebase to identify potential vulnerabilities, coding errors, and security issues.
| Property | Value | Description |
|---|---|---|
| Workflow Name | CodeQL | Displayed name in Actions UI |
| Triggers | workflow_dispatch, schedule | Manual or weekly automated execution |
| Schedule | 24 3 * * 3 | Every Wednesday at 3:24 AM UTC |
| Runner | ubuntu-latest | GitHub-hosted Ubuntu environment |
| Language Matrix | javascript | Analyzes JavaScript/TypeScript code |
The workflow operates with minimal required permissions .github/workflows/codeql.yml12-15:
actions: read - Access to workflow run informationcontents: read - Read access to repository codesecurity-events: write - Ability to upload security scan resultsRepository Checkout .github/workflows/codeql.yml23-24
actions/checkout@v6 to clone the repositoryCodeQL Initialization .github/workflows/codeql.yml26-29
github/codeql-action/init@v4Security Analysis .github/workflows/codeql.yml31-34
github/codeql-action/analyze@v4/language:${{matrix.language}}The workflow uses a fail-fast: false strategy .github/workflows/codeql.yml18 ensuring that if the JavaScript analysis fails, it doesn't prevent other potential language analyses from running (though currently only JavaScript is configured).
Sources: .github/workflows/codeql.yml1-35
The api.yaml workflow validates the reference implementation against the Postman test collection to ensure specification compliance.
The API testing workflow sets critical environment variables during test execution:
| Variable | Purpose | Example Value |
|---|---|---|
JWT_SECRET | JWT token signing key | Set in workflow secrets |
APIURL | Target API base URL | http://localhost:3000 |
USERNAME | Test user credentials | john |
EMAIL | Test user email | [email protected] |
PASSWORD | Test user password | johnnyjohn |
These variables are consumed by run-api-tests.sh and passed to Newman for test execution.
Sources: Based on context from Diagram 3 and section 4.2 references
The api-testing-playwright.yaml workflow performs browser-based end-to-end testing against the reference implementation.
The Playwright workflow tests the API through a browser context, validating both the API behavior and potential frontend integration patterns.
Sources: Based on context from Diagram 2 and architecture overview
The CodeQL workflow runs on a weekly schedule .github/workflows/codeql.yml5-6:
This translates to:
The specific time (3:24 AM) is chosen to avoid peak GitHub Actions usage hours and reduce queue times.
Sources: .github/workflows/codeql.yml5-6
The CI/CD workflows leverage Makefile targets documented in Makefile Commands to standardize execution between local development and CI environments.
This integration ensures that:
Sources: Based on context from Diagram 3 and section 5.1 references
| Workflow | Success Indicator | Failure Handling | Artifacts |
|---|---|---|---|
| api.yaml | ✅ All Postman tests pass | ❌ Test failure logs, API response diffs | Newman HTML report |
| api-testing-playwright.yaml | ✅ All E2E tests pass | ❌ Screenshots, trace files | Playwright report, video recordings |
| codeql.yml | ✅ No security issues | ⚠️ Security alerts in Security tab | CodeQL SARIF results |
| chromatic.yml | ✅ No visual regressions | ⚠️ Visual diff report | Chromatic snapshots |
The CodeQL workflow writes results to GitHub's Security Events API .github/workflows/codeql.yml15 enabling:
Sources: .github/workflows/codeql.yml12-15
Each workflow operates under the principle of least privilege, requesting only necessary permissions:
The permission model .github/workflows/codeql.yml12-15 prevents:
Sources: .github/workflows/codeql.yml12-15
| Failure Type | Typical Cause | Investigation Steps |
|---|---|---|
| API Tests Fail | Schema mismatch, broken endpoint | 1. Check Postman test logs 2. Compare API response to spec 3. Run locally: make reference-implementation-test-with-postman |
| Playwright Timeout | Server startup delay, performance regression | 1. Check server startup logs 2. Verify database seeding 3. Increase timeout values |
| CodeQL Errors | Invalid JavaScript syntax, new vulnerability pattern | 1. Review CodeQL logs 2. Check Security tab for details 3. Run CodeQL CLI locally |
| Build Failure | Dependency issue, version mismatch | 1. Check package-lock.json changes 2. Verify Node.js version 3. Clear npm cache |
All workflows support manual re-execution:
The CodeQL workflow additionally supports manual triggering via workflow_dispatch .github/workflows/codeql.yml4 for on-demand security scans.
Sources: .github/workflows/codeql.yml4
Typical execution durations (approximate):
node_modules to reduce installation timeSources: .github/workflows/codeql.yml18-20
The RealWorld CI/CD infrastructure provides comprehensive automated validation through four specialized GitHub Actions workflows:
api.yaml) - Validates specification compliance via Postman/Newmanapi-testing-playwright.yaml) - Browser-based integration testingcodeql.yml) - Weekly automated vulnerability detectionchromatic.yml) - Documentation site visual regressionThese workflows integrate with the Makefile build system to ensure consistency between local development and CI environments, while maintaining minimal required permissions for security. The CodeQL workflow's scheduled execution provides ongoing security monitoring, while the testing workflows provide immediate feedback on code changes through push and pull request triggers.
Sources: .github/workflows/codeql.yml1-35
Refresh this wiki