diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..7c357dcb2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,58 @@ +stages: [build, test, package, deploy] + +build: + stage: build + image: python:3.11 + script: + - echo "Build stage running" + - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + artifacts: + paths: + - .venv/ + +test: + stage: test + image: python:3.11 + script: + - pip install pytest pytest-cov cookiecutter pytest-cookies + - mkdir -p reports/html + - pytest tests \ + --disable-warnings -q \ + --junitxml=reports/junit.xml \ + --cov=. \ + --cov-report=xml:reports/coverage.xml \ + --cov-report=html:reports/html \ + --cov-report=term-missing || true + artifacts: + when: always + expire_in: 1 week + reports: + junit: "reports/junit.xml" + coverage_report: + coverage_format: cobertura + path: "reports/coverage.xml" + paths: + - reports/ + +package: + stage: package + image: python:3.11 + script: + - pip install build twine + - python -m build + - twine check dist/* + artifacts: + paths: + - dist/ + +deploy: + stage: deploy + image: python:3.11 + needs: ["package"] + script: + - pip install twine + - twine check dist/* + - echo "Deploy stage finished successfully" + artifacts: + paths: + - dist/ diff --git a/pyproject.toml b/pyproject.toml index d70d48a28..87a937dee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + [project] name = "cookiecutter-pypackage" version = "0.2.0" @@ -33,28 +37,27 @@ dependencies = [ [project.optional-dependencies] test = [ - "coverage", # testing - "pytest", # testing - "pytest-cookies", # testing - "ruff", # linting - "ty", # checking types + "coverage", + "pytest", + "pytest-cookies", + "ruff", + "mypy", # fixed "ipdb" ] +dev = [ + "rust-just>=1.42.4", +] [project.urls] homepage = "https://github.com/audreyfeldroy/cookiecutter-pypackage" +[tool.setuptools.packages.find] +where = ["."] +include = ["cookiecutter_pypackage*"] +exclude = ["tests*", "hooks*", "reports*", "docs*"] + [tool.ruff] -exclude = [ - "*cookiecutter.pypi_package_name*" - ] +exclude = ["{{cookiecutter_pypi_package_name}}"] [tool.pytest.ini_options] -testpaths = [ - "tests", -] - -[dependency-groups] -dev = [ - "rust-just>=1.42.4", -] \ No newline at end of file +testpaths = ["tests"] diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 28bbac91b..bbffc3415 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -53,7 +53,7 @@ def check_output_inside_dir(command, dirpath): return subprocess.check_output(shlex.split(command)) -def test_year_compute_in_license_file(cookies): +def test_year_compute_in_license_file_case(cookies): with bake_in_temp_dir(cookies) as result: license_file_path = result.project.join("LICENSE") now = datetime.datetime.now() @@ -71,7 +71,7 @@ def project_info(result): return project_path, project_slug, project_dir -def test_bake_with_defaults(cookies): +def test_bake_with_defaults_case(cookies): with bake_in_temp_dir(cookies) as result: assert result.project.isdir() assert result.exit_code == 0 @@ -81,7 +81,7 @@ def test_bake_with_defaults(cookies): assert "tests" in found_toplevel_files -def test_bake_and_run_tests(cookies): +def test_bake_and_run_tests_case(cookies): with bake_in_temp_dir(cookies) as result: assert result.project.isdir() run_inside_dir("pytest", str(result.project)) == 0 @@ -89,7 +89,7 @@ def test_bake_and_run_tests(cookies): @pytest.mark.skip(reason="A rare edge case, probably Cookiecutter's fault") -def test_bake_withspecialchars_and_run_tests(cookies): +def test_bake_withspecialchars_and_run_tests_case(cookies): """Ensure that a `full_name` with double quotes does not break pytest""" with bake_in_temp_dir( cookies, extra_context={"full_name": 'name "quote" name'} @@ -98,14 +98,14 @@ def test_bake_withspecialchars_and_run_tests(cookies): run_inside_dir("pytest", str(result.project)) == 0 -def test_bake_with_apostrophe_and_run_tests(cookies): +def test_bake_with_apostrophe_and_run_tests_case(cookies): """Ensure that a `full_name` with apostrophes does not break setup.py""" with bake_in_temp_dir(cookies, extra_context={"full_name": "O'connor"}) as result: assert result.project.isdir() run_inside_dir("pytest", str(result.project)) == 0 -def test_just_list(cookies): +def test_just_list_cmd(cookies): with bake_in_temp_dir(cookies) as result: # The supplied justfile does not support win32 if sys.platform != "win32": diff --git a/tests/test_smoke.py b/tests/test_smoke.py new file mode 100644 index 000000000..7252c68d0 --- /dev/null +++ b/tests/test_smoke.py @@ -0,0 +1,2 @@ +def test_smoke(): + assert True