chore: introduce black for code format in github actions#47
chore: introduce black for code format in github actions#47imbajin merged 8 commits intoapache:mainfrom
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.
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.
Right, I'll check that later~
There was a problem hiding this comment.
@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.
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 & bashas 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.
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 & bashasmain/.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.
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.
Note: next time we should enhance the filename black.yml (which is not clear enough)
|
|
||
| on: | ||
| push: | ||
| branches: |
There was a problem hiding this comment.
and shall we add main branch here?





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
