Repository navigation
Add cargo fmt --all and commit to github action #6204
Description
Activity
@youknowone i have doubt , as cargo fmt --all formats the code then are we going to make an commit from CI ?
or we can use cargo fmt --all --check ?
- added a commit that references this issue
on Oct 24, 2025 @YashSuthar983 Make a commit from CI. We already have
cargo fmt --check, and the solution is usually runningcargo fmt --alland commit the changes. It can be trivially autumated.Reacted by Yash SutharSo what i am thinking is that whenever user open a PR from fork , our CI run cargo fmt --all then if any changes this wil commit to pr of user right?
I don't think it is allowed by github or we need somthing like bot that use PAT of user for this.I didn't try that yet, but some github actions look like supporting it.
- https://github.com/marketplace/actions/add-commit
- https://github.com/marketplace/actions/git-auto-commit
- https://github.com/marketplace/actions/add-commit-and-push
Not sure which one is best fit for this purpose though.
I can configure some variables on actions if it is required.
Reacted by Yash Suthar@youknowone We can do one thing, whenever a user pushes to their fork, the CI pipeline run cargo fmt --all and if any formatting changes are needed, it should commit in their fork itself.
i tested this in repo. see pull request
if this satisfy need let me know ?@youknowone I’d like to know your thoughts on the solution, as it’s a hassle to remind everyone to run cargo fmt --all each time.
@YashSuthar983 I checked the repository and it is looking great! Could you apply the same workflow to RustPython too?
@youknowone i got confused as we can do two thing to be efficient and avoid conflicts .
- we run auto format at the end of all workflow .
- we make separate workflow that you can trigger.
I expected auto-format before all other workflow, but auto-format at end of workflow also sounds reasonable.
manual triggering is not a desired one. (better than no auto-format though)
Reacted by Yash Suthar@YashSuthar983 Thank you so much! it looks working great now
I tried another way on #6295 . Tested on #6296 and RustPython-test#1
As you shared, permission mattered. I'd better to try PAT earlier.
Let's see if it works.Thanks @YashSuthar983 and @ShaharNaveh
Closed by #6295
Thanks to @YashSuthar983, we now have auto-format after workflows.
I'd like to check if auto-formatting before workflows is possible
Summary
This is not a necessary task to be asked to human contributors.
If CI can automatically run it, we can rely on it.
Details