Skip to content

Commit

Permalink
Dogfood pre-commit hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Markovtsev <vadim@athenian.co>
  • Loading branch information
vmarkovtsev committed Feb 9, 2021
1 parent d0d910a commit 85bb365
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
diff CONTRIBUTING.md generated/CONTRIBUTING.md
diff LICENSE generated/LICENSE
diff Makefile generated/Makefile
diff .pre-commit-config.yaml generated/.pre-commit-config.yaml
- name: Test with pytest
run: |
Expand Down Expand Up @@ -188,6 +189,7 @@ jobs:
diff CONTRIBUTING.md generated/CONTRIBUTING.md
diff LICENSE generated/LICENSE
diff Makefile generated/Makefile
diff .pre-commit-config.yaml generated/.pre-commit-config.yaml
- name: Test package
run: |
Expand Down Expand Up @@ -278,4 +280,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASS }}
password: ${{ secrets.PYPI_PASS }}
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/life4/flakehell
rev: v.0.8.0
hooks:
- id: flakehell
8 changes: 0 additions & 8 deletions .pre-commit-hooks.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Remove unused code
Fix a bug
```

Every commit details should describe what was changed, under which context and, if applicable, the GitHub issue it relates to.
Every commit details should describe what was changed, under which context and, if applicable, the GitHub issue it relates to.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ remove-dev-packages:
docker-push:
docker push ${DOCKER_ORG}/${DOCKER_TAG}:${VERSION}
docker tag ${DOCKER_ORG}/${DOCKER_TAG}:${VERSION} ${DOCKER_ORG}/${DOCKER_TAG}:latest
docker push ${DOCKER_ORG}/${DOCKER_TAG}:latest
docker push ${DOCKER_ORG}/${DOCKER_TAG}:latest
3 changes: 2 additions & 1 deletion mloq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project:
requirements:
- dogfood
git_init: false
git_push: null
git_push: false
template:
project_name: mloq
default_branch: master
Expand Down Expand Up @@ -50,4 +50,5 @@ template:
diff CONTRIBUTING.md generated/CONTRIBUTING.md
diff LICENSE generated/LICENSE
diff Makefile generated/Makefile
diff .pre-commit-config.yaml generated/.pre-commit-config.yaml
git_message: null
3 changes: 2 additions & 1 deletion mloq/assets/requirements/dogfood.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ click==7.1.2
flogging==0.0.10
invoke==1.5.0
jinja2==2.11.3
hydra-core==1.0.6
hydra-core==1.0.6
pre-commit==2.10.1
3 changes: 2 additions & 1 deletion mloq/assets/requirements/requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pylint==2.6.0
pydocstyle==5.1.1
pycodestyle==2.6.0
flakehell==0.9.0
black==20.8b1
black==20.8b1
pre-commit==2.10.1
9 changes: 9 additions & 0 deletions mloq/assets/static/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/life4/flakehell
rev: v.0.8.0
hooks:
- id: flakehell
1 change: 0 additions & 1 deletion mloq/assets/templates/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,3 @@ at [https://www.contributor-covenant.org/translations][translations].
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

2 changes: 1 addition & 1 deletion mloq/assets/templates/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Remove unused code
Fix a bug
```

Every commit details should describe what was changed, under which context and, if applicable, the GitHub issue it relates to.
Every commit details should describe what was changed, under which context and, if applicable, the GitHub issue it relates to.
2 changes: 1 addition & 1 deletion mloq/assets/templates/MIT_LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
3 changes: 2 additions & 1 deletion mloq/assets/templates/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ from setuptools import find_packages, setup


version = SourceFileLoader(
"{{project_name}}.version", str(Path(__file__).parent / "{{project_name}}" / "version.py"),
"{{project_name}}.version",
str(Path(__file__).parent / "{{project_name}}" / "version.py"),
).load_module()

with open(Path(__file__).with_name("README.md"), encoding="utf-8") as f:
Expand Down
2 changes: 2 additions & 0 deletions mloq/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def file(
# Common files
mloq_yml = file("mloq.yml", STATIC_FILES_PATH, is_static=True)
gitignore = file(".gitignore", STATIC_FILES_PATH, is_static=True)
pre_commit_hook = file(".pre-commit-config.yaml", STATIC_FILES_PATH, is_static=True)
dco = file("DCO.md", STATIC_FILES_PATH, is_static=True)
init = file("init.txt", STATIC_FILES_PATH, "__init__.py", is_static=True)
main = file("main.txt", STATIC_FILES_PATH, "__main__.py", is_static=True)
Expand Down Expand Up @@ -63,6 +64,7 @@ def file(

ROOT_PATH_FILES = [
gitignore,
pre_commit_hook,
pyproject_toml,
makefile,
dockerfile,
Expand Down
1 change: 1 addition & 0 deletions mloq/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def setup_git(
try:
_git_cmd(path, "init")
_git_cmd(path, *f"remote add origin ssh://git@github.com/{owner}/{project_name}".split())
subprocess.run(("pre-commit", "install"), check=True, cwd=path)
_git_cmd(path, *"add .".split())
_git_cmd(path, *f"commit {'--signoff' if sign_off else ''} -m".split(), message)
if push:
Expand Down
1 change: 1 addition & 0 deletions mloq/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
jinja_env = Environment(
loader=FileSystemLoader([str(TEMPLATES_PATH), str(WORKFLOWS_PATH)]),
autoescape=select_autoescape(["html", "xml"]),
keep_trailing_newline=True,
)


Expand Down
3 changes: 2 additions & 1 deletion requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pylint==2.6.0
pydocstyle==5.1.1
pycodestyle==2.6.0
flakehell==0.9.0
black==20.8b1
black==20.8b1
pre-commit==2.10.1
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ click==7.1.2
flogging==0.0.10
hydra-core==1.0.6
invoke==1.5.0
jinja2==2.11.3
jinja2==2.11.3
pre-commit==2.10.1
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"click>=7.1.2,<8.0.0",
"invoke>=1.4.1",
"hydra-core>=1.0,<1.1",
"pre-commit>=2.10.0",
],
package_data={
"": ["README.md"],
Expand Down

0 comments on commit 85bb365

Please sign in to comment.