Skip to content
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

Introduce proper formatting on python ,bash and yaml files #2774

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
590a0ee
Add balck github action to format python files
hansinikarunarathne Jun 28, 2024
c929ea6
Formatted python files from the balck formatter
hansinikarunarathne Jun 28, 2024
335393e
Add github action to format yaml files
hansinikarunarathne Jun 29, 2024
0388a29
Add step YAML Formatting Guidelines to yaml_formatter.yaml file
hansinikarunarathne Jun 29, 2024
afbe930
made chnages to run next steps although the previous step fail
hansinikarunarathne Jun 29, 2024
2c4db16
switch steps
hansinikarunarathne Jun 29, 2024
fc0e758
added shellCheck for bash formatting
hansinikarunarathne Jun 29, 2024
43d95b8
Changed code only to lint yaml files inside the common and example fo…
hansinikarunarathne Jul 1, 2024
eb483c8
Changed main to master
hansinikarunarathne Jul 1, 2024
5f6e20a
Run yamllint on files which is chnaged in PR only
hansinikarunarathne Jul 1, 2024
18081cb
Changed 'Proper formatting on python files' github workflow only to r…
hansinikarunarathne Jul 1, 2024
b132ba1
Add shellcheckrc file
hansinikarunarathne Jul 1, 2024
672abc4
Disable SC1017,SC2086,SC2070 rules when shellcheck and did changes in…
hansinikarunarathne Jul 1, 2024
db19666
made chnages in sh files
hansinikarunarathne Jul 1, 2024
38a57d5
made chnages in sh files to address formattings
hansinikarunarathne Jul 1, 2024
58ee8cd
made chnages in sh files
hansinikarunarathne Jul 1, 2024
399e0a3
disable SC2046 rule
hansinikarunarathne Jul 1, 2024
3c4c985
disable SC2006 and SC2155 rule
hansinikarunarathne Jul 1, 2024
35b242f
Change shellcheck only to run for PR chnaged files
hansinikarunarathne Jul 1, 2024
bc5fd0b
Address a issue with bash_formatter.yaml
hansinikarunarathne Jul 1, 2024
cb67c39
Changed origin/main to origin/master
hansinikarunarathne Jul 1, 2024
77e2c25
Formatted python files from the balck formatter
hansinikarunarathne Jun 28, 2024
8f252bb
Add github action to format yaml files
hansinikarunarathne Jun 29, 2024
045b504
Add step YAML Formatting Guidelines to yaml_formatter.yaml file
hansinikarunarathne Jun 29, 2024
19881d4
made chnages to run next steps although the previous step fail
hansinikarunarathne Jun 29, 2024
04e1858
switch steps
hansinikarunarathne Jun 29, 2024
8ee988d
Add shellcheckrc file
hansinikarunarathne Jul 1, 2024
0f27d46
Disable SC1017,SC2086,SC2070 rules when shellcheck and did changes in…
hansinikarunarathne Jul 1, 2024
5e5e4c4
made chnages in sh files
hansinikarunarathne Jul 1, 2024
859ced5
Change shellcheck only to run for PR chnaged files
hansinikarunarathne Jul 1, 2024
107db8e
Ensure the full history is fetched
hansinikarunarathne Jul 1, 2024
64bd2d9
Ensure the full history is fetched in bash_formatter
hansinikarunarathne Jul 1, 2024
0226a0e
fix SC2148 (error)
hansinikarunarathne Jul 1, 2024
a4bc63f
remove commented lines in bash_formatter.yaml
hansinikarunarathne Jul 7, 2024
2730efc
remove formatting chnages done to app folder content
hansinikarunarathne Jul 7, 2024
5e7dfb5
Add guidlines to how to format python files according to black formatter
hansinikarunarathne Jul 7, 2024
9ae743f
Add guidlines to how to format bash files according to shellcheck for…
hansinikarunarathne Jul 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/bash_formatter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Proper Formatting on bash files

on: [push, pull_request]

jobs:
format_bash_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install ShellCheck
run: sudo apt install -y shellcheck

- name: Bash Formatting Guidelines
run: |
echo "### Bash Files Formatting Guidelines ###
If there are errors and warnings regarding your bash files,
You can check that error code definitions in https://www.shellcheck.net/wiki/ site.
You can correct them using the https://www.shellcheck.net/ site.
You have to ignore disable errors in .shellcheckrc file.
"

- name: Fetch master branch
run: git fetch origin master

- name: Set up changed files
run: |
git diff --name-only origin/master...HEAD | grep -E '^.*\.sh$' | grep -v '^apps/' > changed_files_in_PR.txt || true

- name: Display changed files
run: cat changed_files_in_PR.txt

- name: Run ShellCheck on changed files
run: |
cat changed_files_in_PR.txt | xargs -I {} shellcheck {}
shell: bash


