-
Notifications
You must be signed in to change notification settings - Fork 29
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
chore: introduce black for code format in github actions #47
Conversation
.github/workflows/black.yml
Outdated
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: psf/black@stable |
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.
Come to think of it, ASF/Apache seems to have some rules about external action, and those don't meet the requirements may be banned 🚫 (I found ↓)
https://infra.apache.org/github-actions-policy.html
(maybe we could search some apache's python project that use the same action/step?)
Perhaps this is also the reason why we didn't see Black in our PR CI? (But it works fine in ur personal repo ↓)
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.
Right, I'll check that later~
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.
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.
@liuxiaocs7 @simon824 any suggestion?
(I forgot in which ASF project I saw a way to indirectly reference an action, partially bypassing this restriction)
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 have 2 approaches:
- follow the rules and use the specific git hash (SHA1) of the action, for example
psf/black@3702ba224ecffbcec30af640c149f231d90aebdb
- use
pip install & bash
as https://github.com/apache/incubator-hugegraph-ai/blob/main/.github/workflows/pylint.yml did
I prefer approach 1.
Also, i found a ASF repo which may not obey the restriction but still confused how they did it.
In https://github.com/apache/shenyu/blob/master/.github/workflows/e2e-k8s.yml
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 have 2 approaches:
- follow the rules and use the specific git hash (SHA1) of the action, for example
psf/black@3702ba224ecffbcec30af640c149f231d90aebdb
- use
pip install & bash
asmain
/.github/workflows/pylint.yml didI prefer approach 1.
Also, i found a ASF repo which may not obey the restriction but still confused how they did it. In apache/shenyu@
master
/.github/workflows/e2e-k8s.yml
Thanks for ur feedback~
U could try way1 first (This seems to be a new rule added this year, at least I didn't see it last year)
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.
Merge it first & test it?
(Also I noticed GitHub Action doesn't support short hash value like 3702ba2
for now :)
Update:
Also failed in the latest CI/code (maybe we could submit a ticket in ASF-JIRA for the reason, you need register it first)
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.
Note: next time we should enhance the filename black.yml
(which is not clear enough)
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.
ok
|
||
on: | ||
push: | ||
branches: |
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.
and shall we add main
branch here?
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.
ok
According to #46, I think black for code format can be supported by black integration with github actions(black.readthedocs.io/en/stable/integrations/github_actions.html).
the workflow fails if Black finds files that need to be formatted, as can be seen in ChenZiHong-Gavin#17
so i think everyone should run black in ./style/code_format_and_analysis.sh before commit. (Perhaps it would be better to automatically trigger [the process] through GitHub Hooks rather than running it manually.)
after that, Black passes the workflow, as can be seen in ChenZiHong-Gavin#18