Skip to content

Commit d4804aa

Browse files
authored
Merges pull request #6 from ferreteleco/feature/add-template
Adds first working version
2 parents 819964d + 37be16a commit d4804aa

File tree

15 files changed

+410
-8
lines changed

15 files changed

+410
-8
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.yml text eol=lf
33
*.txt text eol=lf
44
*.json text eol=lf
5+
*.md text eol=lf
56
*.* text eol=lf

.github/pull_request_template.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
If it fixes a bug or resolves a feature request, be sure to link to that issue.
55
Fixes # (issue) -->
66

7+
78
## Types of changes
89

910
What types of changes does the PR introduce?
@@ -24,7 +25,7 @@ This is simply a reminder of what we are going to look for before merging your c
2425
- [ ] Introduced code follows the style guidelines of this project
2526
- [ ] Introduced code includes tests that prove fix is effective or feature works (if applicable)
2627
- [ ] Introduced code includes necessary documentation (if applicable)
27-
- [ ] Author has performed a self-review of my code
28+
- [ ] Author has performed a self-review of the introduced code
2829
- [ ] Introduced code includes relevant comments, particularly in hard-to-understand areas
2930
- [ ] New and existing unit tests pass locally with changes included
3031
- [ ] Any dependent changes have been merged and published in downstream modules
@@ -50,10 +51,8 @@ Please also list any relevant details for your test configuration
5051

5152
- Compiler/interpreter version:
5253
- OS Version:
53-
- Toolchain:
54-
- SDK:
5554

5655
## Further comments
5756

5857
<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you
59-
chose the solution you did and what alternatives you considered, etc... -->
58+
chose the solution you did and what alternatives you considered, etc... -->

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CHANGELOG
2+
3+
All notable changes to the "**cookie-github**" will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
---
8+
9+
## [Unreleased]
10+
11+
### TODO
12+
13+
-
14+
15+
### Added
16+
17+
-
18+
19+
### Changed
20+
21+
-
22+
23+
### Fixed
24+
25+
-
26+
27+
## [**1.0.0**] - 2023-03-12
28+
29+
### Added
30+
31+
- Cookiecutter templates for .github folder.
32+
- Cookiecutter action for CI Unit testing in C++ (CMake, Catch2 based).
33+
- Basic Documentation.
34+
35+
### Changed
36+
37+
-
38+
39+
### Fixed
40+
41+
-

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Ferretero
3+
Copyright (c) 2023 Andrés Ferreiro González
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ This repository can be used for adding Github Actions and templates to an existi
44

55
## Version
66

7-
Current version is 0.1.0 and was set according to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
Current version is 1.0.0 and was set according to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

99
Project's version should be updated, when applicable:
1010

1111
- In this very file.
12+
- In the changelog.
1213

1314
## Usage
1415