32 changes: 32 additions & 0 deletions .github/workflows/python_formatter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Proper Formatting on Python files

on: [push, pull_request]

jobs:
format_python_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Python Files Formatting Guidelines
run: |
echo "### Python Files Formatting Guidelines ###
If there is a formatting errors in your python files,
1. First install black
It requires Python 3.8+ to run.
Install with "pip install black" and if you use pipx, install Black with "pipx install black"
If you want to format Jupyter Notebooks, install with pip install "black[jupyter]"

2. Run the command
"python -m black {source_file_or_directory}" or
"black {source_file_or_directory}"
to format python files.
"

- uses: psf/black@stable
with:
src: |
./common
./example


59 changes: 59 additions & 0 deletions .github/workflows/yaml_formatter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Proper Formatting on YAML files

on: [push, pull_request]

jobs:
format_YAML_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install yamllint
run: pip install yamllint

- name: YAML Formatting Guidelines
run: |
echo "### YAML Formatting Guidelines ###
If there is a formatting error in your YAML file, you will see errors like the one below:
'Error: 6:4 [indentation] wrong indentation: expected 2 but found 3'

To fix these errors, refer to the YAML formatting rules at:
https://yamllint.readthedocs.io/en/stable/rules.html#

Search for the keyword inside the brackets [] in the error message. In this example, it's 'indentation'.

Note: Some rules have been customized in the '.yamllint.yaml' file. Below is the content of that file:

extends: default

rules:
document-start:
present: false
document-end:
present: false
indentation:
indent-sequences: false
line-length:
max: 400
"

- name: Fetch master branch
run: git fetch origin master

- name: Set up changed files
run: |
git diff --name-only origin/master...HEAD | grep -E '^common/.*\.ya?ml$|^example/.*\.ya?ml$' > changed_files_in_PR.txt || true

- name: Display changed files
run: cat changed_files_in_PR.txt

- name: Run yamllint on changed files
run: |
chmod +x ./run_yamllint.sh
./run_yamllint.sh
shell: bash



2 changes: 2 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ~/.shellcheckrc
disable=SC1017,SC2086,SC2070,SC2046,SC2155,SC2006
12 changes: 12 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# It extends the default conf by adjusting some options.
extends: default

rules:
document-start:
present: false
document-end:
present: false
indentation:
indent-sequences: false
line-length:
max: 400
4 changes: 3 additions & 1 deletion contrib/kserve/tests/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def test_sklearn_kserve():
spec=V1beta1InferenceServiceSpec(predictor=predictor),
)

kserve_client = KServeClient(config_file=os.environ.get("KUBECONFIG", "~/.kube/config"))
kserve_client = KServeClient(
config_file=os.environ.get("KUBECONFIG", "~/.kube/config")
)
kserve_client.create(isvc)
kserve_client.wait_isvc_ready(service_name, namespace=KSERVE_TEST_NAMESPACE)
res = predict(service_name, "./data/iris_input.json")
Expand Down
2 changes: 1 addition & 1 deletion hack/synchronize-istio-cni-manifests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@ -1,88 +0,0 @@
#!/usr/bin/env bash
@ -1,88 +0,0 @@

# This script aims at helping create a PR to update the manifests of the
# knative.
Expand Down
3 changes: 2 additions & 1 deletion hack/synchronize-istio-manifests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# #!/usr/bin/env bash
#!/usr/bin/env bash


# # This script aims at helping create a PR to update the manifests of Istio
# # This script:
Expand Down
8 changes: 4 additions & 4 deletions hack/synchronize-kserve-web-app-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You have uncommitted changes"
fi

if [ `git branch --list $BRANCH` ]
if [ "$(git branch --list $BRANCH)" ]
then
echo "WARNING: Branch $BRANCH already exists."
fi
Expand All @@ -39,11 +39,11 @@ echo "Checking out in $SRC_DIR to $COMMIT..."

# Checkout the Model Registry repository
mkdir -p $SRC_DIR
cd $SRC_DIR
cd $SRC_DIR || exit
if [ ! -d "models-web-app/.git" ]; then
git clone https://github.com/kserve/models-web-app.git
fi
cd $SRC_DIR/models-web-app
cd $SRC_DIR/models-web-app || exit
if ! git rev-parse --verify --quiet $COMMIT; then
git checkout -b $COMMIT
else
Expand Down Expand Up @@ -71,7 +71,7 @@ DST_TXT="\[$COMMIT\](https://github.com/kserve/models-web-app/tree/$COMMIT/confi
sed -i "s|$SRC_TXT|$DST_TXT|g" "${MANIFESTS_DIR}"/README.md

echo "Committing the changes..."
cd $MANIFESTS_DIR
cd $MANIFESTS_DIR || exit
git add contrib/kserve/models-web-app
git add README.md
git commit -s -m "Update kserve models web application manifests from ${COMMIT}"
Loading
Loading