Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
93dc844
Add pre-commit config with pre-commit-hooks
weiji14 Jun 4, 2024
0d17730
Add pre-commit CI badge to main README.md
weiji14 Jun 4, 2024
8176a18
Mention pre-commit autofix command in doc/contributing.md
weiji14 Jun 4, 2024
4ae3ba5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 4, 2024
c23f776
Add .pre-commit-config.yaml to MAINIFEST.in
weiji14 Jun 4, 2024
ce6d457
Add forbid-crlf, remove-crlf and chmod hooks, remove from GitHub Actions
weiji14 Jun 4, 2024
5a01ad6
Remove chmod pre-commit hook and use GitHub Action method again
weiji14 Jun 4, 2024
a444d33
Add `pre-commit run --all-files` to `make format`
weiji14 Jun 9, 2024
b3eee6f
Mention pre-commit autofix command in Pull Request template
weiji14 Jun 9, 2024
d937cac
Revert "Add pre-commit CI badge to main README.md"
weiji14 Jun 11, 2024
0f09fb6
Revert "Mention pre-commit autofix command in doc/contributing.md"
weiji14 Jun 11, 2024
386ad8e
Revert "Mention pre-commit autofix command in Pull Request template"
weiji14 Jun 11, 2024
25652fc
Add pre-commit to Style Checks and format-command workflows
weiji14 Jun 11, 2024
f505a99
[ci skip] Fix end-of-line in style_checks.yaml
weiji14 Jun 11, 2024
7b67296
Remove pre-commit.ci config from .pre-commit-config.yaml
weiji14 Jun 11, 2024
533dc4f
Revert "Remove chmod pre-commit hook and use GitHub Action method again"
weiji14 Jun 11, 2024
10ccc9b
Temporarily change requirements.txt permissions to 744
weiji14 Jun 11, 2024
70414ac
Revert "Temporarily change requirements.txt permissions to 744"
weiji14 Jun 11, 2024
c0e6930
Update note on style_checks.yaml to mention ruff+pre-commit is ran
weiji14 Jun 11, 2024
b606f7f
Mention that pre-commit is used to enforce LF ending and 644 permissions
weiji14 Jun 11, 2024
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
5 changes: 1 addition & 4 deletions .github/workflows/format-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ jobs:
# Install formatting tools
- name: Install formatting tools
run: |
python -m pip install ruff
python -m pip install ruff pre-commit
python -m pip list
sudo apt-get install dos2unix

# Run "make format" and commit the change to the PR branch
- name: Commit to the PR branch if any changes
run: |
make format
git ls-files -z | xargs -0 dos2unix --quiet
git ls-files -z | xargs -0 chmod 644
if [[ $(git ls-files -m) ]]; then
git config --global user.name 'actions-bot'
git config --global user.email '[email protected]'
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/style_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ jobs:

- name: Install packages
run: |
python -m pip install ruff
python -m pip install ruff pre-commit
python -m pip list
sudo apt-get install dos2unix

- name: Formatting check (ruff)
run: make check

- name: Ensure files use UNIX line breaks and have 644 permission
- name: Formatting check (ruff + pre-commit)
run: |
git ls-files -z | xargs -0 dos2unix --quiet
git ls-files -z | xargs -0 chmod 644
if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi
make check
pre-commit run --all-files

- name: Ensure example scripts have at least one code block separator
run: |
Expand Down
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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: v4.6.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
Copy link
Member Author

@weiji14 weiji14 Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also add these hooks from https://github.com/Lucas-C/pre-commit-hooks that handle LF file endings and 644 permissions? (Then we can remove these lines from style_checks.yml).

Suggested change
- id: trailing-whitespace
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: forbid-crlf
- id: remove-crlf
- id: chmod
args: ['644']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member Author

@weiji14 weiji14 Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure why, but pre-commit.ci seeems to think our files have 664 permission instead of 644? See logs at https://results.pre-commit.ci/run/github/85352251/1717481309.E-FyucnQQ_CvuFT06LGuHg

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added back the GitHub Action workflows for 644 permission checks/formatting for now at commit 5a01ad6.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not using pre-commit.ci anymore but just GitHub Actions, I've reinstated the 644 pre-commit hook in the YAML file. Seems to be working at https://github.com/GenericMappingTools/pygmt/actions/runs/9458943127/job/26055263366?pr=3283#step:5:31:

