feat: add docker preset
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
[presets.docker]
|
||||
conditions = ["file(Dockerfile)"]
|
||||
|
||||
# build
|
||||
[presets.docker.tasks.build.default]
|
||||
variables.docker_target = "file(.env) | get(DOCKER_PROJECTS)"
|
||||
variables.docker_name = "file(pyproject.toml) | get(project.name)"
|
||||
variables.docker_group = "file(.env) | get(DOCKER_GROUP)"
|
||||
commands = [
|
||||
# "docker build --target {docker_target} -t {docker_group}/{docker_name} . -f Dockerfile",
|
||||
"docker build -t {docker_group}/{docker_name} . -f Dockerfile",
|
||||
]
|
||||
|
||||
# publish
|
||||
[presets.docker.tasks.publish.default]
|
||||
commands = ["docker publish"]
|
||||
@@ -1,6 +1,7 @@
|
||||
[presets.python]
|
||||
conditions = ["file(pyproject.toml)"]
|
||||
|
||||
# setup
|
||||
[presets.python.tasks.setup.poetry]
|
||||
conditions = [
|
||||
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
|
||||
@@ -11,12 +12,14 @@ commands = [
|
||||
"poetry install",
|
||||
]
|
||||
|
||||
# build
|
||||
[presets.python.tasks.build.poetry]
|
||||
conditions = [
|
||||
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
|
||||
]
|
||||
commands = ["poetry build"]
|
||||
|
||||
# publish
|
||||
[presets.python.tasks.publish.poetry]
|
||||
conditions = [
|
||||
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
|
||||
@@ -25,10 +28,12 @@ conditions = [
|
||||
variables.python_repository = "file(poetry.toml) | get(repositories) | key(0)"
|
||||
commands = ["poetry publish -r {python_repository}"]
|
||||
|
||||
# test
|
||||
[presets.python.tasks.test.pytest]
|
||||
conditions = ["file(.venv/bin/pytest)"]
|
||||
commands = [".venv/bin/python -m pytest"]
|
||||
|
||||
# lint
|
||||
[presets.python.tasks.lint.pylint]
|
||||
conditions = ["file(.venv/bin/pylint)"]
|
||||
commands = [".venv/bin/pylint ./"]
|
||||
@@ -37,18 +42,20 @@ commands = [".venv/bin/pylint ./"]
|
||||
conditions = ["file(.venv/bin/isort)"]
|
||||
commands = [".venv/bin/isort --profile black --check-only ./"]
|
||||
|
||||
[presets.python.tasks.format.isort]
|
||||
conditions = ["file(.venv/bin/isort)"]
|
||||
commands = [".venv/bin/isort --profile black ./"]
|
||||
|
||||
[presets.python.tasks.lint.black]
|
||||
conditions = ["file(.venv/bin/black)"]
|
||||
commands = [".venv/bin/black --check --diff ./"]
|
||||
|
||||
# format
|
||||
[presets.python.tasks.format.isort]
|
||||
conditions = ["file(.venv/bin/isort)"]
|
||||
commands = [".venv/bin/isort --profile black ./"]
|
||||
|
||||
[presets.python.tasks.format.black]
|
||||
conditions = ["file(.venv/bin/black)"]
|
||||
commands = [".venv/bin/black ./"]
|
||||
|
||||
# clean
|
||||
[presets.python.tasks.clean.venv]
|
||||
conditions = ["file(.venv)"]
|
||||
commands = ["rm -rf .venv"]
|
||||
|
||||
@@ -31,13 +31,13 @@ class PresetResolver:
|
||||
if self._config.default:
|
||||
yield from (Path(__file__).parent / "default").iterdir()
|
||||
if self._config.user:
|
||||
user_preset = Path.home() / ".preset.toml"
|
||||
user_preset = Path.home() / ".pm.toml"
|
||||
if user_preset.exists():
|
||||
yield user_preset
|
||||
if self._config.project:
|
||||
projectpath = self._basepath
|
||||
while projectpath.exists():
|
||||
project_preset = projectpath / ".preset.toml"
|
||||
project_preset = projectpath / ".pm.toml"
|
||||
if project_preset.exists():
|
||||
yield project_preset
|
||||
if projectpath.parent == projectpath:
|
||||
|
||||
Reference in New Issue
Block a user