Skip to content

Conversation

Artur-
Copy link
Member

@Artur- Artur- commented Oct 7, 2025

Merges the separate formatter workflow into the validation workflow with
automatic commit and push capabilities for formatting changes.

Changes:

  • Deleted standalone .github/workflows/formatter.yml
  • Integrated formatter as first job in validation.yml workflow
  • Added auto-commit functionality using PAT token (VAADIN_BOT_TOKEN)
  • Formatter now commits and pushes changes when formatting issues detected
  • Workflow stops after committing, new workflow run is triggered by the commit
  • On second run, detects bot commit and skips formatting, proceeds to validation
  • Changed workflow permissions to include contents:write for pushing commits
  • Build and test jobs only run if formatter succeeds (no changes or after bot commit)

Infinite loop prevention:

  • Checks if last commit author is github-actions[bot]
  • If true, skips formatting step and proceeds to validation
  • Prevents endless formatting cycles if formatter is inconsistent

Token requirements:

  • Requires VAADIN_BOT_TOKEN secret with repo and workflow permissions
  • Workflow fails immediately if token is not configured
  • PAT needed because GITHUB_TOKEN cannot trigger workflow runs

PR comment behavior:

  • Posts comment when formatting changes are auto-committed
  • Deletes comment when formatting is correct
  • Includes list of files that were modified

@Artur- Artur- force-pushed the flow-spotless-update branch 2 times, most recently from 58cd01c to 52aec19 Compare October 7, 2025 13:06
Copy link

github-actions bot commented Oct 7, 2025

Test Results

1 270 files  +  4  1 270 suites  +4   1h 14m 46s ⏱️ + 1m 26s
8 768 tests +117  8 701 ✅ +116  67 💤 +2  0 ❌  - 1 
9 221 runs  +145  9 144 ✅ +145  77 💤 +1  0 ❌  - 1 

Results for commit 26592ca. ± Comparison against base commit 6aadc0c.

♻️ This comment has been updated with latest results.

@Artur- Artur- force-pushed the flow-spotless-update branch from b217255 to 347f208 Compare October 8, 2025 06:44
@vaadin-bot vaadin-bot added +1.0.0 and removed +0.0.1 labels Oct 8, 2025
@Artur- Artur- force-pushed the flow-spotless-update branch from a1b95ee to 347f208 Compare October 8, 2025 09:32
Merges the separate formatter workflow into the validation workflow with
automatic commit and push capabilities for formatting changes.

Changes:
- Deleted standalone .github/workflows/formatter.yml
- Integrated formatter as first job in validation.yml workflow
- Added auto-commit functionality using PAT token (VAADIN_BOT_TOKEN)
- Formatter now commits and pushes changes when formatting issues detected
- Workflow stops after committing, new workflow run is triggered by the commit
- On second run, detects bot commit and skips formatting, proceeds to validation
- Changed workflow permissions to include contents:write for pushing commits
- Build and test jobs only run if formatter succeeds (no changes or after bot commit)

Infinite loop prevention:
- Checks if last commit author is github-actions[bot]
- If true, skips formatting step and proceeds to validation
- Prevents endless formatting cycles if formatter is inconsistent

Token requirements:
- Requires VAADIN_BOT_TOKEN secret with repo and workflow permissions
- Workflow fails immediately if token is not configured
- PAT needed because GITHUB_TOKEN cannot trigger workflow runs

PR comment behavior:
- Posts comment when formatting changes are auto-committed
- Deletes comment when formatting is correct
- Includes list of files that were modified

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@Artur- Artur- force-pushed the flow-spotless-update branch from ff69418 to 37e8c75 Compare October 8, 2025 09:38
@Artur- Artur- changed the title feat: add auto-commit formatter workflow with loop prevention feat: auto-commit code formatting changes in CI workflow Oct 8, 2025
@Artur- Artur- requested review from ZheSun88 and mshabarov October 8, 2025 09:39
@Artur- Artur- marked this pull request as ready for review October 8, 2025 09:39
@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Oct 8, 2025
Copy link

sonarqubecloud bot commented Oct 8, 2025

@platosha
Copy link
Contributor

Just a question: do I understand correctly, that this change makes validation workflow unusable for external contributor PRs, since the bot cannot push to respective branches? If so, would it make sense to introduce a fallback to just checking formatting in the absence of push access?

@Artur-
Copy link
Member Author

Artur- commented Oct 10, 2025

Most often contributors tend to check the checkbox that maintainers can make updates. Does this mean that formatting will also work? I have not tried

@platosha platosha changed the title feat: auto-commit code formatting changes in CI workflow build: merge code formatter CI workflow with the validation build, test only after formatter succeeds Oct 13, 2025
build:
formatter:
needs: check-permissions
if: github.event_name == 'pull_request_target'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, this condition needs to removed or adjusted. I tried dispatching this workflow from the PR branch manually using the dispatch button, here's what happened:

  • it skipped the formatter job because it was not the pull_request_target event,
  • then it skipped the build job probably because formatter is required,
  • then it skipped the testing jobs also,
  • ...and then it reported a false positive, oh no!

See: https://github.com/vaadin/flow/actions/runs/18466985120

Keeping the manual dispatch function working is useful for enabling maintainers to verify workflow changes from PR branches. Let's not limit the supported triggers. If auto-commit from the formatter isn't appropriate, it could fallback to checking only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants