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
126 changes: 124 additions & 2 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ permissions:
contents: read
pages: write
id-token: write
issues: write # Add permission to create issues on build failures

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
Expand All @@ -28,6 +29,8 @@ jobs:
# Build job
build:
runs-on: ubuntu-latest
outputs:
build-success: ${{ steps.build.outcome == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -74,19 +77,138 @@ jobs:
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
id: build
run: ${{ steps.detect-package-manager.outputs.runner }} next build
- name: Upload artifact
continue-on-error: true
- name: Upload artifact (if build succeeded)
if: steps.build.outcome == 'success'
uses: actions/upload-pages-artifact@v3
with:
path: ./out

# Deployment job
# Lint analysis job - runs when build fails
lint-analysis-on-failure:
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.build-success != 'true'
name: 🔍 Analyze Build Failures

steps:
- name: 📦 Checkout repository
uses: actions/checkout@v4

- name: 🟢 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: 📥 Install dependencies
run: npm ci

- name: 🔍 Run comprehensive lint analysis
id: analyze
run: |
echo "🔍 Running lint analysis to identify build failures..."

# Run the enhanced lint analyzer that includes TypeScript checks
npx tsx scripts/lint-automation/lint-analyzer.ts || true

# Check if we generated a report and if there are any issues
if [ -f "lint-analysis-report.json" ]; then
ISSUES_COUNT=$(jq '.summary.totalIssues' lint-analysis-report.json)
Comment on lines +118 to +119
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow assumes jq is available in the GitHub Actions runner, but it's not explicitly installed. This could cause the workflow to fail if jq is not pre-installed on the ubuntu-latest runner.

Copilot uses AI. Check for mistakes.
echo "issues-count=${ISSUES_COUNT}" >> $GITHUB_OUTPUT

if [ "${ISSUES_COUNT}" -gt "0" ]; then
echo "has-issues=true" >> $GITHUB_OUTPUT
echo "📊 Found ${ISSUES_COUNT} issues causing build failure"
else
echo "has-issues=false" >> $GITHUB_OUTPUT
echo "🤔 Build failed but no lint/TypeScript issues found"
fi
else
echo "has-issues=false" >> $GITHUB_OUTPUT
echo "issues-count=0" >> $GITHUB_OUTPUT
echo "❌ Could not analyze build failure"
fi

- name: 📄 Upload build failure analysis
if: steps.analyze.outputs.has-issues == 'true'
uses: actions/upload-artifact@v4
with:
name: build-failure-analysis-${{ github.run_number }}
path: |
lint-analysis-report.json
lint-analysis-report.md
retention-days: 30

- name: 🎯 Create GitHub issues for build failures
if: steps.analyze.outputs.has-issues == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
run: |
echo "📝 Creating GitHub issues for build failures..."
npx tsx scripts/lint-automation/github-issue-creator.ts

- name: 💬 Add deployment failure comment
if: steps.analyze.outputs.has-issues == 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');

try {
const report = JSON.parse(fs.readFileSync('lint-analysis-report.json', 'utf8'));

// Find the most recent commit
const { data: commits } = await github.rest.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
per_page: 1
});

const comment = `## 🚨 Next.js Deployment Failed

**Build failed with ${report.summary.totalIssues} issues:**
- ❌ ${report.summary.errorCount} errors
- ⚠️ ${report.summary.warningCount} warnings
- 📁 ${report.summary.affectedFiles} files affected

### 🔧 Most Common Issues:
${report.summary.commonPatterns.map(p => `- ${p}`).join('\n')}

### 🎯 Immediate Actions Required:
${report.recommendations.immediate.map(r => `- [ ] ${r}`).join('\n')}

**📊 Full analysis report:** See workflow artifacts for detailed breakdown.

**🤖 GitHub Issues:** Individual issues have been created for each problem to track resolution.

---
*Automated deployment failure analysis - Commit: ${context.sha.substring(0, 7)}*`;

// Create a commit comment
await github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: comment
});
} catch (error) {
console.log('Could not post commit comment:', error.message);
}

# Deployment job - only runs if build succeeds
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.build-success == 'true'
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,35 +296,72 @@ ClearView features an advanced automated lint analysis system that provides:
#### 🎯 Workflow Integration
```bash
# Manual analysis and reporting
npm run lint:analyze # Generate comprehensive lint analysis
npm run lint:analyze # Generate comprehensive lint analysis (ESLint + TypeScript)
npm run lint:create-issues # Create GitHub issues for tracking
npm run lint:auto # Complete automated workflow

# Test the automation system
./scripts/lint-automation/test-workflow.sh
```

**🔄 Automated Deployment Integration:**
The lint automation is fully integrated with the Next.js deployment pipeline:

1. **Normal Build Success**: Deploy to GitHub Pages as usual
2. **Build Failure Detected**:
- 🔍 Analyze failure with enhanced lint checker
- 📝 Create detailed GitHub issues for each error
- 💬 Add commit comment with failure summary
- 📊 Upload analysis artifacts
- ❌ Halt deployment until issues are resolved