15-
In order to start a new project, install [Cookiecutter](https://cookiecutter.readthedocs.io/en/latest/) and run the following command:
16+
In order to start a new project, install [Cookiecutter](https://cookiecutter.readthedocs.io/en/latest/)
17+
and run the following command:
1618

1719
```bash
1820
$ cookiecutter https://github.com/ferreteleco/cookie-github.git
@@ -28,4 +30,35 @@ again. In order to do so, simply specify template name as argument for cookiecut
2830

2931
```bash
3032
$ cookiecutter cookie-github
31-
```
33+
```
34+
35+
NOTE: alternatively, you can use [Cookieninja](https://github.com/cookieninja-generator/cookieninja),
36+
forked and more updated version of Cookiecutter with backward compatibility.
37+
38+
## Variables
39+
40+
Variables allow to customize your project. After running one of the previous cookiecutter commands,
41+
you will be prompted to fill in the following values:
42+
43+
- **add_issue_templates:** this flags controls wether or not to add issue templates in the generated
44+
folder.
45+
- **add_PR_template:** this flags controls wether or not to add a PR template in the generated
46+
folder.
47+
- **add_ci_action_unit_tests_runner:** this variable controls whether or not to create an action to
48+
run unit tests in the repository. The available options are:
49+
- none (no action created).
50+
- cpp, which creates an action for Catch2 based unit tests, built using CMake.
51+
52+
## Contributing
53+
54+
If you want to contribute to this template, feel free to do so! Create a new branch to work in, and
55+
open a pull request when you are done! It will be reviewed and merged into master by one of the
56+
maintainers as soon as possible.
57+
58+
## Authors
59+
60+
- [Andrés Ferreiro González](https://github.com/ferreteleco)
61+
62+
## Maintainer
63+
64+
- [Andrés Ferreiro González](https://github.com/ferreteleco)

cookiecutter.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"add_issue_templates": [
3+
true,
4+
false
5+
],
6+
"add_PR_template": [
7+
true,
8+
false
9+
],
10+
"add_ci_action_unit_tests_runner": ["none", "cpp"],
11+
"__github_folder": ".github"
12+
}

hooks/post_gen_project.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""Post-generate hook for cookiecutter."""
2+
3+
import logging
4+
from pathlib import Path
5+
from shutil import rmtree, copy, copytree
6+
7+
8+
def change_line_endings_crlf_to_lf():
9+
for path in Path(".").glob("**/*"):
10+
if path.is_file():
11+
data = path.read_bytes()
12+
lf_data = data.replace(b"\r\n", b"\n")
13+
path.write_bytes(lf_data)
14+
15+
16+
def remove_unwanted_templates():
17+
18+
if not {{ cookiecutter.add_issue_templates }}:
19+
LOG.info("Skipping issue templates files generation ...")
20+
path = Path("./ISSUE_TEMPLATE")
21+
rmtree(path)
22+
23+
if not {{ cookiecutter.add_PR_template }}:
24+
LOG.info("Skipping PR templates file generation ...")
25+
path = Path("./pull_request_template.md")
26+
path.unlink()
27+
28+
29+
def add_ci_action_unit_tests_runner():
30+
"""Adds a CI action for running unit tests, if applicable"""
31+
32+
target_ci_tests_action = "{{cookiecutter.add_ci_action_unit_tests_runner}}"
33+
34+
if target_ci_tests_action.lower() != "none":
35+
36+
LOG.info("Adding action for running unit tests (workflows folder) with default config...")
37+
38+
destination = Path("workflows")
39+
ci_test_workflow_files_path = Path("_", "workflows", target_ci_tests_action)
40+
copytree(ci_test_workflow_files_path, destination)
41+
42+
else:
43+
LOG.info("Skipping CI action for running unit tests file generation (%s selected) ...", target_ci_tests_action)
44+
45+
46+
def clean():
47+
"""Remove files and folders only needed as input for generation."""
48+
LOG.info("Removing input data folder ...")
49+
rmtree("_")
50+
51+
52+
if __name__ == "__main__":
53+
54+
logging.basicConfig(level=logging.DEBUG, format="%(message)s")
55+
LOG = logging.getLogger("post_gen_project")
56+
remove_unwanted_templates()
57+
add_ci_action_unit_tests_runner()
58+
clean()
59+
change_line_endings_crlf_to_lf()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.yaml text eol=lf
2+
*.yml text eol=lf
3+
*.txt text eol=lf
4+
*.json text eol=lf
5+
*.md text eol=lf
6+
*.* text eol=lf
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Bug Report
2+
description: File a bug report
3+
labels: ["bug", "triage"]
4+
assignees:
5+
- octocat
6+
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this bug report!
12+
13+
- type: checkboxes
14+
id: prerequisites
15+
attributes:
16+
label: Prerequisites
17+
description: Check those before continue
18+
options:
19+
- label: I checked the documentation and found no answer
20+
- label: I checked to make sure that this issue has not been filed yet
21+
- label: I am running the latest stable version of the code
22+
- label: I have the correct environment and set-up needed for running the code
23+
24+
- type: textarea
25+
id: what-happened
26+
attributes:
27+
label: What happened?
28+
description: Describe the issue here.
29+
placeholder: Tell us what you see!
30+
validations:
31+
required: true
32+
33+
- type: markdown
34+
attributes:
35+
value: |
36+
### Detailed information, fill it where possible / applicable
37+
___
38+
39+
- type: textarea
40+
id: expected-behavior
41+
attributes:
42+
label: Expected Behavior
43+
description: A concise description of what you expected to happen.
44+
validations:
45+
required: false
46+
47+
- type: textarea
48+
id: steps-to-reproduce
49+
attributes:
50+
label: Steps To Reproduce
51+
description: Steps to reproduce the behavior.
52+
placeholder: |
53+
1. In this environment...
54+
2. With this config...
55+
3. Run '...'
56+
4. See error...
57+
validations:
58+
required: false
59+
60+
- type: textarea
61+
id: logs
62+
attributes:
63+
label: Relevant application logs
64+
description: Add relevant log excerpt for the application, if applicable.
65+
validations:
66+
required: false
67+
68+
- type: markdown
69+
attributes:
70+
value: |
71+
### OS / environment information, fill it where possible / applicable
72+
___
73+
74+
- type: dropdown
75+
id: operating-systems
76+
attributes:
77+
label: What type of Operating System are you seeing the problem on?
78+
multiple: true
79+
options:
80+
- Linux
81+
- Windows
82+
- Mac
83+
- Other
84+
validations:
85+
required: true
86+
87+
- type: textarea
88+
id: environment
89+
attributes:
90+
label: Environment
91+
description: |
92+
examples:
93+
- **OS**: Ubuntu 20.04
94+
- **Compiler/interpreter version**: Python 3.10.2
95+
value: |
96+
- OS:
97+
- Compiler/interpreter version:
98+
render: Markdown
99+
validations:
100+
required: false

0 commit comments

Comments
 (0)