Skip to content

Commit

Permalink
refactor(ongoing): introduce cookiecutter
Browse files Browse the repository at this point in the history
  • Loading branch information
pplmx committed Aug 13, 2024
1 parent f745668 commit 8833bb6
Show file tree
Hide file tree
Showing 39 changed files with 80 additions and 92 deletions.
19 changes: 19 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"templates": {
"cxx": {
"path": "./template/cxx",
"title": "C++ Project",
"description": "A cookiecutter template for a cxx project"
},
"go": {
"path": "./template/go",
"title": "Go Project",
"description": "A cookiecutter template for a go project"
},
"python": {
"path": "./template/py",
"title": "Python Project",
"description": "A cookiecutter template for a python project"
}
}
}
4 changes: 2 additions & 2 deletions template/cxx/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--
Please make sure:
- you have read the contributing guidelines:
https://github.com/{{gh_uname}}/{{project-name}}/blob/main/docs/CONTRIBUTING.md
https://github.com/{{gh_uname}}/{{cookiecutter.package_name}}/blob/main/docs/CONTRIBUTING.md
- you have updated the changelog (if needed):
https://github.com/{{gh_uname}}/{{project-name}}/blob/main/CHANGELOG.md
https://github.com/{{gh_uname}}/{{cookiecutter.package_name}}/blob/main/CHANGELOG.md
-->
6 changes: 3 additions & 3 deletions template/cxx/compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: Compose specification

service:
{{project-name}}:
{{cookiecutter.package_name}}:
build: .

networks:
{{project-name}}-net:
name: {{project-name}}-net
{{cookiecutter.package_name}}-net:
name: {{cookiecutter.package_name}}-net
ipam:
config:
- subnet: 172.16.238.0/24
4 changes: 2 additions & 2 deletions template/go/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--
Please make sure:
- you have read the contributing guidelines:
https://github.com/{{gh_uname}}/{{project-name}}/blob/main/docs/CONTRIBUTING.md
https://github.com/{{gh_uname}}/{{cookiecutter.package_name}}/blob/main/docs/CONTRIBUTING.md
- you have updated the changelog (if needed):
https://github.com/{{gh_uname}}/{{project-name}}/blob/main/CHANGELOG.md
https://github.com/{{gh_uname}}/{{cookiecutter.package_name}}/blob/main/CHANGELOG.md
-->
6 changes: 3 additions & 3 deletions template/go/compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: Compose specification

service:
{{project-name}}:
{{cookiecutter.package_name}}:
build: .

networks:
{{project-name}}-net:
name: {{project-name}}-net
{{cookiecutter.package_name}}-net:
name: {{cookiecutter.package_name}}-net
ipam:
config:
- subnet: 172.16.238.0/24
9 changes: 0 additions & 9 deletions template/py/.github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

21 changes: 0 additions & 21 deletions template/py/cargo-generate.toml

This file was deleted.

26 changes: 0 additions & 26 deletions template/py/fix-project-name.rhai

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Steps to reproduce the behavior:
<!-- Please fill the following information. -->

- OS: [e.g. Ubuntu 20.04]
- {{project-name}} version: [e.g. 0.1.0]
- {{cookiecutter.package_name}} version: [e.g. 0.1.0]

## Additional context

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Please explain the changes you made -->

<!--
Please make sure:
- you have read the contributing guidelines:
https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/blob/main/docs/CONTRIBUTING.md
- you have updated the changelog (if needed):
https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/blob/main/CHANGELOG.md
-->
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ jobs:
context: .
load: true
tags: |
ghcr.io/{{gh_uname}}/{{project-name}}:latest
ghcr.io/{{gh_uname}}/{{project-name}}:${GITHUB_REF_NAME:1}
ghcr.io/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}:latest
ghcr.io/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}:${GITHUB_REF_NAME:1}
-
name: Test it before Push
run: |
docker run --rm ghcr.io/{{gh_uname}}/{{project-name}}:latest
docker run --rm ghcr.io/{{gh_uname}}/{{project-name}}:${GITHUB_REF_NAME:1}
docker run --rm ghcr.io/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}:latest
docker run --rm ghcr.io/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}:${GITHUB_REF_NAME:1}
-
name: Build and Push
uses: docker/build-push-action@v5
Expand All @@ -50,5 +50,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/{{gh_uname}}/{{project-name}}:latest
ghcr.io/{{gh_uname}}/{{project-name}}:${GITHUB_REF_NAME:1}
ghcr.io/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}:latest
ghcr.io/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}:${GITHUB_REF_NAME:1}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Contribution guidelines

First off, thank you for considering contributing to {{project-name}}.
First off, thank you for considering contributing to {{cookiecutter.project_slug}}.

If your contribution is not straightforward, please first discuss the change you
wish to make by creating a new issue before making the change.