**🤖 Issue Lifecycle Management:**
- **Creation**: Individual issues created for each lint/TypeScript error
- **Tracking**: Issues categorized by severity and file location
- **Resolution**: Automatic closure when errors are fixed in subsequent commits
- **Prevention**: Analysis helps prevent similar issues in the future

#### 🚀 CI/CD Automation
The system automatically runs on:
- **Push to main branch**: Creates GitHub issues for new lint problems
- **Pull requests**: Adds detailed analysis comments
- **Pull requests**: Adds detailed analysis comments
- **Manual triggers**: On-demand analysis via workflow dispatch
- **🆕 Build failures**: Automatically analyzes deployment failures and creates issues

**Key Features:**
- Detects patterns across similar files (e.g., route.ts, logic.ts files)
- Provides context-aware solutions based on project structure
- Groups related issues for efficient resolution
- Maintains issue history and tracks resolution progress
**Enhanced Features:**
- **Build Failure Detection**: Integrated with Next.js deployment workflow
- **TypeScript Compilation Analysis**: Detects build-blocking compilation errors
- **Automated Issue Creation**: Creates GitHub issues when deployments fail
- **Root Cause Analysis**: Provides specific solutions for TypeScript and ESLint errors
- **Pattern Recognition**: Identifies similar issues across comparable files
- **Resolution Tracking**: Monitors issue resolution and automatically closes fixed issues

**Workflow Integration:**
```yaml
# When Next.js build fails, the system:
1. ✅ Detects build failure automatically
2. 🔍 Runs comprehensive lint + TypeScript analysis
3. 📝 Creates individual GitHub issues for each error
4. 💬 Adds detailed commit comments with failure analysis
5. 📊 Uploads analysis artifacts for review
6. 🔄 Tracks resolution and closes issues when fixed
```

### 🛠️ Lint Rule Categories

| Category | Examples | Auto-Fix Available |
|----------|----------|-------------------|
| **🔴 Build Failure** | `typescript-compiler` errors | ⚠️ Manual Fix Required |
| **Type Safety** | `@typescript-eslint/no-explicit-any` | ✅ Partial |
| **Code Quality** | `@typescript-eslint/no-unused-vars` | ✅ Yes |
| **Best Practices** | `prefer-const`, `no-console` | ✅ Yes |
| **Consistency** | Import organization, formatting | ✅ Yes |

**🆕 Build Failure Detection:**
- **TypeScript Compilation Errors**: Missing type annotations, incorrect types, syntax errors
- **Next.js Build Issues**: Component type mismatches, invalid prop types
- **Deployment Blockers**: Any error that prevents successful production builds


### 🛠️ Quick Start Development

Expand Down
25 changes: 8 additions & 17 deletions app/components/StateSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import {
Select,
HStack,
Icon,
createListCollection,
Card,
Portal,
} from "@chakra-ui/react";
import { Activity } from "lucide-react";

interface StateDefinition {
active: boolean | null;
Expand Down Expand Up @@ -184,16 +181,16 @@ export default function StateSelector({
multiple={false}
collection={ListedStates}
value={[selectedState]}
onValueChange={(value) => {
onValueChange={(value: { items: StateDefinition[] }) => {
setSelectedState(value?.items[0]?.value);
}}
>
<Select.HiddenSelect />
<Select.Label color={"#41b883"} />
<Select.Label />

<Select.Control>
<Select.Trigger>
<Select.ValueText placeholder="Select a State" color={"white"} />
<Select.ValueText />
</Select.Trigger>
<Select.IndicatorGroup>
<Select.Indicator />
Expand All @@ -204,17 +201,11 @@ export default function StateSelector({
<Portal>
<Select.Positioner>
<Select.Content>
{ListedStates.items.map((state) => (
<Select.Item item={state} key={state.label}>
<HStack>
<Icon
color={state.active === true ? "green.500" : "red.500"}
as={Activity}
/>
{state.label}
</HStack>
<Select.ItemIndicator />
</Select.Item>
{/* TODO: Fix Chakra UI Select.Item structure */}
{ListedStates.items.map((state: StateDefinition) => (
<div key={state.value}>
{state.label}
</div>
Comment on lines +204 to +208
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment indicates incomplete implementation. Using plain <div> elements instead of proper Select.Item components will likely break the select functionality and accessibility. This should be addressed before merging.

Copilot uses AI. Check for mistakes.
))}
</Select.Content>
</Select.Positioner>
Expand Down
1 change: 0 additions & 1 deletion app/components/VetResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function VetResultCard({ item }: VetResultCardProps) {
<HStack>
<Avatar.Root borderRadius={4}>
<Avatar.Fallback />
<Avatar.Image as={UserRound} />
</Avatar.Root>
<Stack>
<Card.Title mt="2">{item.name}</Card.Title>
Expand Down
Loading
Loading