-
Notifications
You must be signed in to change notification settings - Fork 922
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
Proper message display when no bash, python and YAML files changed in the PR #2803
Merged
google-oss-prow
merged 13 commits into
kubeflow:master
from
hansinikarunarathne:fix_requested_changes_in_linting
Jul 22, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
009df56
Proper message display when no bash files chnaged in the PR
hansinikarunarathne ad63bac
Proper message display when no Yaml files chnaged in the PR
hansinikarunarathne 1d28ed8
Proper message display when no Yaml files chnaged and styled in the PR
hansinikarunarathne 6de525d
Proper message display when no need to do style in Yaml files
hansinikarunarathne 6914368
Check the linting working by changing a yaml file
hansinikarunarathne b409d24
Testing working of Bash linting
hansinikarunarathne 1d11620
Make some fix in formatting bash files
hansinikarunarathne c234d37
checking functionalities of linting
hansinikarunarathne 534793e
Combined Yaml,Bash and Python formatting yaml files into one workflow
hansinikarunarathne b2ce5f4
Deleted seperate files
hansinikarunarathne 60be547
Check the linting working by changing a yaml file
hansinikarunarathne 30a91c6
Testing working of Bash linting
hansinikarunarathne 480b0ef
fix the mistake of changing unwanted file
hansinikarunarathne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
name: Proper linting on Bash, Python, and YAML 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 error 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 | ||
|
||
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 | ||
id: changed_files | ||
run: | | ||
git diff --name-only origin/master...HEAD | grep -E '^common/.*\.ya?ml$|^example/.*\.ya?ml$' > changed_files_in_PR.txt || true | ||
if [ ! -s changed_files_in_PR.txt ]; then | ||
echo "No YAML files have changed in this PR." > changed_files_in_PR.txt | ||
fi | ||
|
||
- name: Display changed files | ||
run: cat changed_files_in_PR.txt | ||
|
||
- name: Run yamllint on changed files | ||
id: lint | ||
run: | | ||
if grep -q 'No YAML files have changed in this PR.' changed_files_in_PR.txt; then | ||
echo "No YAML files have changed in this PR." | ||
else | ||
cat changed_files_in_PR.txt | xargs -I {} yamllint {} || exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Check YAML lint results | ||
if: success() && steps.lint.outcome == 'success' | ||
run: echo "No styling issues with YAML files." | ||
shell: bash | ||
|
||
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 the error code definitions at https://www.shellcheck.net/wiki/. | ||
You can correct them using the https://www.shellcheck.net/ site. | ||
You have to ignore disable errors in the .shellcheckrc file. | ||
" | ||
|
||
- name: Fetch master branch | ||
run: git fetch origin master | ||
|
||
- name: Set up changed files | ||
id: changed_files | ||
run: | | ||
git diff --name-only origin/master...HEAD | grep -E '^.*\.sh$' | grep -v '^apps/' > changed_files_in_PR.txt || true | ||
if [ ! -s changed_files_in_PR.txt ]; then | ||
echo "No bash files have changed in this PR." | ||
fi | ||
|
||
- name: Display changed files | ||
if: always() # Always run this step | ||
run: cat changed_files_in_PR.txt || echo "No bash files have changed in this PR." | ||
|
||
- name: Run ShellCheck on changed files | ||
id: lint | ||
run: | | ||
if grep -q 'No bash files have changed in this PR.' changed_files_in_PR.txt; then | ||
echo "No bash files have changed in this PR." | ||
else | ||
cat changed_files_in_PR.txt | xargs -I {} shellcheck {} || exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Check Bash lint results | ||
if: success() && steps.lint.outcome == 'success' | ||
run: echo "No styling issues with Bash files." | ||
shell: bash |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Why are you changing this file?
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.
The difference is showed in the same line. But I did not change it.