## Reporting issues

Before reporting an issue on the
[issue tracker](https://github.com/{{gh_uname}}/{{project-name}}/issues),
[issue tracker](https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/issues),
please check that it has not already been reported by searching for some related
keywords.

Expand Down Expand Up @@ -42,8 +42,8 @@ If the required subsection does not exist yet under **Unreleased**, create it!
This is no different from other Python projects.

```shell
git clone https://github.com/{{gh_uname}}/{{project-name}}
cd {{project-name}}
git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}
cd {{cookiecutter.project_slug}}
make test
```

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# {{project-name}}

[![CI](https://github.com/{{gh_uname}}/{{project-name}}/workflows/CI/badge.svg)](https://github.com/{{gh_uname}}/{{project-name}}/actions)
[![Coverage Status](https://coveralls.io/repos/github/{{gh_uname}}/{{project-name}}/badge.svg?branch=main)](https://coveralls.io/github/{{gh_uname}}/{{project-name}}?branch=main)
[![CI](https://github.com/{{cookiecutter.github_username}}/{{project-name}}/workflows/CI/badge.svg)](https://github.com/{{cookiecutter.github_username}}/{{project-name}}/actions)
[![Coverage Status](https://coveralls.io/repos/github/{{cookiecutter.github_username}}/{{project-name}}/badge.svg?branch=main)](https://coveralls.io/github/{{cookiecutter.github_username}}/{{project-name}}?branch=main)
[![PyPI version](https://badge.fury.io/py/{{project-name}}.svg)](https://badge.fury.io/py/{{project-name}})
[![Python Versions](https://img.shields.io/pypi/pyversions/{{project-name}}.svg)](https://pypi.org/project/{{project-name}}/)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: Compose specification

service:
{{project-name}}:
{{cookiecutter.project_slug}}:
build: .

networks:
{{project-name}}-net:
name: {{project-name}}-net
{{cookiecutter.project_slug}}-net:
name: {{cookiecutter.project_slug}}-net
ipam:
config:
- subnet: 172.16.238.0/24
16 changes: 16 additions & 0 deletions template/py/{{cookiecutter.project_slug}}/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"project_name": "My Awesome Project",
"project_slug": "{{ cookiecutter.package_name | slugify }}",
"package_name": "{{ cookiecutter.project_slug | replace('-', '_') }}",
"short_description": "A nice python package",
"github_username": "your-org-or-username",
"full_name": "Firstname Lastname",
"email": "email@example.com",
"__prompts__": {
"package_name": "Select your project name",
"short_description": "Short description",
"github_username": "GitHub username or organization",
"full_name": "Author full name",
"email": "Author email"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "{{project-name}}"
name = "{{cookiecutter.project_slug}}"
version = "0.0.1"
description = "{{py_proj_desc}}"
readme = "README.md"
requires-python = ">=3.11"
license = "MIT"
authors = [
{ name = "{{gh_uname}}" },
{ name = "{{cookiecutter.github_username}}" },
]
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -31,16 +31,16 @@ dev = [
]

[project.urls]
Documentation = "https://github.com/{{gh_uname}}/{{project-name}}#readme"
Issues = "https://github.com/{{gh_uname}}/{{project-name}}/issues"
Source = "https://github.com/{{gh_uname}}/{{project-name}}"
Documentation = "https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}#readme"
Issues = "https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}/issues"
Source = "https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}}"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = [
"-ra", # show all captured stdout/stderr
"-q", # quiet
"--cov={{project-name}}", # report coverage of {{project-name}}
"--cov={{cookiecutter.project_slug}}", # report coverage of {{cookiecutter.project_slug}}
"--cov-report=term-missing", # show missing coverage
"--cov-report=html", # generate html coverage report
"--cov-report=lcov", # generate lcov coverage report
Expand All @@ -53,16 +53,16 @@ markers = [
]

[tool.coverage.run]
source_pkgs = ["{{project-name}}", "tests"]
source_pkgs = ["{{cookiecutter.package_name}}", "tests"]
branch = true
parallel = true
omit = [
"*/.venv/*"
]

[tool.coverage.paths]
{{project-name}} = ["src/{{project-name}}", "*/{{project-name}}/src/{{project-name}}"]
tests = ["tests", "*/{{project-name}}/tests"]
{{cookiecutter.package_name}} = ["src/{{cookiecutter.package_name}}", "*/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}"]
tests = ["tests", "*/{{cookiecutter.project_slug}}/tests"]

[tool.coverage.report]
exclude_lines = [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from {{project-name}} import add, divide, multiply, subtract
from {{cookiecutter.package_name}} import add, divide, multiply, subtract


def test_add():
Expand Down

0 comments on commit 8833bb6

Please sign in to comment.