dialoggpt model creation #103
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
name: Pull Request Checks | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Pull Request Checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v45.0.1 | |
with: | |
separator: "," | |
- name: Get markdown files | |
id: changed_md_files | |
uses: tj-actions/changed-files@v45.0.1 | |
with: | |
files: | | |
**.md | |
separator: "," | |
- name: Print the changed and markdown files | |
run: | | |
echo Changed files: ${{ steps.changed_files.outputs.all_changed_files }} | |
echo Markdown files: ${{ steps.changed_md_files.outputs.all_changed_files }} | |
- name: Create log files | |
run: | | |
touch error_log.txt | |
touch pass_log.txt | |
touch flake8_log.txt | |
touch pylint_log.txt | |
- name: Check for naming conventions | |
run: | | |
all_files=$(echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr "," "\n") | |
while IFS= read -r file; do | |
if echo "$file" | grep -q " "; then | |
echo "The file or path $file contains spaces, please rename the path or file without spaces, using underscore ('_') instead." >> error_log.txt | |
fi | |
IFS='/' read -r -a fname_array <<< "$file"; | |
path="${fname_array[@]::${#fname_array[@]}-1}"; | |
if echo "${path}" | grep -qE '[A-Z]'; then | |
echo "The path '$file' contains capital letters. Please write file paths in lower case." >> error_log.txt | |
fi | |
done <<< "$all_files" | |
echo "Folders and files are correctly named!" >> pass_log.txt | |
- name: Check for markdown file naming conventions | |
run: | | |
md_files=$(echo "${{ steps.changed_md_files.outputs.all_changed_files }}" | tr "," "\n") | |
if [ -n "$md_files" ]; then | |
while IFS= read -r file; do | |
md_fname=$(echo "$file" | tr "/" "\n" | grep "md" || true) # Ensure grep doesn't exit | |
if echo $md_fname | grep -qE "^[^A-Z]+.md"; then | |
echo "The markdown file $md_fname at path $file is not in all caps. Please write markdown file names using all caps." >> error_log.txt | |
fi | |
done <<< "$md_files" | |
echo "All markdown files are correctly named!" >> pass_log.txt | |
else | |
echo "There are no markdown files to check." >> pass_log.txt | |
fi | |
- name: Check for PDF and Word files | |
run: | | |
echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr "," "\n" | if grep -q -e ".docx" -e ".pdf"; then | |
echo "This PR contains PDF or word (.docx) files, please remove them and try again." >> error_log.txt | |
else | |
echo "This PR does not contain PDF or word (.docx) files." >> pass_log.txt | |
fi | |
- name: Setup Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install check dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install nbqa flake8 pylint bandit nbformat | |
- name: Execute linting check on Python files | |
run: | | |
py_files=$(echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr "," "\n" | grep ".py$" || true) | |
if [ -n "$py_files" ]; then | |
for file in $py_files; do | |
flake8 --config=ci_build/flake8 "$file" >> flake8_log.txt || true | |
pylint "$file" --rcfile=ci_build/pylintrc >> pylint_log.txt || true | |
done | |
else | |
echo "No Python files to lint and check." | |
fi | |
- name: Execute linting check on Jupyter Notebooks | |
run: | | |
nb_files=$(echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr "," "\n" | grep ".ipynb$" || true) | |
if [ -n "$nb_files" ]; then | |
for file in $nb_files; do | |
nbqa flake8 --config=ci_build/flake8 "$file" >> flake8_log.txt || true | |
nbqa pylint "$file" --rcfile=ci_build/pylintrc >> pylint_log.txt || true | |
done | |
else | |
echo "No Jupyter Notebooks to lint." | |
fi | |
- name: Display name check logs and handle errors | |
run: | | |
echo -e "\n-----------------------------------------\nNaming Conventions Check File:" | |
cat error_log.txt | |
echo -e "\n-----------------------------------------\nFlake8 Linting Check File:" | |
cat flake8_log.txt | |
echo -e "\n-----------------------------------------\nPylint Linting Check File:" | |
cat pylint_log.txt | |
if [ -s error_log.txt ]; then | |
exit 1 | |
elif [ -s flake8_log.txt ]; then | |
exit 1 | |
elif [ -s pylint_log.txt ]; then | |
exit 1 | |
else | |
cat pass_log.txt | |
echo "No naming errors found!" | |
fi |