Skip to content

Commit 10e848c

Browse files
authored
Fix pre-commit and QA configs (#262)
This commit updates the pre-commit hooks to use newer versions of the plugins and also fixes the configuration to be able to run in the current monorepo layout, where git hooks are still executed from the root of the repository. Main changes: - Update pre-commit hook versions and settings, adding paths relative to repo root - Add pre-commit and flake8 settings per model component folder - Add GitHub CI action versions - Add python caches to Github CI actions - Update formatting in yaml and toml files - Apply correct formatting to existing python files
1 parent f929579 commit 10e848c

File tree

99 files changed

+650
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+650
-862
lines changed

.github/workflows/icon4py-qa.yml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,51 @@ on:
2121
types: [submitted]
2222

2323
jobs:
24-
pre-commit:
24+
pre-commit-icon4py-model-common:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v3
2828
- name: Set up Python
29-
uses: actions/setup-python@v3
29+
uses: actions/setup-python@v4
3030
with:
3131
python-version: "3.10"
32-
- name: Install icon4py-atmosphere-dycore
33-
working-directory: model/atmosphere/dycore
32+
cache: 'pip'
33+
cache-dependency-path: |
34+
**/pyproject.toml
35+
**/base-requirements.txt
36+
**/base-requirements-dev.txt
37+
**/requirements.txt
38+
**/requirements-dev.txt
39+
- name: Install icon4py-common
40+
working-directory: model/common
3441
run: |
3542
python -m pip install --upgrade pip setuptools wheel
3643
python -m pip install -r ./requirements-dev.txt
44+
python -m pip list
45+
- name: Run checks icon4py-model-common
46+
run: |
47+
pre-commit run --config model/common/.pre-commit-config.yaml --all-files
3748
38-
- name: Install icon4py-common
39-
working-directory: model/common
49+
pre-commit-icon4py-model-atmosphere-dycore:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
- name: Set up Python
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: "3.10"
57+
cache: 'pip'
58+
cache-dependency-path: |
59+
**/pyproject.toml
60+
**/base-requirements.txt
61+
**/base-requirements-dev.txt
62+
**/requirements.txt
63+
**/requirements-dev.txt
64+
- name: Install icon4py-model-atmosphere-dycore
65+
working-directory: model/atmosphere/dycore
4066
run: |
4167
python -m pip install --upgrade pip setuptools wheel
4268
python -m pip install -r ./requirements-dev.txt
43-
- name: Run checks icon4py-model
69+
- name: Run checks icon4py-model-atmosphere-dycore
4470
run: |
45-
python -m pip list
46-
pre-commit run --config model/.pre-commit-config.yaml --all-files
71+
pre-commit run --config model/atmosphere/dycore/.pre-commit-config.yaml --all-files

.github/workflows/icon4py-tox.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,24 @@ jobs:
2727
python-version: ["3.10"]
2828

2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3131

3232
- name: Install boost
3333
run: |
3434
sudo apt-get update
3535
sudo apt-get install libboost-all-dev
3636
3737
- name: Set up Python ${{ matrix.python-version }}
38-
uses: actions/setup-python@v2
38+
uses: actions/setup-python@v4
3939
with:
4040
python-version: ${{ matrix.python-version }}
41+
cache: 'pip'
42+
cache-dependency-path: |
43+
**/pyproject.toml
44+
**/base-requirements.txt
45+
**/base-requirements-dev.txt
46+
**/requirements.txt
47+
**/requirements-dev.txt
4148
4249
- name: Install python dependencies
4350
run: |

.github/workflows/icon4pytools-qa.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,24 @@ jobs:
3030
pre-commit:
3131
runs-on: ubuntu-latest
3232
steps:
33-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v3
3434
- name: Set up Python
35-
uses: actions/setup-python@v3
35+
uses: actions/setup-python@v4
3636
with:
3737
python-version: "3.10"
38+
cache: 'pip'
39+
cache-dependency-path: |
40+
**/pyproject.toml
41+
**/base-requirements.txt
42+
**/base-requirements-dev.txt
43+
**/requirements.txt
44+
**/requirements-dev.txt
3845
- name: Install dependencies
3946
working-directory: tools
4047
run: |
4148
python -m pip install --upgrade pip setuptools wheel
4249
python -m pip install -r ./requirements-dev.txt
50+
python -m pip list
4351
- name: Run checks
4452
run: |
45-
python -m pip list
4653
pre-commit run --config tools/.pre-commit-config.yaml --all-files

.github/workflows/icon4pytools-tox.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,24 @@ jobs:
3434
python-version: ["3.10"]
3535

3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v3
3838

3939
- name: Install boost
4040
run: |
4141
sudo apt-get update
4242
sudo apt-get install libboost-all-dev
4343
4444
- name: Set up Python ${{ matrix.python-version }}
45-
uses: actions/setup-python@v2
45+
uses: actions/setup-python@v4
4646
with:
4747
python-version: ${{ matrix.python-version }}
48+
cache: 'pip'
49+
cache-dependency-path: |
50+
**/pyproject.toml
51+
**/base-requirements.txt
52+
**/base-requirements-dev.txt
53+
**/requirements.txt
54+
**/requirements-dev.txt
4855
4956
- name: Install python dependencies
5057
run: |

model/.pre-commit-config.yaml

Lines changed: 0 additions & 137 deletions
This file was deleted.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# NOTE: pre-commit runs all hooks from the root folder of the repository,
2+
# as regular git hooks do. Therefore, paths passed as arguments to the plugins
3+
# should always be relative to the root folder.
4+
5+
default_stages: [commit, push]
6+
default_language_version:
7+
python: python3.10
8+
minimum_pre_commit_version: 2.20.0
9+
files: "model/atmosphere/dycore/.*"
10+
11+
repos:
12+
- repo: meta
13+
hooks:
14+
- id: check-hooks-apply
15+
stages: [manual]
16+
- id: check-useless-excludes
17+
stages: [manual]
18+
19+
- repo: https://github.com/asottile/setup-cfg-fmt
20+
rev: v1.20.1
21+
hooks:
22+
# Run only manually because it deletes comments
23+
- id: setup-cfg-fmt
24+
name: format setup.cfg
25+
stages: [manual]
26+
27+
- repo: https://github.com/pre-commit/pre-commit-hooks
28+
rev: v4.3.0
29+
hooks:
30+
- id: check-case-conflict
31+
- id: check-merge-conflict
32+
- id: check-shebang-scripts-are-executable
33+
- id: check-symlinks
34+
- id: check-yaml
35+
- id: debug-statements
36+
- id: destroyed-symlinks
37+
38+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
39+
rev: v2.6.0
40+
hooks:
41+
- id: pretty-format-ini
42+
args: [--autofix]
43+
- id: pretty-format-toml
44+
args: [--autofix]
45+
- id: pretty-format-yaml
46+
args: [--autofix, --preserve-quotes, --indent, "2"]
47+
48+
- repo: https://github.com/pre-commit/mirrors-prettier
49+
rev: v3.0.0-alpha.4
50+
hooks:
51+
- id: prettier
52+
types_or: [markdown, json]
53+
54+
- repo: https://github.com/Lucas-C/pre-commit-hooks
55+
rev: v1.3.0
56+
hooks:
57+
- id: insert-license
58+
name: add license for all ICON4Py Python source files
59+
types: [python]
60+
args: [--comment-style, "|#|", --license-filepath, model/.license_header.txt, --fuzzy-match-generates-todo]
61+
62+
- repo: https://github.com/asottile/yesqa
63+
rev: v1.3.0
64+
hooks:
65+
- id: yesqa
66+
67+
- repo: https://github.com/psf/black
68+
rev: '22.3.0'
69+
hooks:
70+
- id: black
71+
name: black Python formatter
72+
args: [--config, model/atmosphere/dycore/pyproject.toml]
73+
74+
- repo: https://github.com/asottile/blacken-docs
75+
rev: v1.12.1
76+
hooks:
77+
- id: blacken-docs
78+
name: black Python formatter for docstrings
79+
additional_dependencies: [black==22.3.0]
80+
81+
- repo: https://github.com/PyCQA/isort
82+
rev: '5.12.0'
83+
hooks:
84+
- id: isort
85+
args: [--config-root, model/atmosphere/dycore/, --resolve-all-configs]
86+
87+
- repo: https://github.com/PyCQA/flake8
88+
rev: '4.0.1'
89+
hooks:
90+
- id: flake8
91+
name: flake8 code style checks
92+
additional_dependencies:
93+
- darglint
94+
- flake8-bugbear
95+
- flake8-builtins
96+
- flake8-debugger
97+
- flake8-docstrings
98+
- flake8-eradicate
99+
- flake8-mutable
100+
- pygments
101+
args: [--config=model/atmosphere/dycore/.flake8, model/atmosphere/dycore/src/icon4py/]
102+
103+
- repo: local
104+
hooks:
105+
- id: mypy
106+
name: mypy static type checker
107+
entry: bash -c 'echo mypy temporarily disabled'
108+
#entry: bash -c 'cd model/atmosphere/dycore; mypy src/' --
109+
language: system
110+
types_or: [python, pyi]
111+
always_run: true
112+
#pass_filenames: false
113+
require_serial: true
114+
stages: [commit]

0 commit comments

Comments
 (0)