Skip to content

Fix lint automation workflow duplication and enhance issue titles with region context#59

Merged
BorDevTech merged 2 commits into
mainfrom
copilot/fix-503d4353-e0a7-4a80-b5f6-26f3b1390b49
Oct 1, 2025
Merged

Fix lint automation workflow duplication and enhance issue titles with region context#59
BorDevTech merged 2 commits into
mainfrom
copilot/fix-503d4353-e0a7-4a80-b5f6-26f3b1390b49

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 27, 2025

This PR resolves critical issues with the lint automation system that were causing duplicate GitHub issues and poor issue organization.

Issues Fixed

1. Workflow Duplication

The lint automation was running in both lint-automation.yml and nextjs.yml workflows, creating duplicate GitHub issues for the same lint problems. This was particularly problematic when builds failed, as it would trigger lint analysis twice simultaneously.

Before:

  • Next.js workflow runs lint analysis on build failure → creates issues
  • Lint automation workflow runs independently → creates duplicate issues

After:

  • Next.js workflow focuses solely on build and deployment
  • Lint automation workflow runs after Next.js completion → single issue creation

2. Poor Issue Naming

GitHub issues were created with generic filenames like "logic.ts" or "route.ts", making it impossible to distinguish which region/state the issue belonged to.

Before:

Issue Title: "logic.ts"
File: app/api/verify/arizona/logic.ts

After:

Issue Title: "Arizona - logic.ts" 
File: app/api/verify/arizona/logic.ts

3. Improper Workflow Coordination

The lint automation was running simultaneously with the Next.js workflow instead of after it completed, causing race conditions and timing issues.

Technical Changes

Enhanced Title Generation

Added intelligent title generation that includes region context for API verify files while preserving simple names for other files:

// API verify files get region context
app/api/verify/arizona/logic.ts  "Arizona - logic.ts"
app/api/verify/districtofcolumbia/route.ts  "District of Columbia - route.ts"

// Other files remain unchanged  
components/Header.tsx  "Header.tsx"
scripts/build.ts  "build.ts"

The system handles special region name formatting (e.g., "districtofcolumbia" → "District of Columbia") and maintains backward compatibility with existing issues.

Workflow Orchestration

Updated the lint automation workflow to use workflow_run triggers, ensuring it runs automatically after the Next.js deployment completes:

on:
  workflow_run:
    workflows: ["Deploy Next.js site to Pages"]
    types: [completed]
    branches: [main]

Race Condition Protection

Implemented safeguards to prevent duplicate issue creation:

  • Random delays between issue creation attempts
  • Double-checking for existing issues before creation
  • Graceful handling of migration from old to new issue formats

Impact

  • No More Duplicates: Each lint issue will only create one GitHub issue
  • Better Organization: Issues clearly identify which region/state they affect
  • Proper Sequencing: Lint analysis runs after successful/failed builds, not during
  • Maintainability: Easier to track and resolve issues by region

This change significantly improves the developer experience when dealing with lint issues across the multi-region codebase.

Original prompt

This section details on the original issue you should resolve

<issue_title>Prevent duplication of issues after workflow run.</issue_title>
<issue_description>1.) The workflow for lint is causing the issues to still be created 2 times.
2.) the file name for the issue is great but the folder or relevant information is missing like region name for something in the "Arizona" folder of the api folder
Ex. The issues would be called Arizona - Logic.ts for something lint related coming from the logic file in that case and same for route.ts and so on.
3.) the lint check workflow is meant to run automatically...after the next pages workflow. Not during , not cohesively.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #58

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clear-view Ready Ready Preview Comment Sep 27, 2025 9:58am

Co-authored-by: BorDevTech <73800053+BorDevTech@users.noreply.github.com>
Copilot AI changed the title [WIP] Prevent duplication of issues after workflow run. Fix lint automation workflow duplication and enhance issue titles with region context Sep 27, 2025
Copilot AI requested a review from BorDevTech September 27, 2025 09:59
@BorDevTech BorDevTech marked this pull request as ready for review October 1, 2025 17:52
Copilot AI review requested due to automatic review settings October 1, 2025 17:52
@BorDevTech BorDevTech merged commit 27e53b6 into main Oct 1, 2025
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR resolves critical duplication issues in the lint automation system and enhances GitHub issue organization by adding region context to issue titles. The changes ensure lint analysis runs sequentially after Next.js deployment rather than simultaneously, preventing duplicate issue creation.

  • Removed duplicate lint analysis from Next.js workflow to prevent race conditions
  • Enhanced issue titles with region context for API verify files (e.g., "Arizona - logic.ts")
  • Added workflow coordination using workflow_run triggers for proper sequencing

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
scripts/lint-automation/github-issue-creator.ts Added region-aware title generation and backward compatibility for existing issues
.github/workflows/nextjs.yml Removed duplicate lint analysis job to prevent issue duplication
.github/workflows/lint-automation.yml Added workflow_run trigger to run after Next.js completion

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

title: fileName,
body: this.generateFileIssueBody(fileName, filePath, fileIssues),
title: enhancedTitle,
body: this.generateFileIssueBody(enhancedTitle, filePath, fileIssues),
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The generateFileIssueBody method is being called with enhancedTitle as the first parameter, but this might not be the intended behavior. Based on the context, the first parameter should likely be the original fileName since the body generation might expect the actual filename rather than the enhanced display title.

Suggested change
body: this.generateFileIssueBody(enhancedTitle, filePath, fileIssues),
body: this.generateFileIssueBody(fileName, filePath, fileIssues),

Copilot uses AI. Check for mistakes.
Comment on lines +514 to +532
const specialCases: Record<string, string> = {
'districtofcolumbia': 'District of Columbia',
'newhampshire': 'New Hampshire',
'newjersey': 'New Jersey',
'newmexico': 'New Mexico',
'newyork': 'New York',
'northcarolina': 'North Carolina',
'northdakota': 'North Dakota',
'rhodeisland': 'Rhode Island',
'southcarolina': 'South Carolina',
'southdakota': 'South Dakota',
'westvirginia': 'West Virginia',
'britishcolumbia': 'British Columbia',
'newbrunswick': 'New Brunswick',
'newfoundland&labrador': 'Newfoundland & Labrador',
'novascotia': 'Nova Scotia',
'princeedwardisland': 'Prince Edward Island',
'puertorico': 'Puerto Rico'
};
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

[nitpick] The hardcoded mapping of region names could be moved to a configuration file or constants module for better maintainability. This would make it easier to add new regions or modify existing ones without changing the core logic.

Copilot uses AI. Check for mistakes.
}

// If no exact match found, try searching for just the filename part (for backward compatibility)
if (fileNamePart !== enhancedTitle) {
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

This condition could be optimized by checking if the enhanced title contains ' - ' before making the API call, since the fileNamePart extraction logic already handles this case. Consider moving this check earlier to avoid unnecessary API calls when the enhanced title doesn't have region context.

Suggested change
if (fileNamePart !== enhancedTitle) {
if (enhancedTitle.includes(' - ')) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent duplication of issues after workflow run.

3 participants