You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-30Lines changed: 29 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,18 +60,15 @@ Lots more output
60
60
...
61
61
```
62
62
63
-
## Register pre-commit hooks
63
+
## You _could_ stop here
64
64
65
-
One dependency installed by `pip install '.[dev]'` is `pre-commit`. Run the following command register pre-commit hooks with .git/hooks/pre-commit.
66
-
67
-
```
68
-
>> pre-commit install
69
-
```
70
-
`pre-commit` is an industry standard tool that executes a set of tests prior to completing a `git commit` action. For example, `pre-commit` can run unit tests to verify code coverage and linters to ensure adherence to style guides. Additional documentation can be found [here](https://pre-commit.com/index.html).
65
+
At this point, your new project is hydrated and ready for you to start coding. But there's a lot more that this template has to offer. Keep reading to find out more about built in pre-commit hooks, GitHub CI, automatic documentation, and more.
71
66
72
67
## Commit your new project locally
73
68
74
-
Commit the project to your _local_ version control like so to see the pre-commit checks run.
69
+
:shushing-face: If you're interested in using pre-commit hooks to crosscheck your code before you commit it, now is a good time to set that up (it's just one command) - check out ["Helpful pre-commit hooks"](https://github.com/lincc-frameworks/python-project-template#helpful-pre-commit-hooks).
70
+
71
+
Commit the project to your _local_ version control like so to see the pre-commit checks run.
75
72
76
73
```
77
74
>> git checkout -b initial_branch
@@ -80,7 +77,7 @@ Switched to a new branch 'initial_branch'
80
77
>> git commit -m 'Initial commit'
81
78
```
82
79
83
-
## Extra Credit - Push your work to GitHub
80
+
## Push your work to GitHub
84
81
85
82
Create a new repository in GitHub: ([GitHub How-to](https://docs.github.com/en/get-started/quickstart/create-a-repo))
86
83
@@ -91,31 +88,24 @@ Create a new repository in GitHub: ([GitHub How-to](https://docs.github.com/en/g
91
88
92
89
Notice that when you create a PR in GitHub, a set of tests for Continuous Integration starts up to verify that the project can build successfully and that all the unit tests pass. Neato!
93
90
91
+
# Optional - but Awesome
94
92
95
-
# Some nifty things you get for free
96
-
97
-
## Keep your project up to date as the original template evolves
98
-
99
-
Once your project is under version control you'll be able to keep your project up to date by running `copier update`.
100
-
101
-
Copier will automatically check to see if a newer version of the original template is available and if so the changes will be automatically applied. Neato!
102
-
103
-
And of course, because your project is under version control, if you don't like the new changes, you can always revert back to the previous state. :)
93
+
## Helpful pre-commit hooks
104
94
105
-
## Pre-commit comes with it
95
+
`pre-commit` is installed when running `pip install '.[dev]'`. It's an industry standard tool that executes a set of tests prior to completing a `git commit` action. Using pre-commit enables a quick check of your code before it's committed and checked by GitHub workflows. This cuts down on code feedback time, and allows for faster development. Additional documentation can be found [here](https://pre-commit.com/index.html).
106
96
107
-
No one wants the embarrassment of committing a .py file without a trailing blank line :scream: You'll immediately have access to [pre-commit](https://pre-commit.com/), an industry standard third-party tool.
97
+
To configure pre-commit for your project, run the following command register pre-commit hooks with .git/hooks/pre-commit.
108
98
109
-
Using pre-commit before GitHub workflows start allows you to do a quick check of your code before it's committed. This cuts down on code feedback time, and allows for faster development.
99
+
```
100
+
>> pre-commit install
101
+
```
110
102
111
103
## GitHub CI is ready out of the box
112
104
113
105
Notice that this template contains a `.github/workflows` directory with a `python-package.yml` file. Because of this, any project created from this template that uses GitHub as a repository will automatically have CI enabled.
114
106
115
107
GitHub workflows are extremely useful, for more information, check out the [About workflows](https://docs.github.com/en/actions/using-workflows/about-workflows) page.
116
108
117
-
# Optional - but Awesome
118
-
119
109
## Unit test coverage
120
110
121
111
The GitHub workflow that runs when a new commit is pushed to a pull request, will automatically run unit tests and output code coverage into an xml file. To easily see if code coverage is changing as a result of new work, you should install the GitHub app, Codecov.
@@ -128,20 +118,28 @@ Future pull requests and commits will now include code coverage information. Nea
128
118
129
119
## Automatic publishing to ReadTheDocs
130
120
131
-
If you have connected your GitHub account to [ReadTheDocs](https://readthedocs.org/) you should be able to automatically import the documentation from your project. To connect your GitHub account to ReadTheDocs, simply sign in to ReadTheDocs using your GitHub account.
121
+
If you have connected your GitHub account to [ReadTheDocs](https://readthedocs.org/) you should be able to automatically import the documentation from your project. To connect your GitHub account to ReadTheDocs, simply sign in to ReadTheDocs using your GitHub account.
132
122
133
123
On your dashboard, you'll see an "Import a Project" button that will take you to a list of repositories that can be [automatically imported](https://docs.readthedocs.io/en/stable/intro/import-guide.html#automatically-import-your-docs). If you don't see the repository you expect, it is possible that you do not have sufficient permissions configured in your GitHub organization. Talk to an administrator of the organization, and let them know what you're trying to do.
134
124
135
125
## Publishing to PyPI
136
126
137
-
A GitHub workflow is included that will automatically publish the packaged work to [PyPI](https://pypi.org/). To support this, you'll need to configure your new repository.
127
+
A GitHub workflow is included that will automatically publish the packaged work to [PyPI](https://pypi.org/) when a new release is created. To support this, you'll need to configure your repository.
138
128
139
129
- Create and verify an account on PyPI - https://pypi.org/account/register/
140
130
- Create a PyPI API token - https://pypi.org/help/#apitoken
141
131
- Save the API token in your new repository following [these instructions](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/managing-encrypted-secrets-for-your-repository-and-organization-for-github-codespaces#adding-secrets-for-a-repository). Save your secret API token with the name: PYPI_API_TOKEN
142
132
143
133
Now, when you [create a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) from your repository, a workflow will run that will package and deploy the code to PyPI.
144
134
135
+
## Keep your project up to date as the original template evolves
136
+
137
+
Once your project is under version control you'll be able to keep your project up to date by running `copier update`.
138
+
139
+
Copier will automatically check to see if a newer version of the original template is available and if so the changes will be automatically applied. Neato!
140
+
141
+
And of course, because your project is under version control, if you don't like the new changes, you can always revert back to the previous state. :grinning:
142
+
145
143
# Contributing to the Template
146
144
147
145
## Find (or make) a new GitHub issue
@@ -152,25 +150,26 @@ If there isn't an issue for the work you want to do, please create one and inclu
152
150
153
151
## Create a branch
154
152
155
-
It is preferable that you create a new branch with a name like `issue/##/<short-description>`. GitHub makes it pretty easy to associate branches and tickets, but it's just easier when it's in the name.
153
+
It is preferable that you create a new branch with a name like `issue/##/<short-description>`. GitHub makes it pretty easy to associate branches and tickets, but it's nice when it's in the name.
156
154
157
155
## Testing the template
158
156
159
157
Testing can be tricky. The current best way is to clone this repository locally, and use Copier to generate a test project locally, then verify your expected results.
160
158
161
-
Copier will look for git tags to determine which version of the template to use. You probably don't want to create new tags while you're working on the template. Create a test project using this signature to let Copier know to use the latest local version. See the [Copier documentation](https://copier.readthedocs.io/en/latest/generating/#regenerating-a-project) for more information.
162
-
159
+
Copier will look for git tags to determine which version of the template to use. You probably don't want to create new tags while you're working on the template. Create a test project using the following command to let Copier know to use the latest local version.
163
160
```
164
161
>> copier --vcs-ref HEAD </local/path/to/template> </test/project/directory>
165
162
```
166
163
Notes:
167
164
1) Any changes to the template will need to be committed (**not pushed**) to be picked up by Copier.
168
165
2) If there's an opportunity for introducing an automated test, please take it.
166
+
3) This project has some automated testing, to ensure that the template can hydrate a reasonable output project - feel free to extend that if it's reasonable.
167
+
4) See the [Copier documentation](https://copier.readthedocs.io/en/latest/generating/#regenerating-a-project) for more information.
169
168
170
169
## Create your PR
171
170
172
-
To be able to move quickly, there aren't many guardrails right now to prevent merging bad code. This will change as the project becomes more mature. For now, please use PR best practices, and get someone to review your code.
171
+
Please use PR best practices, and get someone to review your code.
173
172
174
173
## Optional - Release a new version
175
174
176
-
Once you've tested the updates you should create a new release to make them available. GitHub's [instructions](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) for doing so are here. Use your best judgement when incrementing the version. i.e. is this a major, minor, or patch fix.
175
+
Once your PR is merged you should create a new release to make your changes available. GitHub's [instructions](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) for doing so are here. Use your best judgement when incrementing the version. i.e. is this a major, minor, or patch fix.
0 commit comments