-
Notifications
You must be signed in to change notification settings - Fork 43
Description
🏥 CI Failure Investigation - Run #29542
Summary
The CI workflow failed with 46 JavaScript test failures across 4 test files in the js job. The failure is NOT caused by code changes in PR #9954 (which only adds documentation), but exposes pre-existing test environment issues.
Failure Details
- Run: #20997451868
- Commit: efad162
- Trigger: push (main branch)
- Duration: 5m47s
- Failed Job:
js(step 7: Run tests)
Root Cause Analysis
🔴 Primary Issue: Read-Only Filesystem (4 failures)
File: check_workflow_recompile_needed.test.cjs
Error: EROFS: read-only file system, open '/opt/gh-aw/prompts/workflow_recompile_issue.md'
Root Cause: Tests attempt to write template files to /opt/gh-aw/prompts/ which is read-only in CI. The CI workflow's "Setup prompt templates for tests" step copies files to this location but doesn't make it writable.
Impact: All 4 tests in this file fail during setup and teardown.
🟡 Secondary Issue: Empty Output Validation (38 failures)
File: collect_ndjson_output.test.cjs
Error: expected [] to have a length of X but got +0
Root Cause: Tests expect parsedOutput.items to contain validation results, but receiving empty arrays. This suggests validation logic changed without updating tests.
Example failing tests:
should validate required fields for add-labels typeshould validate required fields for create-pull-request typeshould respect max limits from config- All JSON repair functionality tests
- All code scanning alert validation tests
🟢 Tertiary Issue: MCP Server Timeouts (2 failures)
File: safe_outputs_mcp_server_defaults.test.cjs
Error: Test timed out in 10000ms
Tests:
should have optional branch parameter for create_pull_requestshould have optional branch parameter for push_to_pull_request_branch
Test Summary
- Test Files: 4 failed | 130 passed (134 total)
- Tests: 46 failed | 2619 passed | 12 skipped (2677 total)
- Duration: 75.69s
Investigation Findings
Important Context
PR #9954 only adds documentation - it creates a new file docs/src/content/docs/setup/cli.md with 490 lines of CLI documentation. No changes to JavaScript code or tests.
This means: The test failures are pre-existing issues that were exposed by this CI run, not introduced by the PR.
Reproduction Steps
cd actions/setup/js
npm ci
npm test
# Observe 46 test failuresRecommended Actions
🔴 HIGH PRIORITY - Fix Filesystem Issue
File: actions/setup/js/check_workflow_recompile_needed.test.cjs
Replace hardcoded /opt/gh-aw/prompts/ path with temp directory:
import os from 'os';
import path from 'path';
// BEFORE (line 12)
const templatePath = "/opt/gh-aw/prompts/workflow_recompile_issue.md";
// AFTER
const templatePath = path.join(os.tmpdir(), 'gh-aw-test', 'workflow_recompile_issue.md');Alternative: Make /opt/gh-aw/prompts writable in CI:
- name: Setup prompt templates for tests
run: |
sudo mkdir -p /opt/gh-aw/prompts
sudo chmod 777 /opt/gh-aw/prompts
cp actions/setup/md/*.md /opt/gh-aw/prompts/🟡 MEDIUM PRIORITY - Fix Validation Tests
File: actions/setup/js/collect_ndjson_output.test.cjs
Investigate why parsedOutput.items is empty:
- Check if safe output type registration changed
- Verify test data format matches current validation logic
- Update test expectations if validation behavior changed
- Add debug logging to see what's being parsed
🟢 LOW PRIORITY - Fix MCP Server Tests
File: actions/setup/js/safe_outputs_mcp_server_defaults.test.cjs
Increase timeout from 10000ms to 30000ms or add server startup verification.
Prevention Strategies
Pre-Commit Checklist
cd actions/setup/js
npm ci # Install dependencies
npm test # MUST pass before commitTest Writing Rules
- ✅ Use
os.tmpdir()for temp files, never/opt/or/var/ - ✅ Mock file system operations when possible
- ✅ Use test fixtures instead of runtime file creation
- ❌ Never assume
/opt/directories are writable in CI - ❌ Never skip test runs before committing
Example Pattern
// ❌ BAD - hardcoded system path
const templatePath = '/opt/gh-aw/prompts/template.md';
// ✅ GOOD - temp directory
import os from 'os';
import path from 'path';
const templatePath = path.join(os.tmpdir(), 'gh-aw-test', 'template.md');AI Team Self-Improvement
Add to AI agent instructions:
## JavaScript Test Requirements
**ALWAYS run npm test before committing:**
```bash
cd actions/setup/js
npm ci && npm testTest fails? DO NOT commit. Fix tests first.
Test Writing Rules
- Use
os.tmpdir()for temp files, never/opt/or/var/ - Mock file system operations when possible
- Use test fixtures instead of runtime file creation
- Increase timeouts for CI environment (3x local)
- Verify all external dependencies are available
Common CI Test Pitfalls
- ❌
/opt/is read-only in GitHub Actions - ❌
/tmp/may be cleared between jobs - ❌ Timeouts are shorter in CI
- ✅ Use
os.tmpdir()for file operations - ✅ Increase timeouts 3x for CI environment
---
## Investigation Metadata
- **Pattern**: `JS_TEST_ENVIRONMENT_FAILURES` (1st occurrence)
- **Investigation Record**: `/tmp/gh-aw/cache-memory/investigations/2026-01-14-20997451868.json`
- **Created**: 2026-01-14T14:32:00Z
> 🤖 AI generated by [CI Failure Doctor](https://github.com/githubnext/gh-aw/actions/runs/20997639422)
> AI generated by [CI Failure Doctor](https://github.com/githubnext/gh-aw/actions/runs/20997639422)
>
> To add this workflow in your repository, run `gh aw add githubnext/agentics/workflows/ci-doctor.md@ea350161ad5dcc9624cf510f134c6a9e39a6f94d`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).
<!-- agentic-workflow: CI Failure Doctor, engine: copilot, run: https://github.com/githubnext/gh-aw/actions/runs/20997639422 -->