-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modernize project infrastructure and switching to hatch (#108)
* Switch to src project structure * Prevent CI being run twice on PR Having CI jobs run on PR and push without any further restrictions runs the CI jobs twice on a new PR, with this setting the CI is only run on pushes to main. * Ignore QbFields warning in sphinx Bug that appeears with aiida 2.6 (independent of this PR), it also goes away when building the docs twice. For now I ignore it. * Remove outdated install_aiida_github.sh It is nowhere used and I am not sure in which context it should be used. Installing aiida-core seems trivial. What would be useful is something for creating new profiles in the tests. * Split pre-commit hook fmt into lint and format * Change ruff settings single quotes -> double quotes double quotes are default so nothing has to be changed * Apply the formatting to double quotes on template repo * Move docs to an optional dependency for readthedocs Because readthedocs can only use extra dependencies from the pyproject.toml, we move the deps of docs into one, so we can reference it in the readthedocs.yaml * Updates in the update-aiida-diff.sh script - Remove `git init` in update aiida-diff script to base on current version - Remove `hatch fmt` at the end since it is done by hook properly * Fix formatting in the cookiecutter hook Now `hatch fmt` is executed twice, running it one time did not fix all isues. Needs to be investigated, if a reviewer has some ideas. * Add script update-template-formatting.sh that can be used to fix formatting To apply the formatting on the cookiecutter template the script initiates a cookiecutter repo instance and applies the formatting on this instance the changes are diffed and copied back to the template. * Update update-aiida-diff.sh Since the cookiecutter hooks is now also performing the formatting, the pre-commit is not necessary. The git init has been removed since the repository already exists. --------- Co-authored-by: Rico Haeuselmann <r.haeuselmann@gmx.ch>
- Loading branch information
1 parent
59c009e
commit 5fa3ff4
Showing
24 changed files
with
283 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
cookiecutter | ||
black==22.12.0 | ||
hatch~=1.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# Creates plugin cutter with unique labels so we can format and then reverses | ||
# the ids to the cookiecutter identifiers and git apply the diff | ||
set -e | ||
|
||
# clean directory contents if exist (but don't delete .git directory) | ||
if [ -d aiida-diff ]; then | ||
rm -rf cookiecutter_plugin_name | ||
fi | ||
cookiecutter --accept-hooks no --no-input -f . plugin_name=cookiecutter_plugin_name module_name=cookiecutter_module_name short_description=cookiecutter_short_description entry_point_prefix=cookiecutter_entry_point_prefix version=0.0.0-dev author=cookiecutter_author year=cookiecutter_year | ||
|
||
cd cookiecutter_plugin_name | ||
git init && git add -A && git commit -am 'init' | ||
hatch fmt || true | ||
# takes the diff and applies it on the cookie cutter template | ||
git diff > patch | ||
cp patch .. | ||
cd .. | ||
# git diff replacements of specified labels with cookiecutter identifiers | ||
sed -i 's/ a\// a\/\{\{cookiecutter.plugin_name\}\}\//g' patch | ||
sed -i 's/ b\// b\/\{\{cookiecutter.plugin_name\}\}\//g' patch | ||
sed -i 's/cookiecutter_plugin_name/\{\{cookiecutter.plugin_name\}\}/g' patch | ||
sed -i 's/cookiecutter_module_name/\{\{cookiecutter.module_name\}\}/g' patch | ||
sed -i 's/cookiecutter_entry_point_prefix/\{\{cookiecutter.entry_point_prefix\}\}/g' patch | ||
sed -i 's/cookiecutter_short_description/\{\{cookiecutter.short_description\}\}/g' patch | ||
sed -i 's/0\.0\.0-dev/\{\{cookiecutter.version\}\}/g' patch | ||
sed -i 's/cookiecutter_author/\{\{cookiecutter.author\}\}/g' patch | ||
sed -i 's/cookiecutter_year/\{\{cookiecutter.year\}\}/g' patch | ||
git apply --reject --whitespace=fix patch |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,13 @@ | ||
# Install pre-commit hooks via: | ||
# pre-commit install | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- id: check-json | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.3.1 | ||
hooks: | ||
- id: pyupgrade | ||
args: ["--py37-plus"] | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 22.12.0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: local | ||
hooks: | ||
- id: pylint | ||
- id: format | ||
name: format | ||
entry: hatch fmt -f | ||
language: system | ||
types: [python] | ||
- id: lint | ||
name: lint | ||
entry: hatch fmt -l | ||
language: system | ||
types: [file, python] | ||
name: pylint | ||
description: "This hook runs the pylint static code analyzer" | ||
exclude: &exclude_files > | ||
(?x)^( | ||
docs/.*| | ||
)$ | ||
entry: pylint | ||
types: [python] |
Oops, something went wrong.