Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 22, 2025

This PR adds automatic linting error fixing capability to the build-node-python action and workflow, allowing developers to automatically fix linting issues via workflow_dispatch.

Changes Made

🎯 Core Functionality

  • Auto-fix parameter: Added auto_fix_lint input (default: false) to maintain backward compatibility
  • Smart error handling: Modified build logic to catch lint failures and attempt fixes when enabled
  • Fix commands: Automatically runs yarn lint:fix for frontend and make format for backend projects
  • Validation: Re-runs linting after fixes to ensure they resolved the issues
  • Auto-commit: Commits successful fixes with message "Auto-fix: Apply linting and formatting fixes [skip ci]"

🚀 Workflow Dispatch Support

  • Added workflow_dispatch trigger to build-node-python.yml workflow
  • Manual triggering now available with auto-fix checkbox in GitHub UI
  • Includes all relevant parameters: auto_fix_lint, cypress_enable, playwright_enable, etc.

🔧 Integration

  • Updated all 4 action calls in the workflow to pass the auto_fix_lint parameter:
    • build-node job
    • build-python job
    • build-node-python-cypress job
    • build-node-python-playwright job

Usage Examples

Via workflow_call:

uses: datavisyn/github-workflows/.github/workflows/build-node-python.yml@main
with:
  auto_fix_lint: true

Via workflow_dispatch:
Manually trigger the workflow from GitHub Actions tab with auto-fix enabled.

Direct action usage:

uses: datavisyn/github-workflows/.github/actions/build-node-python@main
with:
  auto_fix_lint: true
  # ... other parameters

How It Works

  1. Normal flow: Runs standard linting process first
  2. On failure: If linting fails and auto_fix_lint: true, attempts to fix errors
  3. Fix execution: Runs yarn lint:fix (Node.js) and/or make format (Python)
  4. Re-validation: Re-runs linting to verify fixes worked
  5. Auto-commit: Commits and pushes changes if fixes were successful
  6. Failure handling: Still fails the workflow if fixes don't resolve all issues

Backward Compatibility

Fully backward compatible: All existing workflows continue to work without modification since auto_fix_lint defaults to false.

Requirements

For auto-fix to work, projects should have:

  • yarn lint:fix command available (Node.js projects)
  • make format target available (Python projects)
  • Workflow needs contents: write permission for commits

Testing

  • ✅ YAML syntax validation
  • ✅ Created test script validating auto-fix logic
  • ✅ Verified git configuration and commit functionality
  • ✅ Confirmed parameter passing through all action calls
  • ✅ Validated backward compatibility

Fixes #192.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits July 22, 2025 11:02
Co-authored-by: puehringer <51900829+puehringer@users.noreply.github.com>
Co-authored-by: puehringer <51900829+puehringer@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Allow running yarn lint:fix and make format as workflow_dispatch for the build job Add auto-fix functionality for yarn lint:fix and make format in build-node-python workflow Jul 22, 2025
@Copilot Copilot AI requested a review from puehringer July 22, 2025 11:07
Copilot finished work on behalf of puehringer July 22, 2025 11:07
Comment on lines 108 to 139
workflow_dispatch:
inputs:
branch:
type: string
required: false
description: "Branch to build"
default: "main"
auto_fix_lint:
description: "Automatically fix linting errors when possible and commit changes"
type: boolean
required: false
default: false
cypress_enable:
description: "Global enable for cypress"
type: boolean
required: false
default: false
playwright_enable:
description: "Global enable for playwright"
type: boolean
required: false
default: false
node_run_webpack:
description: "Flag to always run the webpack production build."
type: boolean
required: false
default: false
run_parallel:
description: "Flag to ensure that node and python jobs are run in parallel."
type: boolean
required: false
default: true
Copy link
Contributor

Choose a reason for hiding this comment

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

This is never dispatched, just called. So it can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the workflow_dispatch section. You're absolutely right - this is a reusable workflow that's only called by other workflows, not manually dispatched. The auto_fix_lint parameter remains available in the workflow_call inputs. Changes in commit 53a2368.

Co-authored-by: puehringer <51900829+puehringer@users.noreply.github.com>
@Copilot Copilot AI requested a review from puehringer July 22, 2025 11:25
Copilot finished work on behalf of puehringer July 22, 2025 11:25
echo "No staged changes to commit"
return 0
fi
git commit -m "Auto-fix: Apply linting and formatting fixes [skip ci]" || true
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't want to skip the CI at this point, as things may still break (an infinite loop should not happen as we don't commit if no changes are made, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed [skip ci] from the commit message to allow CI validation. The commit message is now just "Auto-fix: Apply linting and formatting fixes" which will trigger CI as expected. You're right about the infinite loop protection - we only commit when there are actual staged changes. Changes in commit 97d745e.

Co-authored-by: puehringer <51900829+puehringer@users.noreply.github.com>
@Copilot Copilot AI requested a review from puehringer July 22, 2025 11:45
Copilot finished work on behalf of puehringer July 22, 2025 11:45
Copilot finished work on behalf of puehringer July 22, 2025 11:47
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.

Allow running yarn lint:fix and make format as workflow_dispatch for the build job
2 participants