This document explains the Continuous Integration and Continuous Deployment (CI/CD) pipeline for the OpenRoads MUD project.
Pipeline Overview
The GitLab CI/CD pipeline consists of five main stages:
Build - Compile the server binary and cross-platform releases
Test - Run unit tests and code quality checks
Integration - Run end-to-end tests and system verification
Deploy - Deploy to staging/production environments
Release - Create automated releases with cross-platform binaries
Pipeline Stages
Job: build
Compiles the OpenRoads server binary
Uses Go 1.21 Alpine image
Caches Go modules for faster builds
Produces openroads binary artifact
Runs on: merge requests, main, develop branches
Job: build_binaries
Builds cross-platform release binaries
Supports Linux AMD64, Windows AMD64, macOS AMD64, Linux ARM64
Uses optimized build flags (-ldflags="-s -w")
Only runs on tags and main branch
Produces release-ready binaries
Artifacts:
openroads binary (expires in 1 hour)
Cross-platform binaries (expires in 1 week)
Job: unit_tests
Runs unit tests for all packages (./lib/..., ./config/..., ./routines/...)
Generates coverage reports
Produces JUnit XML reports for GitLab integration
Artifacts:
report.xml - JUnit test results
coverage.html - Coverage report
Job: code_quality
Runs gofmt for code formatting
Runs go vet for static analysis
Runs staticcheck for advanced static analysis
Runs goimports for import formatting
Allows failure (non-blocking)
Artifacts:
Job: security_scan (Manual)
Runs gosec security scanner
Generates security report
Artifacts:
🔗 Integration Stage
Job: e2e_simple
Runs simple end-to-end tests
Tests core functionality:
Server connection & RLogin protocol
Multiple client connections
Job: e2e_comprehensive (Manual)
Runs comprehensive end-to-end tests
Tests advanced features:
Player creation & authentication
Game commands and interactions
Job: static_npc_verification
Verifies static NPC system functionality
Ensures NPCs like Oria, Hanrod, Wenzel are properly placed
Job: combat_system_verification
Verifies combat system components
Tests combat mechanics and equipment
Job: enemy_spawning_verification
Verifies enemy spawning system
Tests spawn timing, max instances, room validation
Job: deploy_staging (Manual)
Deploys to staging environment
Prepares binary for deployment
Environment:
URL: http://staging.openroads.mud
🚀 Release Stage
Job: release_job
Creates GitLab releases automatically when tags are pushed
Links to cross-platform binaries from build_binaries job
Uses GitLab's native release functionality
Generates release notes from tag message
Only runs when tags are created
Release Assets:
openroads-linux-amd64 - Linux 64-bit binary
openroads-windows-amd64.exe - Windows 64-bit executable
openroads-darwin-amd64 - macOS 64-bit binary
openroads-linux-arm64 - Linux ARM64 binary
Running Tests Locally
Run Specific Test Suites
Creating Releases
Automated Release Process
OpenRoads MUD uses an automated release process that creates cross-platform binaries and GitLab releases when tags are pushed.
Using the Release Script
The script will:
Validate the current git state
Prompt for version and release notes
Run tests to ensure quality
Create and push the git tag
Trigger the automated release pipeline
Manual Release Process
Release Pipeline Workflow
Tag Detection : Pipeline detects new tag
Cross-platform Build : build_binaries job creates binaries for:
Release Creation : release_job creates GitLab release with:
Release notes from tag message
Links to all platform binaries
Automatic asset organization
Version Naming Convention
Use semantic versioning for releases:
v1.1.0 - Minor release with new features
v1.0.1 - Patch release with bug fixes
v1.0.0-beta.1 - Pre-release versions
CI Environment Variables
The pipeline uses these environment variables:
GO_VERSION: Go version to use (default: 1.21)
BINARY_NAME: Name of the compiled binary (default: openroads)
TEST_TIMEOUT: Timeout for tests (default: 5m)
CI: Set to "true" in CI environment
CI_COMMIT_SHA: Git commit hash
CI_COMMIT_REF_NAME: Git branch name
Artifacts and Reports
Location : test-reports/ directory
JUnit XML : For GitLab test result integration
Coverage HTML : Visual coverage reports
Test Output : Raw test output for debugging
Build Artifacts
Binary : openroads executable
Reports : Various analysis and test reports
Pipeline Configuration
Go modules cached in .cache/go-mod/
Build cache in .cache/go-build/
Speeds up subsequent builds
Timeout Settings
Comprehensive E2E: 15 minutes
Build: Default (10 minutes)
Failure Handling
Blocking failures : Build, unit tests, simple E2E tests
Non-blocking failures : Code quality, security scan, comprehensive E2E
Manual jobs : Comprehensive E2E, security scan, deployment
Merge Request Requirements
For a merge request to be accepted, the following must pass:
✅ Required (Blocking):
Static NPC verification pass
Combat system verification pass
Enemy spawning verification pass
⚠️ Optional (Non-blocking):
Troubleshooting
CI Environment Issues
Check the CI logs in GitLab
Run tests locally to reproduce issues
Review the test output in artifacts
Check the troubleshooting section above
Create an issue using the bug report template
Run tests locally before pushing
Keep commits small and focused
Write tests for new features
Update documentation when needed
Use descriptive commit messages
Keep pipelines fast - optimize for quick feedback
Fail fast - catch issues early in the pipeline
Provide clear feedback - good error messages and logs
Cache dependencies - speed up builds
Monitor pipeline performance - track build times and success rates
Monitoring and Metrics
The CI/CD pipeline provides these metrics:
These metrics help maintain code quality and identify areas for improvement.
Last updated 7 months ago