Statly Code
CI/CD

CI/CD

Statly Code includes built-in continuous integration powered by AWS Lambda. Run tests, lint code, and build projects automatically on every push and pull request.

Overview

The CI system provides:

  • Automatic triggering on push and PR events
  • Multiple language support (Node.js, Go, Python, Rust)
  • Dependency caching for faster builds
  • Test result parsing with detailed reports
  • Branch protection integration for merge blocking
  • AI auto-merge when tests pass

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Git Push      β”‚ -> β”‚   SQS Queue     β”‚ -> β”‚  Lambda Runner  β”‚
β”‚   PR Created    β”‚    β”‚   (CI Jobs)     β”‚    β”‚  (Container)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                      β”‚
                                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                                              β”‚               β”‚
                                        β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
                                        β”‚ S3 Cache  β”‚   β”‚ S3 Artifactsβ”‚
                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Configuring CI

Enable CI

  1. Go to Repository Settings β†’ CI/CD
  2. Toggle Enable CI
  3. Configure triggers and commands

Pipeline Configuration

SettingDescriptionDefault
projectTypeAuto-detect or specify: nodejs, go, python, rustauto
installCommandDependency installation commandAuto-detected
testCommandTest execution commandAuto-detected
lintCommandLint command (optional)None
buildCommandBuild command (optional)None
timeoutMax run time in seconds600 (10 min)
cacheEnabledEnable dependency cachingtrue

Trigger Configuration

TriggerDescriptionDefault
triggerOnPushRun on every pushtrue
triggerOnPRRun on PR creation/updatetrue

Auto-Detection

When projectType is auto, the runner detects your project type:

Files DetectedProject TypeInstallTest
package.json + pnpm-lock.yamlNode.js (pnpm)pnpm installpnpm test
package.json + yarn.lockNode.js (yarn)yarn installyarn test
package.jsonNode.js (npm)npm cinpm test
go.modGogo mod downloadgo test ./...
requirements.txtPythonpip install -r requirements.txtpytest
pyproject.tomlPython (Poetry)pip install .pytest
Cargo.tomlRustcargo buildcargo test

Runtime Environment

The CI runner includes:

RuntimeVersion
Node.js20.x
npmLatest
pnpmLatest
yarnLatest
Go1.22
Python3.12
RustLatest stable
GitLatest

Environment Variables

Default environment variables available:

CI=true
STATLY_CI=true
STATLY_RUN_ID=run_xxx
STATLY_REPO=org/repo
STATLY_BRANCH=feature/branch
STATLY_COMMIT=abc123
STATLY_PR_NUMBER=42  # Only on PR builds

Custom Environment Variables

Add custom variables in Repository Settings β†’ CI/CD β†’ Environment Variables:

⚠️

Secret variables are encrypted at rest and never exposed in logs.

Dependency Caching

Caching speeds up subsequent builds by preserving dependencies:

Project TypeCached Directories
Node.jsnode_modules, .pnpm-store
Go~/go/pkg/mod
Python~/.cache/pip, .venv
Rust~/.cargo, target

Cache entries expire after 7 days of inactivity.

Test Results

The runner parses test output for detailed reporting:

Supported Frameworks

FrameworkProject TypeOutput Format
JestNode.jsJSON reporter
VitestNode.jsJSON reporter
MochaNode.jsJSON reporter
go testGoStandard output
pytestPythonJUnit XML

Test Summary

Tests: 42 passed, 2 failed, 3 skipped
Coverage: 87.3%

Failed Tests:
  βœ— UserService.createUser should validate email
    Expected: valid email
    Received: undefined
    at src/services/user.test.ts:42

CI Runs

Run States

StateDescription
queuedWaiting for runner
runningCurrently executing
completedFinished (check conclusion)

Run Conclusions

ConclusionDescription
successAll checks passed
failureTests failed
errorInfrastructure error
cancelledManually cancelled

Viewing Logs

  1. Go to the PR or Repository β†’ CI Runs
  2. Click on the run number
  3. View logs for each job

Branch Protection Integration

CI integrates with branch protection:

  1. Go to Repository Settings β†’ Branches
  2. Select a branch protection rule
  3. Enable Require status checks
  4. Select CI checks to require

When required, PRs cannot be merged until CI passes.

AI Auto-Merge

When configured, PRs can auto-merge after:

  1. CI checks pass
  2. AI review approves (if enabled)
  3. Required human approvals obtained

See AI Code Review β†’ Auto-Merge for configuration.

Limits

PlanCI Minutes/MonthConcurrent JobsTimeout
Free10015 min
Pro1,000515 min
EnterpriseUnlimited1015 min

CI runs on AWS Lambda, which has generous free tier limits (1M requests, 400K GB-seconds).

API Reference

Trigger CI Run

POST /api/v1/code/repos/{org}/{repo}/ci/runs
Content-Type: application/json
 
{
  "branch": "main",
  "commitSha": "abc123"
}

List CI Runs

GET /api/v1/code/repos/{org}/{repo}/ci/runs?status=completed&limit=20

Get CI Run

GET /api/v1/code/repos/{org}/{repo}/ci/runs/{number}
 
# Response
{
  "run": {
    "id": "run_xxx",
    "number": 42,
    "status": "completed",
    "conclusion": "success",
    "branch": "main",
    "commitSha": "abc123",
    "duration": 45,
    "startedAt": "2024-01-01T00:00:00Z",
    "completedAt": "2024-01-01T00:00:45Z"
  },
  "jobs": [...],
  "testSummary": {
    "total": 42,
    "passed": 40,
    "failed": 2,
    "skipped": 0
  }
}

Cancel CI Run

POST /api/v1/code/repos/{org}/{repo}/ci/runs/{number}/cancel

Re-run CI

POST /api/v1/code/repos/{org}/{repo}/ci/runs/{number}/rerun

Troubleshooting

Common Issues

Tests pass locally but fail in CI:

  • Check Node.js/Go/Python version differences
  • Ensure all dependencies are in package.json/go.mod/requirements.txt
  • Check for hardcoded paths or environment-specific code

Timeout errors:

  • Increase timeout in pipeline settings
  • Optimize slow tests
  • Use caching effectively

Cache not working:

  • Verify lock files are committed
  • Check cache key generation

Missing dependencies:

  • Ensure install command runs first
  • Check for native dependencies that need system packages