Version/bump #191
Workflow file for this run
This file contains hidden or 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: Static code analysis 🔎 | |
| "on": | |
| # Run static code analysis on pull_request events | |
| pull_request: | |
| types: [opened, reopened, synchronize, ready_for_review] | |
| # Allow this workflow to be called by other workflows | |
| workflow_call: | |
| # Allow this workflow to be called manually (e.g. from the GitHub Actions UI) | |
| workflow_dispatch: | |
| jobs: | |
| pylint: | |
| name: Static code analysis 🔎 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: uv sync --extra dev | |
| - name: Run pylint analysis | |
| # Using repository pylint config (pyproject.toml) with comprehensive settings for scientific code | |
| run: | | |
| exit_code=0 | |
| uv run pylint --output-format=parseable --output=pylint-report.txt weac/ tests/ || exit_code=$? | |
| echo "Pylint finished with exit code $exit_code." | |
| echo | |
| echo "Pylint exit code meaning:" | |
| if [ $exit_code -eq 0 ]; then echo "-> No issues found"; fi | |
| if [ $((exit_code & 1)) -ne 0 ]; then echo "-> Fatal message issued"; fi | |
| if [ $((exit_code & 2)) -ne 0 ]; then echo "-> Error message issued"; fi | |
| if [ $((exit_code & 4)) -ne 0 ]; then echo "-> Warning message issued"; fi | |
| if [ $((exit_code & 8)) -ne 0 ]; then echo "-> Refactor message issued"; fi | |
| if [ $((exit_code & 16)) -ne 0 ]; then echo "-> Convention message issued"; fi | |
| if [ $((exit_code & 32)) -ne 0 ]; then echo "-> Usage error"; fi | |
| echo | |
| echo 'Error type counts:' | |
| grep -oP '[A-Z]\d+\([a-z\-]+\)' pylint-report.txt | sort | uniq -c | sort -nr | |
| echo | |
| echo 'Errors per file:' | |
| grep -oP '^[\w\-\/]+\.py' pylint-report.txt | sort | uniq -c | sort -nr | |
| echo | |
| echo 'Total errors:' | |
| grep -oP '^[\w\-\/]+\.py' pylint-report.txt | wc -l | |
| echo | |
| grep 'Your code' pylint-report.txt || true | |
| # Fail on fatal, error, and usage error. | |
| # These are severe and should block PRs. | |
| # Warnings (4), refactors (8), and conventions (16) will not cause a failure. | |
| fail_on_codes=$((1 | 2 | 32)) | |
| if [ $((exit_code & fail_on_codes)) -ne 0 ]; then | |
| echo "Failing CI due to fatal/error/usage messages from pylint." | |
| exit 1 | |
| else | |
| echo "Pylint check passed. No fatal/error/usage messages." | |
| fi |