[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/Lucas-C/pre-commit-hooks.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/Lucas-C/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check for added large files..............................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
CRLF end-lines checker...................................................Passed
CRLF end-lines remover...................................................Passed
Set file permissions.....................................................Failed
- hook id: chmod
- exit code: 1
- files were modified by this hook

Fixing file permissions on requirements.txt: 0o755 -> 0o644

Error: Process completed with exit code 1.

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: forbid-crlf
- id: remove-crlf
- id: chmod
args: ['644']
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
All participants in the PyGMT community must abide by
the [Generic Mapping Tools organization Code of Conduct](https://github.com/GenericMappingTools/.github/blob/main/CODE_OF_CONDUCT.md).
the [Generic Mapping Tools organization Code of Conduct](https://github.com/GenericMappingTools/.github/blob/main/CODE_OF_CONDUCT.md).
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ prune examples*
prune pygmt/tests*
exclude .dvcignore
exclude .gitignore
exclude .pre-commit-config.yaml
exclude .readthedocs.yaml
exclude AUTHORSHIP.md
exclude CODE_OF_CONDUCT.md
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ test_no_images: _runtest
format:
ruff check --fix --exit-zero $(FORMAT_FILES)
ruff format $(FORMAT_FILES)
pre-commit run --all-files

check:
ruff check $(FORMAT_FILES)
Expand Down
1 change: 0 additions & 1 deletion doc/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@
.. raw:: html

<div style='clear:both'></div>

1 change: 0 additions & 1 deletion doc/_templates/autosummary/exception.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
.. raw:: html

<div style='clear:both'></div>

1 change: 0 additions & 1 deletion doc/_templates/autosummary/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
.. raw:: html

<div style='clear:both'></div>

4 changes: 2 additions & 2 deletions doc/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
### Highlights

* 🎉 **Twelfth minor release of PyGMT** 🎉
* 🚀 Almost all module wrappers (with a few exceptions) now use in-memory GMT *virtual files* instead of intermediate temporary files to improve performance ([#2730](https://github.com/GenericMappingTools/pygmt/issues/2730))
* 🚀 Almost all module wrappers (with a few exceptions) now use in-memory GMT *virtual files* instead of intermediate temporary files to improve performance ([#2730](https://github.com/GenericMappingTools/pygmt/issues/2730))
* Almost all module wrappers (with a few exceptions) now have consistent behavior for table-like output ([#1318](https://github.com/GenericMappingTools/pygmt/issues/1318))
* Adopt [SPEC 0](https://scientific-python.org/specs/spec-0000/) policy for minimum supported versions of GMT, Python, and other core dependencies
* Adopt [SPEC 0](https://scientific-python.org/specs/spec-0000/) policy for minimum supported versions of GMT, Python, and other core dependencies

### Enhancements

Expand Down
4 changes: 2 additions & 2 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ the code yourself. Before committing, run it to automatically format your code:
make format
```

For consistency, we also use UNIX-style line endings (`\n`) and file permission
644 (`-rw-r--r--`) throughout the whole project.
For consistency, we also use `pre-commit` hooks to enforce UNIX-style line endings
(`\n`) and file permission 644 (`-rw-r--r--`) throughout the whole project.
Don't worry if you forget to do it. Our continuous integration systems will
warn us and you can make a new commit with the formatted code.
Even better, you can just write `/format` in the first line of any comment in a
Expand Down
1 change: 0 additions & 1 deletion doc/team.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,3 @@ year will be moved to Distinguished Contributors.
::::

:::::

1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- pip
# Dev dependencies (style checks)
- codespell
- pre-commit
- ruff>=0.3.0
# Dev dependencies (unit testing)
- matplotlib-base
Expand Down
2 changes: 1 addition & 1 deletion examples/projections/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Projections
===========

PyGMT supports many map projections. Use the ``projection`` parameter to specify which
one you want to use in all plotting methods. The projection is specified by a one-letter
one you want to use in all plotting methods. The projection is specified by a one-letter
code along with (sometimes optional) reference longitude and latitude and the
width of the map (for example, **A**\ *lon0/lat0*\ [*/horizon*\ ]\ */width*). The map
height is determined based on the region and projection.
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/data/contours.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
600 A
700 C
800 A
900 C
900 C