Skip to content

Commit e3bd180

Browse files
committed
feat: improved plain project
* fixed ci for plain project * added tests for plain project * simplified justfile * removed unnecessary things from pyproject.toml in plain project * removed .env.example for plain project * added .python-version to skeleton
1 parent 479c300 commit e3bd180

8 files changed

Lines changed: 53 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ jobs:
1717
- name: "Install just"
1818
uses: extractions/setup-just@v3
1919

20-
- name: "Install uv"
21-
uses: astral-sh/setup-uv@v5
22-
with:
23-
version: "0.7.19"
24-
2520
- name: "Set up Python"
2621
uses: actions/setup-python@v5
2722
with:
2823
python-version-file: ".python-version"
2924

25+
- name: "Install uv"
26+
uses: astral-sh/setup-uv@v5
27+
3028
- name: "Install dependencies"
3129
run: uv sync --dev --no-cache-dir --locked
3230

@@ -40,5 +38,7 @@ jobs:
4038
run: just test
4139

4240
- name: "Run CI checks in generated code"
43-
run: just _ci_generation_check
41+
run: just generation_check
4442

43+
- name: "Run CI checks in generated code (docker variant)"
44+
run: just generation_check_docker

justfile

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
PROJECT_NAME := "copier-python-project"
21
TEST_CATALOG := "test_catalog"
3-
COPIER_ANSWERS_CATALOG := ".copier"
4-
TEST_ANSWERS_FILE := COPIER_ANSWERS_CATALOG + "/.copier-answers." + PROJECT_NAME + ".yml"
2+
DEFAULT_OUTPUT := TEST_CATALOG + "/generated_project"
3+
DOCKER_OUTPUT := TEST_CATALOG + "/dockerized_project"
4+
PLAIN_OUTPUT := TEST_CATALOG + "/plain_project"
55
PATHS_TO_LINT := "tests"
66

77
[doc("Command run when 'just' is called without any arguments")]
@@ -13,7 +13,7 @@ help:
1313

1414
[group("generation")]
1515
[doc("Generates repo from template to output directory")]
16-
copy output=TEST_CATALOG data_file="example-answers.yml":
16+
copy data_file output=DEFAULT_OUTPUT:
1717
uv run copier copy . {{ output }} \
1818
--vcs-ref=HEAD \
1919
--data-file {{ data_file }} \
@@ -22,44 +22,25 @@ copy output=TEST_CATALOG data_file="example-answers.yml":
2222
--force
2323

2424
[group("generation")]
25-
[doc("Deletes the output directory, excluding the answers file (it is remained for re-copying).")]
26-
clear output=TEST_CATALOG:
27-
find "{{ output }}" -mindepth 1 \
28-
-not -path "{{ output }}/{{ COPIER_ANSWERS_CATALOG }}" \
29-
-not -path "{{ output }}/{{ TEST_ANSWERS_FILE }}" \
30-
-delete
31-
32-
[group("generation")]
33-
[doc("Re-copies the template to the output directory, using the answers file. If clear is true, it deletes the output directory first.")]
34-
recopy output=TEST_CATALOG clear="true" skip-answered="true":
35-
@if {{ clear }}; then \
36-
just clear {{ output }}; \
37-
fi
38-
uv run copier recopy {{ output }} \
39-
--vcs-ref=HEAD \
40-
--answers-file {{ TEST_ANSWERS_FILE }} \
41-
--overwrite \
42-
{{ if skip-answered == "true" { "--skip-answered" } else { "" } }}
43-
44-
[group("generation")]
45-
[doc("Same as `recopy`, but with `skip-answered=false` to allow modifying answers.")]
46-
update output=TEST_CATALOG clear="true":
47-
just recopy output={{ output }} clear={{ clear }} skip-answered=false recopy
25+
[doc("Runs linters and tests in the output directory (docker variant).")]
26+
output_all_ff_docker output=DEFAULT_OUTPUT:
27+
cp {{ output }}/.env.example {{ output }}/.env
28+
cd {{ output }} && uv lock
29+
just --justfile {{ output }}/justfile dc all_ff
4830

4931
[group("generation")]
5032
[doc("Runs linters and tests in the output directory.")]
51-
run_lints_and_tests_in_output output=TEST_CATALOG:
52-
cp {{ output }}/.env.example {{ output }}/.env
33+
output_all_ff output=DEFAULT_OUTPUT:
5334
cd {{ output }} && uv lock
54-
just --justfile {{ output }}/justfile dc all_ff
35+
just --justfile {{ output }}/justfile all_ff
5536

