Skip to content

Commit

Permalink
Add seperate style and typing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Aug 14, 2024
1 parent e17584b commit ce97ec5
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
PYTHON: '3.8'

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@master
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/res2df.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install res2df with dependencies
run: |
pip install --upgrade pip
pip install ".[tests,docs,types]"
pip install ".[tests, docs]"
- name: Install numpy<2 if pandas<2
if: matrix.pandas-version == 'pandas<2'
Expand All @@ -58,13 +58,6 @@ jobs:
if: matrix.install-ert
run: pip install ".[ert]"

- name: Check code style and typing
run: |
black --check res2df tests setup.py docs/conf.py
flake8 res2df tests
isort --check-only --profile black res2df tests
mypy res2df
- name: List all installed packages
run: pip freeze

Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Style

on:
push:
branches:
- master
- 'version-**'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
check-style:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
setup.py
pyproject.toml
- name: Install res2df with style dependencies
run: |
pip install ".[style]"
- name: Run style check
if: ${{ always() }}
run: |
SKIP=no-commit-to-branch pre-commit run --all-files --show-diff-on-failure
42 changes: 42 additions & 0 deletions .github/workflows/typing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Typing

on:
push:
branches:
- master
- 'version-**'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
check-style:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
setup.py
pyproject.toml
- name: Install res2df with types dependencies
run: |
pip install ".[types]"
- name: Run mypy
run: |
mypy res2df
28 changes: 7 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v4.6.0
hooks:
- id: no-commit-to-branch
args: ['--branch', 'master']
Expand All @@ -12,23 +12,9 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/ambv/black
rev: 20.8b1
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.9.2
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy

- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort
name: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
23 changes: 0 additions & 23 deletions .pylintrc

This file was deleted.

3 changes: 0 additions & 3 deletions bandit.yml

This file was deleted.

3 changes: 3 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ ignore = ["PLW2901", # redefined-loop-name
"PLW3201", # bad-dunder-method-name
]

[lint.extend-per-file-ignores]
"res2df/__init__.py" = ["PLC0414"]

[lint.pylint]
max-args = 20
7 changes: 0 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ universal = 1
[aliases]
test=pytest

[flake8]
max-line-length = 88
exclude = docs, res2df/__init__.py

[tool:pytest]
markers =
integration: marks a test as an integration test
Expand All @@ -21,6 +17,3 @@ warning-is-error = 1
ignore_directives=argparse,automodule
# This looks like a bug in rstcheck:
ignore_messages=Hyperlink target .* is not referenced

[isort]
profile=black
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
]
EXTRAS_REQUIRE = {
"tests": TEST_REQUIREMENTS,
"style": ["pre-commit"],
"types": TYPES_REQUIREMENTS,
"docs": DOCS_REQUIREMENTS,
"ert": ["ert>=2.38.0-b5"],
Expand Down
5 changes: 0 additions & 5 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
black
flake8
isort
mypy
networkx
pre-commit
pytest
pytest-cov
pytest-mock
1 change: 1 addition & 0 deletions types_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mypy
types-PyYAML
types-python-dateutil
types-setuptools

0 comments on commit ce97ec5

Please sign in to comment.