Skip to content

Commit

Permalink
Try pdm scripts and nox for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Jan 3, 2024
1 parent 1faadd9 commit c4b4cac
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
10 changes: 4 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ CI image:
stage: image
tags:
- container-registry-push
# rules:
# - if: '$CI_PIPELINE_SOURCE == "schedule"'
# - if: '$CI_BUILD_IMAGES == "1"'
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_BUILD_IMAGES == "1"'
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
Expand Down Expand Up @@ -54,9 +54,7 @@ validate_code:
- job: "CI image"
optional: true
script:
- pdm install -G dev --no-self
- pdm run make lint
- pdm run make black_check
- nox validate_code

tests:
stage: test
Expand Down
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ __pycache__
.pytest_cache/
.mypy_cache/
.coverage/
.nox

bench/launcher_*
bench/SLURM*
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ shortlog:
@hg log -M -r$(RELEASE): --template '- {desc|firstline} (:rev:`{node|short}`)\n'

black:
black -l 82 fluidsim scripts bench doc lib --exclude "/(__pythran__|__python__|__numba__|doc/_build|\.ipynb_checkpoints/*)/"
pdm black

black_check:
black --check -l 82 fluidsim scripts bench doc lib --exclude "/(__pythran__|__python__|__numba__|doc/_build|\.ipynb_checkpoints/*)/"
pdm black_check

lint:
pdm lint

validate_code:
pdm validate_code

tests:
pytest -v lib
Expand Down Expand Up @@ -84,9 +90,6 @@ _report_coverage:
coverage: _tests_coverage _report_coverage


lint:
pylint -rn --rcfile=pylintrc --jobs=$(shell nproc) fluidsim --exit-zero

define _init_coverage
rm -rf .coverage
mkdir -p .coverage
Expand Down
10 changes: 10 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
import nox

os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})


@nox.session
def validate_code(session):
session.run_always("pdm", "install", "-G", "dev", "--no-self", external=True)
session.run("pdm", "validate_code", external=True)
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ dev = [
"-e fluidsim-core @ file:///${PROJECT_ROOT}/lib",
]

[tool.pdm.scripts]
black = 'black -l 82 fluidsim scripts bench doc lib --exclude "/(__pythran__|__python__|__numba__|doc/_build|\.ipynb_checkpoints/*)/"'
lint = {shell="pylint -rn --rcfile=pylintrc --jobs=$(nproc) fluidsim --exit-zero"}
black_check = 'black --check -l 82 fluidsim scripts bench doc lib --exclude "/(__pythran__|__python__|__numba__|doc/_build|\.ipynb_checkpoints/*)/"'
validate_code = {composite = ["black_check", "lint"]}


[tool.coverage.run]
source = [
"./fluidsim",
Expand Down

0 comments on commit c4b4cac

Please sign in to comment.