Update .gitattributes #45
Workflow file for this run
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: Pylint | |
on: | |
push: | |
paths: | |
- '**.py' | |
- 'RequirementsFiles/**' | |
- '.github/workflows/pylint.yml' | |
- 'LaunchFile/**' | |
pull_request: | |
paths: | |
- '**.py' | |
- 'RequirementsFiles/**' | |
- '.github/workflows/pylint.yml' | |
- 'LaunchFile/**' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
cache-dependency-path: | | |
RequirementsFiles/requirements.txt | |
RequirementsFiles/requirements-CPU.txt | |
RequirementsFiles/requirements-cuda.txt | |
RequirementsFiles/requirements-cuda-CPU.txt | |
RequirementsFiles/requirements-llama-cpp.txt | |
RequirementsFiles/requirements-llama-cpp-CPU.txt | |
RequirementsFiles/requirements-stable-diffusion-cpp.txt | |
RequirementsFiles/requirements-stable-diffusion-cpp-CPU.txt | |
- name: Create virtual environment | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
- name: Install base dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install pylint black flake8 mypy | |
- name: Install project dependencies | |
run: | | |
# Installing main requirements (CPU version for CI) | |
pip install --no-deps -r RequirementsFiles/requirements-CPU.txt | |
pip install --no-deps -r RequirementsFiles/requirements-cuda-CPU.txt | |
pip install --no-deps -r RequirementsFiles/requirements-llama-cpp-CPU.txt | |
pip install --no-deps -r RequirementsFiles/requirements-stable-diffusion-cpp-CPU.txt | |
continue-on-error: true | |
- name: Create .pylintrc | |
run: | | |
cat > .pylintrc << EOF | |
[MASTER] | |
ignore=venv | |
persistent=yes | |
[MESSAGES CONTROL] | |
disable=\ | |
C0111, # missing-docstring | |
C0103, # invalid-name | |
C0301, # line-too-long | |
C0114, # missing-module-docstring | |
C0115, # missing-class-docstring | |
C0116, # missing-function-docstring | |
R0913, # too-many-arguments | |
R0914, # too-many-locals | |
W0611, # unused-import | |
W0401, # wildcard-import | |
W0614, # unused-wildcard-import | |
W0703, # broad-except | |
E1101, # no-member (often false-positives) | |
[FORMAT] | |
max-line-length=120 | |
[BASIC] | |
good-names=i,j,k,ex,Run,_,fp,id | |
[MISCELLANEOUS] | |
notes=FIXME,XXX,TODO | |
[SIMILARITIES] | |
min-similarity-lines=4 | |
ignore-comments=yes | |
ignore-docstrings=yes | |
ignore-imports=yes | |
EOF | |
- name: Run black check | |
run: | | |
black --check --diff LaunchFile/ | |
continue-on-error: true | |
- name: Run pylint | |
run: | | |
mkdir -p ./reports | |
pylint LaunchFile/ --output-format=json > ./reports/pylint-report.json || true | |
pylint LaunchFile/ --output-format=text > ./reports/pylint-report.txt || true | |
continue-on-error: true | |
- name: Run flake8 | |
run: | | |
flake8 LaunchFile/ --max-line-length=120 --statistics --tee --output-file=./reports/flake8-report.txt || true | |
continue-on-error: true | |
- name: Check pylint score | |
run: | | |
SCORE=$(tail -n 2 ./reports/pylint-report.txt | grep -oP "(?<=rated at )[0-9.]+") | |
echo "Pylint score: $SCORE/10" | |
if (( $(echo "$SCORE < 7.0" | bc -l) )); then | |
echo "Warning: Pylint score is below 7.0" | |
exit 1 | |
fi | |
- name: Run MyPy | |
run: | | |
source venv/bin/activate | |
mypy LaunchFile/ | |
continue-on-error: true | |
- name: Run tests | |
run: | | |
source venv/bin/activate | |
python -m unittest discover -s tests || true | |
continue-on-error: true | |
- name: Upload lint results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: lint-reports | |
path: | | |
./reports/pylint-report.json | |
./reports/pylint-report.txt | |
./reports/flake8-report.txt | |
retention-days: 14 | |
- name: Comment PR with lint results | |
if: github.event_name == 'pull_request' && always() | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const pylintReport = fs.readFileSync('./reports/pylint-report.txt', 'utf8'); | |
const score = pylintReport.match(/rated at ([0-9.]+)/); | |
const scoreValue = score ? score[1] : 'N/A'; | |
const body = `## Lint Results | |
### Pylint Score: ${scoreValue}/10 | |
<details> | |
<summary>Detailed Report</summary> | |
\`\`\` | |
${pylintReport} | |
\`\`\` | |
</details>`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}); |