5637
[group("development")]
5738
[doc("Run all checks and tests (lints, mypy, tests...)")]
58-
all: lint_full test
39+
all: lint_full test generation_check generation_check_docker
5940

6041
[group("development")]
6142
[doc("Run all checks and tests, but fail on first that returns error (lints, mypy, tests...)")]
62-
all_ff: lint_full_ff test
43+
all_ff: lint_full_ff test generation_check generation_check_docker
6344

6445
[group("development")]
6546
[doc("Runs template tests.")]
@@ -102,6 +83,14 @@ lint_fix:
10283
uv run ruff check {{PATHS_TO_LINT}} --fix
10384
uv run ruff format {{PATHS_TO_LINT}}
10485

105-
_ci_generation_check output=TEST_CATALOG:
106-
just copy {{ output }}
107-
just run_lints_and_tests_in_output {{ output }}
86+
[group("development")]
87+
[group("generation")]
88+
generation_check_docker data_file="test_answers/docker.yml" output=DOCKER_OUTPUT:
89+
just copy {{ data_file }} {{ output }}
90+
just output_all_ff_docker {{ output }}
91+
92+
[group("development")]
93+
[group("generation")]
94+
generation_check data_file="test_answers/plain.yml" output=PLAIN_OUTPUT:
95+
just copy {{ data_file }} {{ output }}
96+
just output_all_ff {{ output }}

skeleton/.github/workflows/ci.yml.jinja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
with:
2828
python-version-file: ".python-version"
2929

30+
- name: "Install uv"
31+
uses: astral-sh/setup-uv@v5
32+
3033
- name: "Install dependencies"
3134
run: uv sync --dev --no-cache-dir --frozen
3235

skeleton/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

skeleton/pyproject.toml.jinja

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@ dependencies = []
1010
[dependency-groups]
1111
dev = [
1212
"copier>=9.8.0",
13+
{%- if docker %}
1314
"dotenv-linter>=0.4.0,<0.5",
15+
{%- endif %}
1416
"fawltydeps>=0.20.0,<1.0.0",
1517
"ipython>=8.14.0,<9",
1618
"mypy>=1.10.0,<2",
1719
"pytest-asyncio>=0.25.2,<0.26",
1820
"pytest-cov>=6.0.0,<7",
21+
{%- if docker %}
1922
"pytest-env>=1.1.3,<2",
23+
{%- endif %}
2024
"pytest-mock>=3.14.0,<4",
2125
"pytest>=8.3.4,<9",
26+
{%- if docker %}
2227
"python-dotenv>=1.0.0,<2",
28+
{%- endif %}
2329
"ruff>=0.14.1",
2430
]
2531

@@ -70,15 +76,21 @@ deps = ["pyproject.toml"]
7076
ignore_unused = [
7177
# Dev dependencies. This list should contain ALL of them!
7278
"copier",
79+
{% if docker %}
7380
"dotenv-linter",
81+
{% endif %}
7482
"fawltydeps",
7583
"ipython",
7684
"mypy",
7785
"pytest-asyncio",
7886
"pytest-cov",
87+
{%- if docker %}
7988
"pytest-env",
89+
{%- endif %}
8090
"pytest-mock",
91+
{% if docker %}
8192
"python-dotenv",
93+
{% endif %}
8294
"pytest",
8395
"ruff",
8496
]
@@ -93,8 +105,10 @@ disable_error_code = "misc"
93105
python_files = ["tests.py", "test_*.py", "*_tests.py"]
94106
addopts = "--strict-markers -p no:warnings --cov=. --cov-fail-under=90 --cov-config=.coveragerc"
95107
asyncio_mode = "auto"
108+
{%- if docker %}
96109

97110
[tool.pytest_env]
98111
FLAVOR = "test"
99112
DEBUG = "True"
100113
SERVICE_NAME = "{{ project_name_kebab_case }}"
114+
{%- endif %}

skeleton/.env.example.jinja renamed to skeleton/{% if docker %}.env.example{% endif %}.jinja

File renamed without changes.

test_answers/plain.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
author_email: author@email.test
2+
author_name: test-author
3+
description: Service description.
4+
docker: false
5+
project_name: test-service

0 commit comments

Comments
 (0)