Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile --prefer-offline

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
135 changes: 33 additions & 102 deletions .github/workflows/dependency-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,50 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9.0.0
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9.0.0

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile --prefer-offline
# NOTE: If this fails with ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY,
# run locally: rm pnpm-lock.yaml && pnpm install --no-frozen-lockfile

- name: Run Repair Script
run: |
bash scripts/repair-dependencies.sh
continue-on-error: false

- name: Run Health Check
id: health-check
run: |
bash scripts/master.sh health --json > health-report.json
cat health-report.json
continue-on-error: false

- name: Smart Brain Oracle Analysis
run: |
.smartbrain/oracle.sh analyze > oracle-report.txt
cat oracle-report.txt
continue-on-error: true

- name: Security Audit
run: |
pnpm audit --audit-level=moderate || echo "Security vulnerabilities detected"
continue-on-error: true

- name: Build packages
run: |
echo "Building packages in dependency order..."
pnpm --filter @castquest/neo-ux-core build
pnpm --filter @castquest/sdk build
pnpm --filter @castquest/core-services build
continue-on-error: false
env:
CI: false

- name: Check Version Consistency
id: version-check
run: |
Expand All @@ -92,78 +85,48 @@ jobs:
NEXT_VERSIONS=$(find . -name "package.json" -not -path "*/node_modules/*" -exec grep -h '"next"' {} \; | sort -u | wc -l)
echo "next_versions=$NEXT_VERSIONS" >> $GITHUB_OUTPUT

if [ "$TS_VERSIONS" -le 2 ] && [ "$NODE_TYPES_VERSIONS" -le 2 ] && [ "$NEXT_VERSIONS" -le 1 ]; then
# Allow up to 2 Next.js versions: frames uses 14.2.18, admin/web use 14.2.35
if [ "$TS_VERSIONS" -le 2 ] && [ "$NODE_TYPES_VERSIONS" -le 2 ] && [ "$NEXT_VERSIONS" -le 2 ]; then
echo "Version consistency check passed ✓"
echo "consistent=true" >> $GITHUB_OUTPUT
else
echo "Version consistency check failed ✗"
echo "TypeScript versions: $TS_VERSIONS (should be ≤2)"
echo "@types/node versions: $NODE_TYPES_VERSIONS (should be ≤2)"
echo "Next.js versions: $NEXT_VERSIONS (should be 1)"
echo "Next.js versions: $NEXT_VERSIONS (should be ≤2)"
echo "consistent=false" >> $GITHUB_OUTPUT
fi

- name: Upload Health Report
uses: actions/upload-artifact@v4.4.3
if: always()
with:
name: health-report
name: version-report
path: |
health-report.json
oracle-report.txt
package.json
pnpm-lock.yaml

- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

let healthReport = { status: 'unknown', checks_passed: 0, checks_failed: 0 };
try {
healthReport = JSON.parse(fs.readFileSync('health-report.json', 'utf8'));
} catch (e) {
console.log('Could not parse health report');
}

let oracleReport = '';
try {
oracleReport = fs.readFileSync('oracle-report.txt', 'utf8');
} catch (e) {
console.log('Could not read oracle report');
}

const versionConsistent = '${{ steps.version-check.outputs.consistent }}' === 'true';

const statusEmoji = healthReport.status === 'healthy' ? '✅' : '⚠️';
const versionEmoji = versionConsistent ? '✅' : '❌';

const comment = `## 🏥 Dependency Health Check

**Status:** ${statusEmoji} ${healthReport.status}
**Checks Passed:** ${healthReport.checks_passed}
**Checks Failed:** ${healthReport.checks_failed}
**Status:** ${versionConsistent ? '✅ Healthy' : '⚠️ Inconsistent Versions Detected'}
**Version Consistency:** ${versionEmoji} ${versionConsistent ? 'Consistent' : 'Inconsistent'}

<details>
<summary>📊 Smart Brain Oracle Analysis</summary>

\`\`\`
${oracleReport.substring(0, 2000)}
\`\`\`
</details>

<details>
<summary>ℹ️ Health Report Details</summary>

\`\`\`json
${JSON.stringify(healthReport, null, 2)}
\`\`\`
</details>
### Version Summary
- TypeScript versions: ${{ steps.version-check.outputs.ts_versions }}
- @types/node versions: ${{ steps.version-check.outputs.node_types_versions }}
- Next.js versions: ${{ steps.version-check.outputs.next_versions }}

---

${healthReport.status === 'unhealthy' || !versionConsistent ? '⚠️ **Action Required:** Please address the issues above before merging.' : '✅ All checks passed! Safe to merge.'}
${!versionConsistent ? '⚠️ **Action Required:** Please address version inconsistencies before merging.' : '✅ All checks passed! Safe to merge.'}
`;

github.rest.issues.createComment({
Expand All @@ -178,15 +141,6 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

let healthReport = { status: 'unknown' };
try {
healthReport = JSON.parse(fs.readFileSync('health-report.json', 'utf8'));
} catch (e) {
console.log('Could not parse health report');
}

const title = '🚨 Dependency Health Check Failed';
const body = `## Automated Health Check Failure

Expand All @@ -196,27 +150,11 @@ jobs:
**Triggered by:** ${context.eventName}
**Timestamp:** ${new Date().toISOString()}

### Status
- Health Status: ${healthReport.status || 'unknown'}
- Checks Failed: ${healthReport.checks_failed || 'unknown'}

### Recommended Actions
1. Review the workflow run logs for detailed error information
2. Run \`bash scripts/repair-dependencies.sh\` locally to diagnose issues
3. Run \`bash scripts/master.sh health\` to see detailed health report
4. Check \`.smartbrain/oracle.sh analyze\` for AI-powered insights

### Quick Fix
\`\`\`bash
# Clean and repair dependencies
bash scripts/repair-dependencies.sh

# Run health check
bash scripts/master.sh health

# Get oracle recommendations
.smartbrain/oracle.sh recommend-upgrades
\`\`\`
2. Check for version inconsistencies across packages
3. Verify all builds complete successfully
4. Review security audit results

This issue was automatically created by the Dependency Health Check workflow.
`;
Expand All @@ -228,10 +166,3 @@ jobs:
body: body,
labels: ['dependencies', 'automated', 'health-check']
});

- name: Set workflow status
if: always()
# Validates health-report.json and exits with appropriate status code
# The check-health.js script handles missing files and parse errors gracefully
run: |
node scripts/health/check-health.js health-report.json
Loading
Loading