mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
name: Python Linting
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-python@v7
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install ruff
|
|
run: pip install "ruff==0.15.*"
|
|
|
|
# Always run strict lint check (catches all errors including unfixable ones)
|
|
- name: (Python) Check with ruff
|
|
run: |
|
|
cd GrpcInterface
|
|
ruff check .
|
|
ruff format --check --diff .
|
|
|
|
# Same-repo PRs and pushes: Apply auto-fixable issues and create PR if needed
|
|
- name: (Python) Auto-fix and create PR
|
|
if: failure() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
|
|
run: |
|
|
cd GrpcInterface
|
|
ruff check --fix .
|
|
ruff format .
|
|
- uses: peter-evans/create-pull-request@v8
|
|
if: failure() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
commit-message: "Python code linting changes detected by ruff"
|
|
title: "Fixes by ruff (Python)"
|
|
branch: python-ruff-patches
|
|
branch-suffix: random
|
|
base: ${{ github.head_ref }}
|
|
|