Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5e36c30
#75 fixing whitespaces and code format
ChrsBaur Dec 8, 2022
a6ffc4c
#refined pr
ChrsBaur Dec 9, 2022
e77f65f
#refined pr v2 - deleted whitespaces in functions
ChrsBaur Dec 23, 2022
6dd5b99
Use mambaforge as base image
Dec 8, 2022
3decf1f
Optimise Dockerfile for caching
Jan 20, 2023
9257b4f
Change metadata version reference to project_slug
Jan 25, 2023
a3a1962
Begin to add and adapt files for az-devops option
Feb 13, 2023
dd51238
complete draft of test pipeline for pip and conda
AlexF1994 Feb 15, 2023
e428dc3
Merge pull request #92 from at-gmbh/refactor/conda-dockerfile
carsten-bo Feb 17, 2023
8498241
Merge pull request #104 from at-gmbh/fix/metadata_version_fetch
klamann Feb 17, 2023
ebd4274
move append of conda to path to proper if else position
AlexF1994 Feb 20, 2023
8064e4f
Merge pull request #1 from MichaelGehring/feature/az-devops-afo
MichaelGehring Feb 20, 2023
cd476d7
Move DevOps files into project_slug dir
Feb 20, 2023
a5ed727
Fix declaration of all ci files
Feb 20, 2023
6c85536
Copy Build and Delete templates without rendering
Feb 20, 2023
7dba22a
Bf - Add forgotten devops file path
Feb 20, 2023
85f5237
Bf - delete empty step
Feb 20, 2023
2ba8570
Fix indentation
Feb 20, 2023
256ec3e
Revert "Fix indentation"
Feb 20, 2023
605bd58
Fix indentation
Feb 20, 2023
03f4a3c
Bf - delete single quotes
Feb 20, 2023
0a225f4
Fix format
Feb 21, 2023
eca9c11
Fix template file names
Feb 21, 2023
5fba904
Fix template file names
Feb 22, 2023
9aa9a8c
Fix template file names
Feb 22, 2023
ced2620
Fix template file names
Feb 22, 2023
830ce74
Revert "Fix template file names"
Feb 22, 2023
f4cd38e
Fix stage names
Feb 22, 2023
ae02d16
Fix other names
Feb 22, 2023
3d743bc
Fix conda test-pipeline
Feb 22, 2023
910b682
cd option conditional on docker option
Feb 27, 2023
d3551df
add tests for az-devops option
AlexF1994 Mar 14, 2023
efb4a1a
Merge pull request #91 from at-gmbh/whitespace_issue
klamann Aug 10, 2023
1188501
add .DS_Store and pyenv to gitignore
klamann Aug 10, 2023
77f47cc
set min version to python 3.8 (3.7 is EOL)
klamann Aug 10, 2023
39cb5a1
Merge pull request #112 from at-gmbh/feature/gitignore-update
klamann Aug 10, 2023
e89e17e
revert to 3.11 as max supported
klamann Aug 10, 2023
97abe83
added human readable prompts
ChrsBaur Aug 24, 2023
85ebfc4
linter happiness
ChrsBaur Aug 24, 2023
8a1a556
add poetry option for az devops
AlexF1994 Oct 11, 2023
1bb50f2
rebase to upstream
AlexF1994 Oct 11, 2023
82f94ff
make poetry test pipeline work
AlexF1994 Oct 18, 2023
ac84560
solve new line issue
AlexF1994 Oct 18, 2023
06b6403
Merge pull request #113 from at-gmbh/feature/drop-python-37
klamann Oct 25, 2023
5fb9e2a
adjust descriptions
klamann Oct 25, 2023
c37faa8
Merge pull request #115 from at-gmbh/feature/human-readable-prompts
klamann Oct 25, 2023
167203d
Merge branch 'master' into feature/az-devops
AlexF1994 Nov 7, 2023
57a1c44
fix missing comma in cookiecutter.json
AlexF1994 Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.11]
python-version: [3.8, 3.11]
os: [ubuntu-latest, windows-latest]
name: "Test: Python ${{ matrix.python-version }}, conda, ${{ matrix.os }}"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.11]
python-version: [3.8, 3.11]
os: [ubuntu-latest, windows-latest]
name: "Test: Python ${{ matrix.python-version }}, pip, ${{ matrix.os }}"
steps:
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,22 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# virtualenv
.env
.venv
venv*/

