Skip to main content
Glama

DollhouseMCP

by DollhouseMCP
CI_FIXES_REFERENCE.md4.43 kB
# CI Fixes Reference - July 10, 2025 ## Overview This document captures the CI fixes implemented to resolve test failures that were blocking all PRs. ## Problem Summary ### 1. Flaky Timing Test (Issue #148) - **Symptom**: Extended Node Compatibility badge showing as failing - **Cause**: Windows CI only passing 2/5 timing tests (needed >2.5) - **Root Issue**: CI environments have unreliable microsecond timing ### 2. TypeScript Compilation Errors - **Symptom**: All CI builds failing during test compilation - **Cause**: Multiple TypeScript errors in test files - **Impact**: Blocked all PRs from passing CI ## Solutions Implemented ### Timing Test Fix (PR #185) #### Rejected Approach ```typescript // DON'T DO THIS - Security Risk! const requiredPasses = isCI ? 2 : testRuns / 2; // Lowers threshold to 40% ``` #### Implemented Approach ```typescript // Skip timing tests in CI entirely if (isCI) { console.log('Skipping timing attack test in CI environment - timing too unreliable'); // Still verify validation works expect(() => validateFilename('test-file.md')).not.toThrow(); expect(validateFilename('../../../etc/passwd')).toBe('etcpasswd'); return; } ``` #### Added Deterministic Test ```typescript it('should have consistent validation logic (deterministic security test)', () => { // Tests security properties without timing // Works reliably in all environments // Verifies consistent error messages // Tests sanitization behavior }); ``` ### TypeScript Fixes 1. **Readonly Property Fix** ```typescript // Before: SecurityMonitor['events'] = []; // After: SecurityMonitor['events'].splice(0, SecurityMonitor['events'].length); ``` 2. **Mock Implementation Fix** ```typescript // Before: jest.spyOn(console, 'log').mockImplementation(); // After: jest.spyOn(console, 'log').mockImplementation(() => {}); ``` 3. **Missing Jest Method** ```typescript // Before: expect.fail('Should have thrown'); // After: throw new Error('Should have thrown'); ``` 4. **Environment Variable Types** ```typescript declare global { namespace NodeJS { interface ProcessEnv { TEST_PERSONAS_DIR?: string; // ... other env vars } } } ``` 5. **Missing Interface Properties** ```typescript interface WorkflowJob { permissions?: Record<string, string> | string; // ... other properties } ``` ## CI Detection Pattern ```typescript const isCI = process.env.CI === 'true' || !!process.env.GITHUB_ACTIONS || !!process.env.JENKINS_URL || !!process.env.TRAVIS || !!process.env.CIRCLECI || !!process.env.GITLAB_CI || !!process.env.BUILDKITE || !!process.env.DRONE; ``` ## Key Learnings ### Security Testing in CI 1. **Never lower security thresholds** to fix CI issues 2. **Skip unreliable tests** rather than make them less strict 3. **Add deterministic alternatives** when possible 4. **Document why tests are skipped** for future maintainers ### TypeScript in Tests 1. **Use proper mock signatures** - always provide implementations 2. **Declare environment variables** in TypeScript 3. **Keep interfaces in sync** with actual usage 4. **Test compilation regularly** with `npm run build:test` ## Testing Commands ```bash # Run specific test locally npm test -- __tests__/unit/InputValidator.test.ts # Build tests to check TypeScript npm run build:test # Run all tests npm test # Check CI status gh pr checks <PR-NUMBER> # View CI logs gh run view <RUN-ID> --log-failed ``` ## Common CI Issues ### Windows-Specific - PowerShell vs Bash differences - Path separator issues - Timing characteristics differ - GPG warnings (non-fatal) ### Timing Tests - VM overhead affects timing - Background processes interfere - CPU throttling impacts results - Network latency in cloud environments ### TypeScript - Version mismatches - Missing type declarations - Strict mode differences - Build vs runtime environments ## Prevention Strategies 1. **Always test locally** before pushing 2. **Run build:test** to catch TypeScript errors 3. **Consider CI environment** when writing tests 4. **Use deterministic tests** when possible 5. **Document CI-specific behavior** ## Related Issues & PRs - Issue #148: Original flaky test report - PR #185: Timing test fix - Issue #186: CI detection enhancements

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DollhouseMCP/DollhouseMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server