|
| 1 | +# Python Project Template |
| 2 | +This is basic python project template with basic CI/CD GA workflow & GH issue & PR template. Anyone can use this template to start a new python project. |
| 3 | + |
| 4 | +## Directory Structure |
| 5 | +You can remove the `(optional)` directories if you don't need them. (e.g. `docker/`, `setup.py`, etc.) |
| 6 | +``` |
| 7 | +python-project-template/ |
| 8 | +├── .github/ # GA workflows & PR, Issue templates |
| 9 | +├── docker/ # (optional) Dockerfile & docker-compose files related to the project. |
| 10 | +├── tests/ # Test codes with pytest |
| 11 | +├── .gitignore # gitignore file |
| 12 | +├── README.md # README file |
| 13 | +└── requirements.txt # Project dependencies |
| 14 | +``` |
| 15 | + |
| 16 | +## Github Actions |
| 17 | +1. [`ci.yml`](https://github.com/jhj0517/python-project-template/tree/master/.github/workflows/ci.yml) |
| 18 | +Basic CI workflow with pytest. It runs tests in the [`tests`](https://github.com/jhj0517/python-project-template/tree/master/tests) directory, with master branch commit & PR triggers by default. |
| 19 | +2. [`publish-dockerhub.yml`](https://github.com/jhj0517/python-project-template/tree/master/.github/workflows/publish-dockerhub.yml) |
| 20 | +Basic CD workflow for DockerHub. This workflow is optional, only needed when you want to publish the docker image to the dockerhub. You can remove this workflow if you don't need it.<br> |
| 21 | +It will build the docker image with [`docker/Dockerfile`](https://github.com/jhj0517/python-project-template/tree/master/docker/Dockerfile) and [`docker/docker-compose.yaml`](https://github.com/jhj0517/python-project-template/tree/master/docker/docker-compose.yaml) for the project and publish it to the dockerhub with the tag `latest`.<br> |
| 22 | +The auto-trigger for this workflow is disabled by default. You can edit the workflow to enable it.<br> |
| 23 | +Before using the workflow, you need to set the `DOCKERHUB_USERNAME` & `DOCKERHUB_TOKEN` in the repository secrets. |
| 24 | + |
| 25 | +[image](URL) |
| 26 | + |
| 27 | +And make sure to edit the `image-name` in the workflow. |
| 28 | + |
| 29 | +[code-url](URL) |
| 30 | + |
| 31 | +3. [`publish-pypi.yml`](https://github.com/jhj0517/python-project-template/tree/master/.github/workflows/publish-dockerhub.yml) |
| 32 | +Basic CD workflow for pypi package. This is the workflow that only used in case when your project is a python package that will be published in the pypi. You can remove this workflow if you don't need it.<br> |
| 33 | +It will build it and publish it to pypi whenever you make a new "release" in the repository.<br> |
| 34 | +The auto-trigger for this workflow is disabled by default. You can edit the workflow to enable it.<br> |
| 35 | +Before using the workflow, edit package name to yours in the workflow. |
| 36 | + |
| 37 | +[code-url](URL) |
| 38 | + |
| 39 | +## Issue & PR Template |
| 40 | +There are some basic templates for the issue & PR. You can edit them or add more to fit your project's needs. |
| 41 | + |
| 42 | +- Issue Templates: |
| 43 | + 1. [`bug_report.md`](https://github.com/jhj0517/python-project-template/tree/master/.github/ISSUE_TEMPLATE/bug_report.md) : Basic bug report template |
| 44 | + 2. [`feature_request.md`](https://github.com/jhj0517/python-project-template/tree/master/.github/ISSUE_TEMPLATE/feature_request.md) : Feature request template |
| 45 | + |
| 46 | +- PR Template: [`pull_request_template.md`](https://github.com/jhj0517/python-project-template/tree/master/.github/pull_request_template.md) |
| 47 | + |
| 48 | + |
| 49 | +## Docker |
| 50 | + |
| 51 | +The [`docker/`](https://github.com/jhj0517/python-project-template/tree/master/docker) directory and [`publish-dockerhub.yml`](https://github.com/jhj0517/python-project-template/tree/master/.github/workflows/publish-dockerhub.yml) are associated with building the docker image and publishing to dockerhub. You can remove them if you don't need them.<br> |
| 52 | +Before building image, make sure to edit the variable in the [`docker/Dockerfile`](https://github.com/jhj0517/python-project-template/tree/master/docker/Dockerfile): |
| 53 | + |
| 54 | +[code-url](URL) |
| 55 | + |
| 56 | +And in [`docker/docker-compose.yaml`](https://github.com/jhj0517/python-project-template/tree/master/docker/docker-compose.yaml) as well: |
| 57 | + |
| 58 | +[code-url](URL) |
| 59 | + |
| 60 | +The image is built and published automatically by the action, but you can also manually build and run the image with the following commands. |
| 61 | + |
| 62 | +1. git clone this repository |
| 63 | +```bash |
| 64 | +git clone https://github.com/your-name/your-project-name.git |
| 65 | +``` |
| 66 | +2. Build the image |
| 67 | +```bash |
| 68 | +docker compose -f docker/docker-compose.yaml build |
| 69 | +``` |
| 70 | +3. Run the container |
| 71 | +```bash |
| 72 | +docker compose -f docker/docker-compose.yaml up |
| 73 | +``` |
| 74 | + |
| 75 | +## PyPI |
| 76 | +The [`setup.py`](https://github.com/jhj0517/python-project-template/tree/master/setup.py), [`pyproject.toml`](https://github.com/jhj0517/python-project-template/tree/master/setup.py) and [`publish-pypi.yml`](https://github.com/jhj0517/python-project-template/tree/master/.github/workflows/publish-dockerhub.yml) are associated with building the package and publishing to PyPI. You can remove them if you don't need them.<br> |
| 77 | +Make sure to edit dependencies & variables in the [`pyproject.toml`](https://github.com/jhj0517/python-project-template/tree/master/setup.py) as your project's needs. |
| 78 | + |
| 79 | + |
| 80 | +## How to start |
| 81 | +Click "Use this template" and "Create a new repository". Then git clone it and you can start your own project. |
| 82 | + |
| 83 | +[image-url](URL) |
| 84 | + |
| 85 | + |
| 86 | + |
0 commit comments