-
Notifications
You must be signed in to change notification settings - Fork 168
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 simple pre-commit hook #1065
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,19 +16,30 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.8" | ||
|
||
# Note: we could try and cache the pre-commit environment | ||
# See the pre-commit docs at https://pre-commit.com/#github-actions-example | ||
- name: Run pre-commit hooks | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pre-commit | ||
pre-commit run --all-files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does modify the files, but we don't commit them. The important thing is that the command's exit code is set to 1 if it made changes, which makes the workflow fail. |
||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
sudo apt-get update | ||
sudo apt install -y meson gettext itstool libgirepository1.0-dev gir1.2-gtk-4.0 libgtksourceview-5-dev libportal-dev | ||
pip install --user -e git+https://github.com/getting-things-gnome/liblarch.git#egg=liblarch | ||
pip install --user pytest pycairo PyGObject caldav lxml | ||
|
||
- name: Build and install GTG | ||
run: | | ||
meson setup --prefix=${PWD}/inst ./build | ||
cd build | ||
meson compile | ||
sudo meson install | ||
|
||
- name: Run unit tests with Pytest | ||
run: | | ||
export PYTHONPATH=${PWD}/inst/lib/python3.8/site-packages | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned in #237, this This file is just the output of |
||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,29 @@ No data should be lost since it is just re-generateable build files. | |
[pudb]: https://pypi.org/project/pudb/ | ||
[gtk-interactive]: https://developer.gnome.org/gtk3/stable/gtk-running.html#interactive-debugging | ||
|
||
## Setting up a development environment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could eventually move into its own file within https://github.com/getting-things-gnome/gtg/tree/master/docs/contributors. I think it's OK to have it here for now. I will create a task for modernizing https://github.com/getting-things-gnome/gtg/blob/master/docs/contributors/coding%20best%20practices.md, which still mentions Python 2 and tox. It's a good place to also mention the automated code quality checks that we're adding. |
||
|
||
Now that you have installed all the dependencies and know how to run the tests, | ||
it's possible that you would like to make code changes and submit them for | ||
review. | ||
|
||
We use [pre-commit](https://pre-commit.com) to run some checks that ensure that | ||
our codebase is clean and consistent. | ||
|
||
Install it with `pip install pre-commit`, and install the pre-commit hooks with | ||
`pre-commit install`. | ||
|
||
The checks will now run every time you make a commit, and fix files if | ||
necessary. It's generally a good idea to always run them, but you can also | ||
bypass them by running `git commit --no-verify`, if necessary. | ||
|
||
The CI system runs the checks on each commit to master, and on each pull | ||
request. If you want to make sure they pass before opening your PR, you can run | ||
them locally with `pre-commit run --all-files`. | ||
|
||
For more guidelines about contributing, see | ||
[CONTRIBUTING.md](./CONTRIBUTING.md). | ||
|
||
# "Where is my user data and config stored?" | ||
|
||
It depends: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried doing it, but my first attempt didn't work. I still had the
but the entire pre-commit step only takes 12 seconds at the moment. So it seems okay to leave it as is for now.