# OS specific
.DS_Store

# IDE settings
.vscode/
.idea/
*.iws

# Pyenv
.python-version

# project-specific stuff
serve/
cookiecutter-server.yml
cookiecutter-server.yml
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ repos:
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-merge-conflict
- id: end-of-file-fixer
- id: mixed-line-ending
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AT Python Template

[![build](https://img.shields.io/github/actions/workflow/status/at-gmbh/at-python-template/tests-pip.yml?branch=master)](https://github.com/at-gmbh/at-python-template/actions?query=branch%3Amaster+)
![Python Version](https://img.shields.io/badge/python-3.7%20--%203.11-blue)
![Python Version](https://img.shields.io/badge/python-3.8%20--%203.11-blue)
[![License](https://img.shields.io/github/license/at-gmbh/at-python-template)](https://github.com/at-gmbh/at-python-template/blob/master/LICENSE)
![GitHub Repo stars](https://img.shields.io/github/stars/at-gmbh/at-python-template?style=social)

Expand All @@ -13,7 +13,7 @@ This is the official Python Project Template of Alexander Thamm GmbH (AT). It is
2. `cookiecutter https://github.com/at-gmbh/at-python-template`
3. profit!

This will install or update cookiecutter on your system and create a new project in the current folder using the AT Python Template. Please note: Python 3.7 or higher is required.
This will install or update cookiecutter on your system and create a new project in the current folder using the AT Python Template. Please note: Python 3.8 or higher is required.

> This template requires `cookiecutter>=1.7.2`. If you experience issues installing it into your default conda environment, we recommend to create a new clean environment with nothing but the `cookiecutter` package installed.

Expand Down Expand Up @@ -44,6 +44,7 @@ Unfortunately, cookiecutter does not allow us to show any description of the opt
* Select your `ci_pipeline`
- `none` (default): Don't use any CI/CD pipeline.
- `gitlab`: If you plan to use GitLab, this option will add a CI/CD Pipeline definition for [GitLab CI/CD](https://docs.gitlab.com/ee/ci/). The pipeline includes basic steps to build, test and deploy your code. The deployment steps do nothing but echoing a String, as deployment is very project-specific.
- `az-devops`: If you plan to use [Azure DevOps](https://azure.microsoft.com/en-us/products/devops), this option will add a CI pipeline and templates for CD pipelines. For the CD pipelines to work, you need to add project specific information.
* `create_cli` (yes or no): if you plan to build an application with a command line interface (CLI), select *yes* here. This will integrate a template for the CLI into your project - minimal boilerplate guaranteed! (We're leveraging the awesome [typer](https://typer.tiangolo.com/) library for this.)
* `config_file`: select your preferred config format. It is best practice to store your configuration separate from your code, even for small projects, but because there are a gazillion ways to do this, each project seems to reinvents the wheel. We want to provide a few options to set you up with a working configuration:
- `yaml`: use [YAML](https://yaml.org/) as your configuration file format. Easy to read and write, widely adopted, relies on the [PyYAML](https://pyyaml.org/) package.
Expand Down
61 changes: 59 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,66 @@
"package_manager": ["conda", "pip", "poetry"],
"use_notebooks": ["no", "yes"],
"use_docker": ["no", "yes"],
"ci_pipeline": ["none", "gitlab"],
"ci_pipeline": ["none", "gitlab", "az-devops"],
"create_cli": ["no", "yes"],
"config_file": ["none", "hocon", "yaml"],
"code_formatter": ["none", "black"],
"editor_settings": ["none", "pycharm", "vscode"]
"editor_settings": ["none", "pycharm", "vscode"],
"_copy_without_render": [
"cd/build-dev.yml",
"cd/build.yml",
"cd/delete-old-images.yml"
],
"__prompts__": {
"full_name": "What's your [bold yellow]name[/]?",
"company_name": "Enter your [bold yellow]company name[/]; leave empty if not applicable",
"email": "What's your [bold yellow]email address[/]?",
"project_name": "Please provide the [bold yellow]full name of your project[/], as it would appear in a headline",
"project_slug": "Please provide a [bold yellow]slug[/], which is the project name as it would appear in a URL, or accept this suggestion",
"module_name": "Please provide a [bold yellow]module name[/] for your project. Make it short, if possible, and use underscores instead of whitespace",
"project_short_description": "Provide a [bold yellow]short description[/] for the project in one sentence",
"package_manager": {
"__prompt__": "Which [bold yellow]packaging tool[/] would you like to use?",
"conda": "conda (environment.yml)",
"pip": "pip (setup.py)",
"poetry": "poetry (pyproject.toml)"
},
"use_notebooks": {
"__prompt__": "Do you want to include [bold yellow]Jupyter Notebooks[/] in your project?",
"no": "No",
"yes": "Yes"
},
"use_docker": {
"__prompt__": "Do you want to use [bold yellow]Docker[/]?",
"no": "No",
"yes": "Yes"
},
"ci_pipeline": {
"__prompt__": "What [bold yellow]CI pipeline[/] would you like to use?",
"none": "None",
"gitlab": "GitLab CI"
},
"create_cli": {
"__prompt__": "Do you want to create a [bold yellow]CLI[/] for your project?",
"no": "No",
"yes": "Yes"
},
"config_file": {
"__prompt__": "Which [bold yellow]config file format[/] do you prefer?",
"none": "None",
"hocon": "HOCON",
"yaml": "YAML"
},
"code_formatter": {
"__prompt__": "What [bold yellow]code formatter[/] would you like to use?",
"none": "None",
"black": "Black"
},
"editor_settings": {
"__prompt__": "Which [bold yellow]editor settings[/] do you want to include?",
"none": "None",
"pycharm": "PyCharm",
"vscode": "VS Code"
}
}
}
23 changes: 22 additions & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,18 @@
".gitlab-ci.yml",
}

files_ci_all = files_ci_gitlab
files_ci_devops = {
'ci/test-pipeline.yml',
}

files_cd_devops = {
'cd/build-dev.yml',
'cd/build.yml',
'cd/trigger.yml',
'cd/delete-old-images.yml'
}

files_ci_all = files_ci_gitlab | files_ci_devops | files_cd_devops

folders_editor = [
'.idea__editor',
Expand Down Expand Up @@ -167,10 +178,20 @@ def handle_editor_settings():

def handle_ci():
ci_pipeline = '{{ cookiecutter.ci_pipeline }}'
use_docker = '{{ cookiecutter.use_docker }}'
if ci_pipeline == "gitlab":
_delete_files(files_ci_all - files_ci_gitlab)
os.rmdir('ci')
os.rmdir('cd')
elif ci_pipeline == "az-devops":
_delete_files(files_ci_all - files_ci_devops - files_cd_devops)
if use_docker == 'no':
_delete_files(files_cd_devops)
os.rmdir('cd')
elif ci_pipeline == 'none':
_delete_files(files_ci_all)
os.rmdir('ci')
os.rmdir('cd')


def print_success():
Expand Down
6 changes: 3 additions & 3 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
# check Python version (3.7 or higher)
if StrictVersion(platform.python_version()) < StrictVersion("3.7.0"):
print("ERROR: You are using Python {}, but Python 3.7 or higher is required "
# check Python version (3.8 or higher)
if StrictVersion(platform.python_version()) < StrictVersion("3.8.0"):
print("ERROR: You are using Python {}, but Python 3.8 or higher is required "
"to use this template".format(platform.python_version()))
sys.exit(1)
# check cookiecutter version (1.7.2 or higher)
Expand Down
80 changes: 77 additions & 3 deletions tests/test_options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
from pathlib import Path

from .util import assert_file_contains, check_project
import pytest


@pytest.fixture
def az_devops_cd_files():
return [
'cd/build.yml',
'cd/build-dev.yml',
'cd/delete-old-images.yml',
'cd/trigger.yml'
]


@pytest.fixture
def az_devops_ci_files():
return ['ci/test-pipeline.yml']


@pytest.fixture
def az_devops_files(az_devops_ci_files, az_devops_cd_files):
return az_devops_ci_files + az_devops_cd_files


def test_base():
Expand Down Expand Up @@ -61,10 +82,26 @@ def test_docker_poetry():

def test_docker_no():
check_project(
settings={'use_docker': 'no'},
settings={
'use_docker': 'no'
},
files_non_existent=['Dockerfile', 'docker-compose.yml', '.dockerignore'])


def test_docker_no_az_devops(az_devops_cd_files):
check_project(
settings={
'use_docker': 'no',
'ci_pipeline': 'az-devops'
},
files_non_existent=[
'Dockerfile',
'docker-compose.yml',
'.dockerignore',
].extend(az_devops_cd_files)
)


def test_cli_yes():
check_project(
settings={'create_cli': 'yes'},
Expand Down Expand Up @@ -197,6 +234,7 @@ def test_poetry_regression():
run_pytest=True,
)


def test_gitlab_pip():
check_project(
settings={
Expand All @@ -206,6 +244,7 @@ def test_gitlab_pip():
files_existent=[".gitlab-ci.yml"]
)


def test_gitlab_conda():
check_project(
settings={
Expand All @@ -215,6 +254,7 @@ def test_gitlab_conda():
files_existent=[".gitlab-ci.yml"]
)


def test_gitlab_poetry():
check_project(
settings={
Expand All @@ -224,10 +264,44 @@ def test_gitlab_poetry():
files_existent=[".gitlab-ci.yml"]
)

def test_no_ci_pipeline():

def test_az_devops_pip(az_devops_files):
check_project(
settings={
"package_manager": "pip",
"ci_pipeline": "az-devops",
"use_docker": "yes"
},
files_existent=az_devops_files
)


def test_az_devops_conda(az_devops_files):
check_project(
settings={
"package_manager": "conda",
"ci_pipeline": "az-devops",
"use_docker": "yes"
},
files_existent=az_devops_files
)


def test_az_devops_poetry(az_devops_files):
check_project(
settings={
"package_manager": "poetry",
"ci_pipeline": "az-devops",
"use_docker": "yes"
},
files_existent=az_devops_files
)


def test_no_ci_pipeline(az_devops_files):
check_project(
settings={
"ci_pipeline": "none"
},
files_non_existent=[".gitlab-ci.yml"]
files_non_existent=[".gitlab-ci.yml"] + az_devops_files
)
2 changes: 1 addition & 1 deletion tests/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
shutil.rmtree(temp_dir, ignore_errors=True)

# handle possible issues & give proper return codes
if b'Python 3.7 or higher' in stdout or b'successfully created' in stdout:
if b'Python 3.8 or higher' in stdout or b'successfully created' in stdout:
if actual_fail == expect_fail:
print("Python {} {} as expected".format(
platform.python_version(),
Expand Down
6 changes: 6 additions & 0 deletions {{cookiecutter.project_slug}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# virtualenv
.env
.venv
venv*/

# OS specific
.DS_Store

# IDE settings
.vscode/
.idea/
Expand Down
Loading