-
Notifications
You must be signed in to change notification settings - Fork 13
feat: expand self-healing pipeline to any failed pipelines due to codestyles #4777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
4
commits into
main
Choose a base branch
from
copilot/fix-4562
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2390f66
Initial plan
Copilot 3f92b48
Add self-healing lint workflow and update default pipeline
Copilot 2cab8c9
Improve self-healing lint workflow with better conditions and documen…
Copilot c264c06
Merge branch 'main' into copilot/fix-4562
michaelmkraus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # Self-Healing Lint Workflow | ||
| # | ||
| # This workflow runs linting and automatically fixes code style issues when possible. | ||
| # Behavior: | ||
| # - For pull requests (non-dependabot): Attempts to auto-fix style issues and commits changes | ||
| # - For dependabot PRs: Only attempts fixes but doesn't commit (dedicated workflow handles this) | ||
| # - For main branch pushes: Only attempts fixes but doesn't commit (manual intervention required) | ||
| # - For unfixable issues: Fails the workflow as before | ||
| # | ||
| # Auto-fixable issues include: | ||
| # - prettier/xo formatting issues | ||
| # - stylelint CSS/SCSS formatting issues | ||
| # - markdownlint markdown formatting issues | ||
| # | ||
| # Non-fixable issues include: | ||
| # - jscpd code duplication | ||
| # - structural code issues (unused variables, etc.) | ||
| # - custom lint rule violations | ||
|
|
||
| name: Self-Healing Lint | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Self-Healing Lint | ||
| runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: ⏬️ Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
|
|
||
| - name: 🔄 Init Cache | ||
| uses: ./.github/actions/npm-cache | ||
|
|
||
| - name: 🔍 Check lint status (attempt 1) | ||
| id: lint_check | ||
| run: | | ||
| # Pre-build stylelint package if needed | ||
| npm run postinstall --workspace=nuxt-showcase | ||
| npm run build --workspace=@db-ux/core-stylelint | ||
|
|
||
| # Run lint and capture exit code | ||
| set +e | ||
| npm run lint | ||
| LINT_EXIT_CODE=$? | ||
| set -e | ||
|
|
||
| if [ $LINT_EXIT_CODE -eq 0 ]; then | ||
| echo "✅ Lint passed on first attempt" | ||
| echo "lint_passed=true" >> $GITHUB_ENV | ||
| echo "needs_fixing=false" >> $GITHUB_ENV | ||
| else | ||
| echo "❌ Lint failed on first attempt" | ||
| echo "lint_passed=false" >> $GITHUB_ENV | ||
| echo "needs_fixing=true" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| - name: 🔧 Attempt auto-fix for style issues | ||
| if: env.needs_fixing == 'true' | ||
| run: | | ||
| echo "🔧 Attempting to auto-fix lint issues..." | ||
|
|
||
| # Check for changes before fixing | ||
| echo "📋 Files before fixing:" | ||
| git status --porcelain | ||
|
|
||
| # Run formatters with --fix flags | ||
| echo "🎨 Running prettier/xo fix..." | ||
| npm run lint:xo -- --fix || true | ||
|
|
||
| echo "🎨 Running stylelint fix..." | ||
| npm run lint:stylelint -- --fix || true | ||
|
|
||
| echo "📝 Running markdownlint fix..." | ||
| npm run lint:markdownlint -- --fix || true | ||
|
|
||
| # Check if any changes were made | ||
| if [[ -n "$(git status --porcelain)" ]]; then | ||
| echo "✅ Auto-fix made changes to files" | ||
| echo "changes_made=true" >> $GITHUB_ENV | ||
| else | ||
| echo "ℹ️ No changes made by auto-fix" | ||
| echo "changes_made=false" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| # For dependabot PRs, we don't auto-commit here as they have their own workflow | ||
| if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then | ||
| echo "ℹ️ Dependabot PR detected - skipping auto-commit (handled by dedicated workflow)" | ||
| fi | ||
|
|
||
| - name: 🔍 Check lint status after fixes (attempt 2) | ||
| if: env.needs_fixing == 'true' | ||
| id: lint_recheck | ||
| run: | | ||
| # Run lint again and capture exit code | ||
| set +e | ||
| npm run lint | ||
| LINT_EXIT_CODE=$? | ||
| set -e | ||
|
|
||
| if [ $LINT_EXIT_CODE -eq 0 ]; then | ||
| echo "✅ Lint passed after auto-fix" | ||
| echo "fixes_successful=true" >> $GITHUB_ENV | ||
| else | ||
| echo "❌ Lint still failing after auto-fix" | ||
| echo "fixes_successful=false" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| - name: 🚘 Auto commit style fixes | ||
| if: env.needs_fixing == 'true' && env.fixes_successful == 'true' && env.changes_made == 'true' && github.event.pull_request != null && github.actor != 'dependabot[bot]' | ||
| uses: ./.github/actions/auto-commit | ||
| with: | ||
| branch-name: "${{ github.head_ref }}-codestyle-fixes" | ||
| commit-message: "style: auto-fix codestyle issues" | ||
| commit-files: "." | ||
| auto-merge-app-id: ${{ vars.AUTO_MERGE_APP_ID }} | ||
| auto-merge-private-key: ${{ secrets.AUTO_MERGE_PRIVATE_KEY }} | ||
| gh-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: ❌ Fail if lint issues remain unfixable | ||
| if: env.needs_fixing == 'true' && env.fixes_successful == 'false' | ||
| run: | | ||
| echo "❌ Lint issues remain after auto-fix attempt." | ||
| echo "These may be structural issues that require manual intervention." | ||
| echo "Please review the lint output and fix remaining issues manually." | ||
| exit 1 | ||
|
|
||
| - name: ℹ️ Report self-healing results | ||
| if: env.needs_fixing == 'true' | ||
| run: | | ||
| if [[ "${{ env.fixes_successful }}" == "true" ]]; then | ||
| if [[ "${{ env.changes_made }}" == "true" ]]; then | ||
| if [[ "${{ github.event.pull_request }}" != "null" && "${{ github.actor }}" != "dependabot[bot]" ]]; then | ||
| echo "🎉 Self-healing successful! Codestyle issues have been auto-fixed and committed." | ||
| else | ||
| echo "✅ Codestyle issues were auto-fixed but not committed (main branch or dependabot)." | ||
| echo "Please commit the changes manually." | ||
| fi | ||
| else | ||
| echo "✅ Lint passed after running formatters, but no file changes were needed." | ||
| fi | ||
| fi | ||
|
|
||
| - name: 💀 Killing me softly | ||
| uses: ./.github/actions/cancel-workflow | ||
| if: failure() | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don’t need
pull-requests: writehere because the job doesn't modifiy PR metadata.