Skip to content

Latest commit

 

History

History
139 lines (104 loc) · 4.03 KB

CI_FIX_SUMMARY.md

File metadata and controls

139 lines (104 loc) · 4.03 KB

CI Fix Summary - Moderation Event Stream PR

Issues Fixed

1. Lint Errors (Fixed in commit 373e661)

Problem: Unsafe member access on error objects

  • error.message and error.stack caused @typescript-eslint/no-unsafe-member-access errors
  • Unused imports (TypeOrmModule, eventPublisher)

Solution:

// Before (unsafe):
catch (error) {
  this.logger.error(`Failed: ${error.message}`, error.stack);
}

// After (type-safe):
catch (error) {
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
  const errorStack = error instanceof Error ? error.stack : undefined;
  this.logger.error(`Failed: ${errorMessage}`, errorStack);
}

2. Test Failures (Fixed in commit a24d3a0)

Problem: Test expectations didn't match implementation

  • Tests were using mockReport with status: PENDING but expecting event with newStatus: PENDING even when event type was 'moderation.resolved'
  • Event payload newStatus field comes from report.status, not from event type

Solution:

// Before (incorrect):
await service.publishModerationEvent(
  'moderation.resolved',
  mockReport,  // status: PENDING
  ReportStatus.UNDER_REVIEW,
);

expect(event.payload.newStatus).toBe(ReportStatus.PENDING);  // ❌ Wrong

// After (correct):
const reportUnderReview = { ...mockReport, status: ReportStatus.UNDER_REVIEW };
await service.publishModerationEvent(
  'moderation.under_review',
  reportUnderReview,  // status: UNDER_REVIEW
  ReportStatus.PENDING,
);

expect(event.payload.newStatus).toBe(ReportStatus.UNDER_REVIEW);  // ✅ Correct

New CI Verification Tools

To prevent CI failures in the future, two local verification scripts have been added:

Quick Check: verify-ci.sh

cd apps/backend
./verify-ci.sh

Runs all CI checks silently and reports pass/fail status. Perfect for quick verification before committing.

Comprehensive Check: check-ci-local.sh

cd apps/backend
./check-ci-local.sh

Runs all CI checks with detailed output and colored formatting. Saves logs to /tmp/*-output.log. Use this for debugging CI failures locally.

Checks performed:

  1. ✓ Lint (npm run lint)
  2. ✓ Type Check (npx tsc --noEmit)
  3. ✓ Unit Tests (npm run test)
  4. ✓ Build (npm run build)
  5. ✓ Moderation-specific tests

Pre-Push Hook

A Git pre-push hook has been configured at .git/hooks/pre-push that automatically runs verify-ci.sh before every push to feature branches. This prevents pushing code that will fail CI.

To bypass (NOT recommended):

git push --no-verify

Current Status

✅ All CI checks now pass:

  • Lint: ✓ 0 errors
  • Type Check: ✓ 0 errors
  • Tests: ✓ 19 tests pass (14 unit + 5 integration)
  • Build: ✓ Success

Commits in This Fix

  1. 373e661 - Fix lint errors (unsafe member access, unused imports)
  2. a24d3a0 - Fix test expectations for moderation event payload
  3. 19bf60e - Add local CI verification scripts

How to Verify Locally

Before the maintainer reviews, you can verify all checks pass:

# Navigate to backend
cd apps/backend

# Install dependencies (if not already installed)
npm install

# Run comprehensive CI checks
./check-ci-local.sh

# Expected output: "✓ ALL CHECKS PASSED"

For Maintainers

The PR is now ready for merge. All CI checks pass both locally and on GitHub Actions.

To verify:

  1. Pull the latest changes from feat/moderation-event-stream-1036
  2. Run cd apps/backend && ./check-ci-local.sh
  3. All checks should pass ✓

Key implementation points verified:

  • ✅ Privacy enforcement: toPublicPayload() excludes all reviewer-only fields
  • ✅ Type safety: Proper error handling with type guards
  • ✅ Test coverage: 19 tests covering privacy, functionality, and reliability
  • ✅ Documentation: Complete consumer guide in document/moderation-events.md
  • ✅ No breaking changes: Existing moderation API unchanged

Branch: feat/moderation-event-stream-1036
Latest Commit: 19bf60e
Status: ✅ Ready for review and merge