-
-
Notifications
You must be signed in to change notification settings - Fork 3
cicd
teXt0wnz uses GitHub Actions for continuous integration, testing, and deployment. The pipeline ensures code quality, runs comprehensive tests, and automatically deploys to GitHub Pages.
The CI/CD system consists of 10 workflow files that handle:
- Code quality checks (linting, formatting)
- Automated testing (unit, DOM, E2E)
- Build verification
- Docker image creation
- Deployment to GitHub Pages
- Wiki documentation synchronization
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β test-suite.yml β
β (Main Orchestrator) β
ββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββ> lint.yml (Code Quality)
βββ> build.yml (Build Verification)
βββ> unit.yml (Unit Tests)
βββ> e2e.yml (E2E Tests - Sharded)
βββ> merge-reports.yml (Merge E2E Results)
βββ> deploy.yml (GitHub Pages Deploy)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β docker-build.yml β
β (Container Image Builder) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ci-docker-build.yml β
β (CI Container Image Builder) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β wiki.yml β
β (Documentation Publisher) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Purpose: Orchestrates the complete CI/CD pipeline for code changes.
Triggers:
- Push to
mainbranch (excluding docs and markdown files) - Pull requests to any branch
- Manual workflow dispatch
Jobs:
- lint - Code quality checks
- build - Build verification
- unit - Unit test execution
- e2e - End-to-end tests (4-way sharded for speed)
- reports - Merge E2E test reports
- deploy - Deploy to GitHub Pages (main branch only)
Path Ignores:
docs/****/*.mdLICENSE.txtOSSMETADATA.gitattributes.gitignore.prettierignore
Permissions:
contents: write
pages: write
id-token: write
packages: readWorkflow:
graph TD
A[Push/PR] --> B[Lint]
A --> C[Build]
A --> D[Unit Tests]
A --> E[E2E Tests - Shard 1]
A --> F[E2E Tests - Shard 2]
A --> G[E2E Tests - Shard 3]
A --> H[E2E Tests - Shard 4]
E --> I[Merge Reports]
F --> I
G --> I
H --> I
B --> J{Main Branch?}
C --> J
D --> J
I --> J
J -->|Yes| K[Deploy]
J -->|No| L[End]
Purpose: Validates code style and quality using ESLint.
Called by: test-suite.yml
Steps:
- Checkout code
- Setup Bun
- Install dependencies
- Run
bun lint:check
Coverage:
- HTML files (
src/**/*.html) - JavaScript files (
src/js/**/*.js) - Test files (
tests/**/*.js)
Linting Rules:
- ESLint configuration from
eslint.config.js - HTML linting with
@html-eslint/eslint-plugin - Stylistic rules with
@stylistic/eslint-plugin
Purpose: Verifies the application builds successfully and produces expected artifacts.
Called by: test-suite.yml
Steps:
- Checkout code
- Setup Bun
- Install dependencies
- Modify
.envfor GitHub Pages domain - Build application with
bun bake - Verify build artifacts exist
- Upload build artifacts (main branch only)
Verified Artifacts:
- Directory structure (
dist/ui,dist/ui/js,dist/ui/img,dist/ui/fonts) - Static files (icons, manifest, HTML, robots.txt, sitemap.xml)
- Hashed files (JavaScript bundles, CSS, SVG icons, screenshots)
- Service worker and Workbox runtime
Artifact Upload:
- Name:
editor-build - Retention: 3 days
- Only on successful builds from the
mainbranch
Purpose: Executes unit tests with coverage reporting.
Called by: test-suite.yml
Steps:
- Checkout code with full history
- Setup Bun
- Install dependencies
- Run
bun test:unit(Vitest with coverage) - Inject dark theme CSS into coverage report
- Upload coverage artifacts
Test Configuration:
- Test runner: Vitest
- Environment: jsdom
- Coverage provider: v8
- Output:
tests/results/coverage/
Coverage Report:
- HTML report with dark theme support
- Statement, branch, function, and line coverage
- Uploaded as artifact:
unit-test-results - Retention: 3 days
Dark Theme Injection: Adds CSS for dark mode support in coverage reports:
@media (prefers-color-scheme:dark) { ... }Purpose: Runs end-to-end tests in real browsers using Playwright.
Called by: test-suite.yml (4 times with different shards)
Sharding Strategy: Tests are split into 4 parallel shards for faster execution:
- Shard 1/4
- Shard 2/4
- Shard 3/4
- Shard 4/4
Container:
image: ghcr.io/xero/text0wnz/ci:latest
options: --user rootTest Browsers:
- Chrome
- Firefox
- Safari
Steps:
- Checkout code
- Install dependencies with Bun
- Set localhost domain in
.env - Build application
- Run E2E tests for assigned shard
- Upload blob report
Environment:
HOME: /rootPLAYWRIGHT_TEST_BASE_URL: http://localhost:8060
Artifacts:
- Name:
blob-report-{shard}(e.g.,blob-report-1-4) - Path:
blob-report - Retention: 1 day
- Always uploaded (even on failure)
Purpose: Combines Playwright reports from all E2E shards into a single HTML report.
Called by: test-suite.yml
Steps:
- Checkout code
- Install Bun and Playwright
- Download all blob reports
- Merge reports with
playwright merge-reports --reporter html - Upload merged report
Input:
- Downloads artifacts matching pattern:
blob-report-* - Merges multiple blob reports into one
Output:
- Artifact name:
merged-playwright-report - Path:
playwright-report - Retention: 14 days (configurable)
Purpose: Deploys the application and test reports to GitHub Pages.
Called by: test-suite.yml (only on main branch)
Permissions:
contents: read
pages: write
id-token: writeConcurrency:
- Group:
pages - Cancel in-progress: false
Jobs:
- Download
editor-buildartifact - Download
unit-test-resultsartifact - Download
merged-playwright-reportartifact - Organize files:
release/ βββ (application files) βββ tests/ βββ (unit coverage) βββ e2e/ βββ (E2E report) - Upload pages artifact
- Deploy to GitHub Pages using pages artifact
- Set environment:
github-pages - Output deployment URL
Deployed Structure:
https://xero.github.io/text0wnz/
βββ index.html (Application)
βββ ui/ (Assets)
βββ tests/
βββ index.html (Unit coverage)
βββ e2e/
βββ index.html (E2E report)
Purpose: Builds and publishes multi-architecture Docker images for the Editor.
Triggers:
- Manual workflow dispatch
- Push to main when
Dockerfilechanges
Platforms:
linux/amd64linux/arm64
Registries:
- GitHub Container Registry:
ghcr.io/xero/text0wnz - Docker Hub:
xerostyle/text0wnz
Steps:
- Checkout code
- Setup QEMU for multi-arch builds
- Setup Docker Buildx
- Login to GitHub Container Registry
- Login to Docker Hub
- Extract metadata
- Build and push images
Tags:
-
latest(always) -
sha-{short-sha}(commit-based)
Cache:
- Type: GitHub Actions cache
- Mode: max (cache everything possible)
Purpose: Builds the CI container image used for E2E testing.
Triggers:
- Manual workflow dispatch
- Push to main when
.github/ci.Dockerfilechanges
Base Image:
FROM mcr.microsoft.com/playwright:latestIncludes:
- Bun runtime
- Playwright with all browsers (Chrome, Firefox, WebKit)
- ESLint and Prettier
- All necessary dependencies
Registry:
ghcr.io/xero/text0wnz/ci:latest
Purpose: Provides a pre-configured environment for E2E tests with all browsers and dependencies installed, reducing CI run time.
Purpose: Synchronizes documentation from /docs to GitHub Wiki.
Triggers:
- Push to main branch with changes in
docs/** - Manual workflow dispatch
Steps:
- Checkout repository
- Checkout wiki repository
- Configure git with commit author
- Clear wiki (except
.gitandimgfolders) - Copy docs to wiki
- Rename
README.mdtoHome.md - Update footer with copyright year
- Fix internal markdown links (remove
.mdextension) - Commit and push if changes exist
Link Transformation:
# Before: [link](document)
# After: [link](document)
# Before: [link](document#section)
# After: [link](document#section)Authentication:
Uses CICD_TOKEN secret for wiki repository access.
All GitHub Actions use commit SHAs for security:
actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2
actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5
docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4See: other-tools/pin-github-action
Each workflow uses least-privilege permissions:
test-suite.yml:
permissions:
contents: write
pages: write
id-token: write
packages: readdocker-build.yml:
permissions:
contents: read
packages: writedeploy.yml:
permissions:
contents: read
pages: write
id-token: writeRequired repository secrets:
| Secret | Purpose | Used In |
|---|---|---|
GITHUB_TOKEN |
Built-in token for GitHub API access | Most workflows |
DOCKERHUB_USERNAME |
Docker Hub login | docker-build.yml |
DOCKERHUB_TOKEN |
Docker Hub password | docker-build.yml |
CICD_TOKEN |
Wiki repository access | wiki.yml |
PKG_TOKEN |
GitHub Packages access | ci-docker-build.yml |
editor-build
- Content: Complete built application from
dist/ - Size: ~10-20 MB
- Used by: deploy.yml
unit-test-results
- Content: HTML coverage report from Vitest
- Path:
tests/results/coverage/ - Includes: Dark theme CSS injection
- Used by: deploy.yml
blob-report-{shard}
- Content: Playwright E2E test results for one shard
- Path:
blob-report/ - Used by: merge-reports.yml
merged-playwright-report
- Content: Combined E2E test HTML report
- Path:
playwright-report/ - Used by: deploy.yml
Via GitHub CLI:
# List artifacts for a run
gh run view RUN_ID --json artifacts
# Download specific artifact
gh run download RUN_ID -n editor-build
gh run download RUN_ID -n unit-test-results
gh run download RUN_ID -n merged-playwright-reportVia Workflow Summary: Artifacts are available in the "Artifacts" section of workflow runs.
Tests are split into 4 parallel shards, reducing total test time from ~25 minutes to ~2-5 minutes:
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]Docker Build Cache:
cache-from: type=gha
cache-to: type=gha,mode=maxBun Dependencies:
Bun's native caching handles node_modules efficiently.
- Deployment only runs on main branch
- Artifact uploads skip for non-main branches
- Path filters prevent unnecessary runs
The repository README includes these CI/CD badges:
[](https://github.com/xero/teXt0wnz/actions/workflows/test-suite.yml?query=branch%3Amain)
[](https://github.com/xero/text0wnz/deployments)
[](https://github.com/xero/text0wnz/wiki)GitHub UI:
- Navigate to Actions tab
- Select workflow from sidebar
- Click on specific run
- View job details and logs
GitHub CLI:
# List recent runs
gh run list --workflow=test-suite.yml
# View run details
gh run view RUN_ID
# Watch run in real-time
gh run watch RUN_ID
# View logs
gh run view RUN_ID --logCheck Logs:
- Open failed workflow run
- Click on failed job
- Expand failed step
- Review error messages and stack traces
Common Issues:
Build Failures:
- Check
bun bakeoutput - Verify
vite.config.jsconfiguration - Check for missing dependencies
Test Failures:
- Review test logs
- Check screenshots (E2E) in artifacts
- Verify browser compatibility
Deployment Failures:
- Check Pages settings in repository
- Verify permissions
- Review artifact upload/download steps
Docker Build Failures:
- Check Dockerfile syntax
- Verify base images are available
- Check registry authentication
Via GitHub UI:
- Open failed workflow run
- Click "Re-run all jobs" or "Re-run failed jobs"
Via GitHub CLI:
# Re-run entire workflow
gh run rerun RUN_ID
# Re-run only failed jobs
gh run rerun RUN_ID --failedLint:
bun lint:checkBuild:
bun bakeUnit Tests:
bun test:unitE2E Tests:
bun test:e2eStandard build:
docker buildx build -t text0wnz:local .Multi-arch build:
docker buildx build --platform linux/amd64,linux/arm64 -t text0wnz:local .Run locally:
docker run -p 80:80 -e NODE_ENV=development text0wnz:localBuild CI image:
docker build -f .github/ci.Dockerfile -t text0wnz-ci:local .Run E2E tests in container:
docker run -v $(pwd):/app -w /app text0wnz-ci:local bun test:e2e- Write tests locally first
- Ensure tests pass locally
- Commit and push
- Monitor CI run
- Fix any CI-specific issues
-
Test changes in a feature branch
-
Use
workflow_dispatchfor manual testing -
Check workflow syntax with:
# Install actionlint brew install actionlint # macOS # or download from: https://github.com/rhysd/actionlint # Validate workflow actionlint .github/workflows/*.yml
-
Review security implications
-
Update documentation
- Use GitHub repository settings
- Never commit secrets to code
- Rotate secrets regularly
- Use environment-specific secrets
- Audit secret usage in workflows
- Test pass rate
- Build time
- Test execution time
- Artifact sizes
- Deployment frequency
- Time to deployment
- Reduce test time: Further shard E2E tests if needed
- Improve caching: Cache more build artifacts
- Parallel jobs: Run more jobs in parallel
- Smaller containers: Optimize Docker images
- Faster dependencies: Keep dependencies minimal
- Testing Guide - Test infrastructure details
- Building and Developing - Build process
- Docker - Container deployment
- Webserver Configuration - Production deployment