Skip to content

Commit

Permalink
chore: Update Github workflows, pre-commit hooks and makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
saattrupdan committed Jul 15, 2024
1 parent 9d27f8a commit c9d53f8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
5 changes: 3 additions & 2 deletions {{cookiecutter.project_name}}/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ on:
- main

jobs:
lint:
code-check:
if: github.event.pull_request.draft == false
runs-on: {{'ubuntu-latest' if cookiecutter.open_source == 'y' else '[self-hosted, self-hosted-ubuntu-latest]'}}
steps:
- uses: actions/checkout@v4
- uses: jpetrucciani/ruff-check@main
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]

pytest:
if: github.event.pull_request.draft == false
Expand Down
27 changes: 20 additions & 7 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,38 @@ repos:
hooks:
- id: python-use-type-annotations
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.5.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi, jupyter]
args:
- --fix
- --exit-non-zero-on-fix
types_or:
- python
- pyi
- jupyter
- id: ruff-format
types_or: [python, pyi, jupyter]
types_or:
- python
- pyi
- jupyter
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.10.1
hooks:
- id: mypy
args: [--install-types, --non-interactive, --ignore-missing-imports, --show-error-codes]
args:
- --install-types
- --non-interactive
- --ignore-missing-imports
- --show-error-codes
- --check-untyped-defs
12 changes: 6 additions & 6 deletions {{cookiecutter.project_name}}/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ help:

install: ## Install dependencies
@echo "Installing the '{{ cookiecutter.project_name }}' project..."
@$(MAKE) --quiet install-brew
@$(MAKE) --quiet install-gpg
@$(MAKE) --quiet generate-gpg-key{{'\n @$(MAKE) --quiet install-pipx\n @$(MAKE) --quiet install-poetry' if cookiecutter.dependency_manager != 'pip'}}
@$(MAKE) --quiet install-brew{{'\n\t@$(MAKE) --quiet install-gpg' if cookiecutter.open_source != 'y'}}
@$(MAKE) --quiet generate-gpg-key{{'\n\t@$(MAKE) --quiet install-pipx\n\t@$(MAKE) --quiet install-poetry' if cookiecutter.dependency_manager != 'pip'}}
@$(MAKE) --quiet install-dependencies
@$(MAKE) --quiet setup-environment-variables
@$(MAKE) --quiet setup-git{{'\n\t@$(MAKE) --quiet freeze' if cookiecutter.dependency_manager == 'pip'}}
@$(MAKE) --quiet setup-environment-variables{{'\n\t@$(MAKE) --quiet setup-git' if cookiecutter.open_source != 'y'}}{{'\n\t@$(MAKE) --quiet freeze' if cookiecutter.dependency_manager == 'pip'}}
@$(MAKE) --quiet add-repo-to-git
@echo "Installed the '{{ cookiecutter.project_name }}' project. You can now activate your virtual environment with 'source .venv/bin/activate'."
@echo "Installed the '{{ cookiecutter.project_name }}' project. You can now activate your virtual environment with 'source .venv/bin/activate'. If you want to use pre-commit hooks, run 'make install-pre-commit'."
@echo "Note that this is a {{'Poetry' if cookiecutter.dependency_manager != 'pip' else 'pip'}} project. Use '{{'poetry add <package>' if cookiecutter.dependency_manager != 'pip' else 'pip install <package>'}}' to install new dependencies and '{{'poetry remove <package>' if cookiecutter.dependency_manager != 'pip' else 'pip uninstall <package>'}}' to remove them.{{' Freeze your dependencies into pyproject.toml with \'make freeze\'.' if cookiecutter.dependency_manager == 'pip'}}"

install-brew:
Expand Down Expand Up @@ -109,6 +107,8 @@ setup-git:
git config --local user.signingkey ${GPG_KEY_ID}; \
echo "Signed with GPG key ID ${GPG_KEY_ID}."; \
fi

install-pre-commit: ## Install pre-commit hooks
@{{'poetry run ' if cookiecutter.dependency_manager != 'pip' else '. .venv/bin/activate && '}}pre-commit install

add-repo-to-git:
Expand Down

0 comments on commit c9d53f8

Please sign in to comment.