Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.yml text eol=lf
*.txt text eol=lf
*.json text eol=lf
*.md text eol=lf
*.* text eol=lf
File renamed without changes.
7 changes: 3 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
If it fixes a bug or resolves a feature request, be sure to link to that issue.
Fixes # (issue) -->


## Types of changes

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

- Compiler/interpreter version:
- OS Version:
- Toolchain:
- SDK:

## Further comments

<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you
chose the solution you did and what alternatives you considered, etc... -->
chose the solution you did and what alternatives you considered, etc... -->
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# CHANGELOG

All notable changes to the "**cookie-github**" will be documented in this file.

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).

---

## [Unreleased]

### TODO

-

### Added

-

### Changed

-

### Fixed

-

## [**1.0.0**] - 2023-03-12

### Added

- Cookiecutter templates for .github folder.
- Cookiecutter action for CI Unit testing in C++ (CMake, Catch2 based).
- Basic Documentation.

### Changed

-

### Fixed

-
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Ferretero
Copyright (c) 2023 Andrés Ferreiro González

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ This repository can be used for adding Github Actions and templates to an existi

## Version

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

Project's version should be updated, when applicable:

- In this very file.
- In the changelog.

## Usage

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

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

```bash
$ cookiecutter cookie-github
```
```

NOTE: alternatively, you can use [Cookieninja](https://github.com/cookieninja-generator/cookieninja),
forked and more updated version of Cookiecutter with backward compatibility.

## Variables

Variables allow to customize your project. After running one of the previous cookiecutter commands,
you will be prompted to fill in the following values:

- **add_issue_templates:** this flags controls wether or not to add issue templates in the generated
folder.
- **add_PR_template:** this flags controls wether or not to add a PR template in the generated
folder.
- **add_ci_action_unit_tests_runner:** this variable controls whether or not to create an action to
run unit tests in the repository. The available options are:
- none (no action created).
- cpp, which creates an action for Catch2 based unit tests, built using CMake.

## Contributing

If you want to contribute to this template, feel free to do so! Create a new branch to work in, and
open a pull request when you are done! It will be reviewed and merged into master by one of the
maintainers as soon as possible.

## Authors

- [Andrés Ferreiro González](https://github.com/ferreteleco)

## Maintainer

- [Andrés Ferreiro González](https://github.com/ferreteleco)
12 changes: 12 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"add_issue_templates": [
true,
false
],
"add_PR_template": [
true,
false
],
"add_ci_action_unit_tests_runner": ["none", "cpp"],
"__github_folder": ".github"
}
59 changes: 59 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Post-generate hook for cookiecutter."""

import logging
from pathlib import Path
from shutil import rmtree, copy, copytree


def change_line_endings_crlf_to_lf():
for path in Path(".").glob("**/*"):
if path.is_file():
data = path.read_bytes()
lf_data = data.replace(b"\r\n", b"\n")
path.write_bytes(lf_data)


def remove_unwanted_templates():

if not {{ cookiecutter.add_issue_templates }}:
LOG.info("Skipping issue templates files generation ...")
path = Path("./ISSUE_TEMPLATE")
rmtree(path)

if not {{ cookiecutter.add_PR_template }}:
LOG.info("Skipping PR templates file generation ...")
path = Path("./pull_request_template.md")
path.unlink()


def add_ci_action_unit_tests_runner():
"""Adds a CI action for running unit tests, if applicable"""

target_ci_tests_action = "{{cookiecutter.add_ci_action_unit_tests_runner}}"

if target_ci_tests_action.lower() != "none":

LOG.info("Adding action for running unit tests (workflows folder) with default config...")

destination = Path("workflows")
ci_test_workflow_files_path = Path("_", "workflows", target_ci_tests_action)
copytree(ci_test_workflow_files_path, destination)

else:
LOG.info("Skipping CI action for running unit tests file generation (%s selected) ...", target_ci_tests_action)


def clean():
"""Remove files and folders only needed as input for generation."""
LOG.info("Removing input data folder ...")
rmtree("_")


if __name__ == "__main__":

logging.basicConfig(level=logging.DEBUG, format="%(message)s")
LOG = logging.getLogger("post_gen_project")
remove_unwanted_templates()
add_ci_action_unit_tests_runner()
clean()
change_line_endings_crlf_to_lf()
6 changes: 6 additions & 0 deletions {{ cookiecutter.__github_folder }}/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.yaml text eol=lf
*.yml text eol=lf
*.txt text eol=lf
*.json text eol=lf
*.md text eol=lf
*.* text eol=lf
100 changes: 100 additions & 0 deletions {{ cookiecutter.__github_folder }}/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Bug Report
description: File a bug report
labels: ["bug", "triage"]
assignees:
- octocat

body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!

- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
description: Check those before continue
options:
- label: I checked the documentation and found no answer
- label: I checked to make sure that this issue has not been filed yet
- label: I am running the latest stable version of the code
- label: I have the correct environment and set-up needed for running the code

- type: textarea
id: what-happened
attributes:
label: What happened?
description: Describe the issue here.
placeholder: Tell us what you see!
validations:
required: true

- type: markdown
attributes:
value: |
### Detailed information, fill it where possible / applicable
___

- type: textarea
id: expected-behavior
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
validations:
required: false

- type: textarea
id: steps-to-reproduce
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false

- type: textarea
id: logs
attributes:
label: Relevant application logs
description: Add relevant log excerpt for the application, if applicable.
validations:
required: false

- type: markdown
attributes:
value: |
### OS / environment information, fill it where possible / applicable
___

- type: dropdown
id: operating-systems
attributes:
label: What type of Operating System are you seeing the problem on?
multiple: true
options:
- Linux
- Windows
- Mac
- Other
validations:
required: true

- type: textarea
id: environment
attributes:
label: Environment
description: |
examples:
- **OS**: Ubuntu 20.04
- **Compiler/interpreter version**: Python 3.10.2
value: |
- OS:
- Compiler/interpreter version:
render: Markdown
validations:
required: false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Task
description: Add an issue for a new Task, covering new feature / idea for this project (or a maintenance one)
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Please be sure to include as much details and indications as possible (and applicable)!
- type: textarea
id: Suggestion
attributes:
label: Suggestion / Feature
description: Describe the task to be carried out.
placeholder: Implement a new awesome feature that makes coffee! or Add some tests!
validations:
required: true
Loading