Skip to content

try this

try this #3

Workflow file for this run

name: Pylint Loads
on: [push, pull_request]
jobs:
formatting-and-linting:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Run Pylint on mhkit/loads/ and check score
run: |
# Run pylint and capture the output
pylint_output=$(pylint mhkit/loads/ --output-format=text || true)
echo "$pylint_output"
# Extract the score from the output, handling cases where score is not found
score=$(echo "$pylint_output" | grep "Your code has been rated at" | awk '{print $7}' | sed 's/\/10//' || echo "0")
echo "Pylint score: $score"
# Define the minimum acceptable score
min_score=8.0
# Check if score is a number, exit with code 1 (failure) if not
python -c "import sys; score='$score'; sys.exit(0 if score.replace('.', '', 1).isdigit() else 1)"
# Compare the score with the minimum acceptable score, exit with code 1 if below threshold
python -c "import sys; sys.exit(0 if float('$score') >= $min_score else 1)"