dosubot[bot] commented on issue #46:
URL:
https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2154364039
<!-- Answer -->
@ChenZiHong-Gavin, integrating BLACK into your CI workflow while adhering to
Apache's action rules can be challenging. Here is an example of how BLACK is
integrated within the constraints of Apache's action rules:
```yaml
name: "Black Code Formatter"
on:
push:
branches:
- 'release-*'
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@3702ba224ecffbcec30af640c149f231d90aebdb
with:
options: "--check --diff --line-length 100"
src: "hugegraph-llm/src hugegraph-python-client/src"
```
Additionally, the `incubator-hugegraph-ai` repository includes a script for
running BLACK and PYLINT checks:
```sh
#! /bin/bash
BLACK=false
PYLINT=false
ROOT_DIR=$(pwd)
echo ${ROOT_DIR}
# Parse command line arguments
while getopts ":bp" opt; do
case ${opt} in
b )
BLACK=true
;;
p )
PYLINT=true
;;
\? )
echo "Usage: cmd [-b] [-p]"
;;
esac
done
# If no arguments were provided, run both BLACK and PYLINT
if [ "$BLACK" = false ] && [ "$PYLINT" = false ]; then
BLACK=true
PYLINT=true
fi
# Run BLACK if -b is specified
if [ "$BLACK" = true ] ; then
echo "[black] Start to check code style and auto format"
black --line-length=100 ${ROOT_DIR}
fi
# Run PYLINT if -p is specified
if [ "$PYLINT" = true ] ; then
echo "[pylint] Start code analysis and check,
we need to manually fix all the warnings mentioned below before commit! "
export
PYTHONPATH=${ROOT_DIR}/hugegraph-llm/src:${ROOT_DIR}/hugegraph-python-client/src
pylint --rcfile=${ROOT_DIR}/style/pylint.conf ${ROOT_DIR}/hugegraph-llm
pylint --rcfile=${ROOT_DIR}/style/pylint.conf --disable C0103
${ROOT_DIR}/hugegraph-python-client
fi
```
This script allows for flexible integration of BLACK and PYLINT checks,
either individually or together, based on command-line arguments
<sup>[[1]](https://github.com/apache/incubator-hugegraph-ai/blob/main/.github/workflows/black.yml)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph-ai/blob/main/style/code_format_and_analysis.sh)</sup>.
If you need further assistance or have more questions, feel free to ask.
Happy coding!
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]