Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add teyit for better unittest assertions. #267

Merged
merged 1 commit into from
Aug 26, 2024
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
29 changes: 29 additions & 0 deletions .github/workflows/pre-commit-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pre-Commit Update
on:
schedule:
- cron: "0 12 * * 0" # run once a week on Sunday
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
pre-commit-update:
strategy:
matrix:
python-version:
- 3.11
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Check for pre-commit dependency updates
# This fails, if there is a new version available,
# Update to the new version number in
# .pre-commit-config.yaml and config/default/pre-commit-config.yaml.j2.
run: |
pre-commit autoupdate
git diff --exit-code
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ repos:
rev: v2.0.4
hooks:
- id: autopep8
- repo: https://github.com/isidentical/teyit
rev: 0.4.3
hooks:
- id: teyit
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
Expand Down
12 changes: 12 additions & 0 deletions config/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ updated. Example:
"*.mo",
]

[pre-commit]
teyit-exclude = "App/tests/fixtures/error\.py"

[readthedocs]
build-extra = [
"apt_packages:",
Expand Down Expand Up @@ -623,6 +626,15 @@ ignore
Additional lines to be added to the ``.gitignore`` file. This option has to
be a list of strings and defaults to an empty list.

pre-commit options
``````````````````

The corresponding section is named: ``[pre-commit]``.

teyit-exclude
Regex for files to be hidden from teyit. It fails on files containing syntax
errors. This option has to be a string and is omitted when not defined.

ReadTheDocs options
```````````````````

Expand Down
3 changes: 2 additions & 1 deletion config/config-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,14 @@ def gitignore(self):
)

def pre_commit_config_yaml(self):
# git_ignore = self.meta_cfg["git"].get("ignore", [])
teyit_exclude = self.meta_cfg["pre-commit"].get("teyit-exclude", "")

self.copy_with_meta(
"pre-commit-config.yaml.j2",
self.path / ".pre-commit-config.yaml",
self.config_type,
oldest_python_version=OLDEST_PYTHON_VERSION.replace(".", ""),
teyit_exclude=teyit_exclude,
)

def readthedocs(self):
Expand Down
7 changes: 7 additions & 0 deletions config/default/pre-commit-config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ repos:
hooks:
- id: pyupgrade
args: [--py%(oldest_python_version)s-plus]
- repo: https://github.com/isidentical/teyit
rev: 0.4.3
hooks:
- id: teyit
{% if teyit_exclude %}
exclude: %(teyit_exclude)s
{% endif %}
- repo: https://github.com/PyCQA/flake8
rev: "7.1.1"
hooks:
Expand Down