Skip to content

Commit f916543

Browse files
jeremykubicahombit
andauthored
Add some of the core precommit tests (#619)
* Fixes * Update .pre-commit-config.yaml Co-authored-by: Konstantin Malanchev <hombit@gmail.com> --------- Co-authored-by: Konstantin Malanchev <hombit@gmail.com>
1 parent 9741b23 commit f916543

10 files changed

Lines changed: 37 additions & 14 deletions

‎.github/workflows/smoke-test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
# Runs this workflow automatically
1111
schedule:
1212
- cron: 45 6 * * *
13-
13+
1414
# Allows you to run this workflow manually from the Actions tab
1515
workflow_dispatch:
1616

‎.pre-commit-config.yaml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ repos:
2121
stages: [pre-commit]
2222
language: system
2323
entry: jupyter nbconvert --clear-output
24-
# Prevents committing directly branches named 'main' and 'master'.
24+
# Run a series of standard precommit checks, including:
25+
# - no commits to branches named 'main' and 'master'.
26+
# - No large files (>= 500kb)
27+
# - All YAML and TOML files are valid.
28+
# - No outstanding merge conflict markers in the codebase.
2529
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c
30+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
2731
hooks:
2832
- id: no-commit-to-branch
2933
name: Prevent main branch commits
@@ -32,6 +36,13 @@ repos:
3236
name: Check for large files
3337
description: Prevent the user from committing very large files.
3438
args: ['--maxkb=500']
39+
- id: check-toml
40+
name: Validate TOML files
41+
- id: check-yaml
42+
args: [--allow-multiple-documents] # Allow multiple document format
43+
name: Validate YAML files
44+
- id: check-merge-conflict
45+
name: Check for files that contain merge conflict strings
3546
# Verify that pyproject.toml is well formed
3647
- repo: https://github.com/abravalheri/validate-pyproject
3748
rev: 17e12779811926f000bdfa1795f9e3735dd71ac3
@@ -79,7 +90,9 @@ repos:
7990
# supported by your project here, or alternatively use
8091
# pre-commit's default_language_version, see
8192
# https://pre-commit.com/#top_level-default_language_version
82-
language_version: python3.11
93+
# This currently uses the default language version. Uncomment
94+
# the following line to use the max version.
95+
# language_version: python{{ py.max(python_versions) }}
8396
# Run unit tests, verify that they pass. Note that coverage is run against
8497
# the ./src directory here because that is what will be committed. In the
8598
# github workflow script, the coverage is run against the installed package

‎docs/practices/issue_pr_templating.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ provides generic fields for:
6060

6161
As well as a set of additional project and issue-specific fields. This template
6262
only serves as an initial framework, and you should feel free to modify this as
63-
you see fit by directly modifying the template file.
63+
you see fit by directly modifying the template file.

‎docs/source/update_project.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ For all the details about updating with Copier checkout the
141141
Still have questions?
142142
-------------------------------------
143143

144-
:doc:`/source/contact`
144+
:doc:`/source/contact`

‎python-project-template/.github/workflows/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ or when you create a new PR.
66

77
For more information about CI and workflows, look here: https://lincc-ppt.readthedocs.io/en/latest/practices/ci.html
88

9-
Or if you still have questions contact us: https://lincc-ppt.readthedocs.io/en/latest/source/contact.html
9+
Or if you still have questions contact us: https://lincc-ppt.readthedocs.io/en/latest/source/contact.html

‎python-project-template/.github/workflows/pre-commit-ci.yml.jinja‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
env:
4040
SKIP: "check-lincc-frameworks-template-version,no-commit-to-branch,check-added-large-files,validate-pyproject,sphinx-build,pytest-check"
4141
- uses: pre-commit-ci/lite-action@062bca0919bc9d6e66755cc05074b70c77e111fc # v1.2.0
42-
if: failure() && github.event_name == 'pull_request' && github.event.pull_request.draft == false
42+
if: failure() && github.event_name == 'pull_request' && github.event.pull_request.draft == false

‎python-project-template/.pre-commit-config.yaml.jinja‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ repos:
2121
stages: [pre-commit]
2222
language: system
2323
entry: jupyter nbconvert --clear-output
24-
# Prevents committing directly branches named 'main' and 'master'.
24+
# Run a series of standard precommit checks, including:
25+
# - no commits to branches named 'main' and 'master'.
26+
# - No large files (>= 500kb)
27+
# - All YAML and TOML files are valid.
28+
# - No outstanding merge conflict markers in the codebase.
2529
- repo: https://github.com/pre-commit/pre-commit-hooks
2630
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
2731
hooks:
@@ -32,6 +36,13 @@ repos:
3236
name: Check for large files
3337
description: Prevent the user from committing very large files.
3438
args: ['--maxkb=500']
39+
- id: check-toml
40+
name: Validate TOML files
41+
- id: check-yaml
42+
args: [--allow-multiple-documents] # Allow multiple document format
43+
name: Validate YAML files
44+
- id: check-merge-conflict
45+
name: Check for merge conflicts
3546
# Verify that pyproject.toml is well formed
3647
- repo: https://github.com/abravalheri/validate-pyproject
3748
rev: 17e12779811926f000bdfa1795f9e3735dd71ac3 # v0.26

‎python-project-template/README.md.jinja‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
[![Benchmarks](https://img.shields.io/github/actions/workflow/status/{{project_organization}}/{{project_name}}/asv-main.yml?label=benchmarks)](https://{{project_organization}}.github.io/{{project_name}}/)
1616
{%- endif %}
1717

18-
This project was automatically generated using the LINCC-Frameworks
18+
This project was automatically generated using the LINCC-Frameworks
1919
[python-project-template](https://github.com/lincc-frameworks/python-project-template).
2020

2121
A repository badge was added to show that this project uses the python-project-template, however it's up to
2222
you whether or not you'd like to display it!
2323

24-
For more information about the project template see the
24+
For more information about the project template see the
2525
[documentation](https://lincc-ppt.readthedocs.io/en/latest/).
2626

2727
## Dev Guide - Getting Started
@@ -47,7 +47,7 @@ development using the following commands:
4747
Notes:
4848
1. `./.setup_dev.sh` will initialize pre-commit for this local repository, so
4949
that a set of tests will be run prior to completing a local commit. For more
50-
information, see the Python Project Template documentation on
50+
information, see the Python Project Template documentation on
5151
[pre-commit](https://lincc-ppt.readthedocs.io/en/latest/practices/precommit.html)
5252
{%- if include_notebooks %}
5353
2. Install `pandoc` allows you to verify that automatic rendering of Jupyter notebooks

‎python-project-template/{% if include_dev_guide %}DEVELOPMENT_GUIDE.md{% endif %}.jinja‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,3 @@ benchmarks/ ASV performance benchmarks
6565
- **File naming:** `tests/{{package_name}}/<SUBDIR>/test_<name>.py`, mirroring the `src/{{package_name}}/` layout.
6666
- **Fixtures:** defined in `tests/conftest.py`. Use existing fixtures, do not duplicate test data.
6767
- Default test run: `python -m pytest`
68-

‎python-project-template/{% if project_license == 'GPL3' %}LICENSE{% endif%}.jinja‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
671671
may consider it more useful to permit linking proprietary applications with
672672
the library. If this is what you want to do, use the GNU Lesser General
673673
Public License instead of this License. But first, please read
674-
<https://www.gnu.org/licenses/why-not-lgpl.html>.
674+
<https://www.gnu.org/licenses/why-not-lgpl.html>.

0 commit comments

Comments
 (0)