My own useful pre-commit hooks
Project description
mondeja's pre-commit hooks
Example configuration
- repo: https://github.com/mondeja/pre-commit-hooks
rev: v1.5.2
hooks:
- id: dev-extras-required
- id: root-editorconfig-required
- id: freenom-autorenew
args:
- -domain=my-web.xyz
- id: cloudflare-nameservers
args:
- -domain=my-web.xyz
- id: cloudflare-gh-pages-dns
args:
- -domain=my-web.xyz
- -username=my_gh_username
Hooks
add-pre-commit-hook
Add a pre-commit hook to your configuration file if is not already defined.
Parameters
-repo=URL
(str) Repository of the new hook.-rev=VERSION
(str) Version of the new hook.-hook=ID
(str) Identifier of the new hook.
dev-extras-required
- Doesn't support
setup.py
files. Please, migrate your setup configuration tosetup.cfg
format.- Support for
pyproject.toml
files is limited to printing errors, automatic file rewriting is not performed.
Check if your development dependencies contains all other extras requirements. If an extra requirement is defined in other extra group than your development one, it will be added to your development extra dependencies group. If your development group is not defined, it will be created.
This is useful if you want to execute python -m pip install -e .[dev]
to
install all the optional requirements of the package, so if you add a new
requirement to another groups, it will be added to development requirements.
Parameters
-extra=NAME
(str): Name for your development requirements extra group (as defaultdev
).-setup-cfg=PATH
(str): Path to yoursetup.cfg
file, mandatory if the extras requirements are defined in asetup.cfg
file and this is located in another directory than the current one.-pyproject-toml=PATH
(str): Path to yourpyproject.toml
file, mandatory if the extras requirements are defined in apyproject.toml
file and this is located in another directory than the current one.
nameservers-endswith
Check that the nameservers of a domain ends with a string or raise an error.
You can use it to check if a site like Clouflare is managing a domain using
-nameserver=cloudflare.com
.
Parameters
-domain=DOMAIN
(str): Domain name whose nameservers will be checked.-nameserver=NAMESERVER
(str): String to end the domain name servers in.
cloudflare-nameservers
Check that Cloudflare is handling the nameservers of a domain.
Parameters
-domain=DOMAIN
(str): Domain name whose nameservers will be checked.
cloudflare-gh-pages-dns
Check that the DNS records of a Cloudflare site are configured to serve a static website under Github Pages.
You must define the environment variable
CF_API_KEY
with your Cloudflare API key.
The required DNS records to make it pass are:
Type | Name | Content |
---|---|---|
A | {domain} | 185.199.108.153 |
A | {domain} | 185.199.109.153 |
A | {domain} | 185.199.110.153 |
A | {domain} | 185.199.111.153 |
CNAME | www | {username}.github.io |
Parameters
-domain=DOMAIN
: Domain managed by Cloudflare whose DNS records will be checked.-username=USER
: Github username or organization under the Github Pages site is being served.
Environment variables
CF_API_KEY
: Cloudflare API key of the user that is managing the DNS records of the site using Cloudflare.
freenom-autorenew
Renews your free Freenom domains.
You must set the environment variables
FREENOM_EMAIL
andFREENOM_PASSWORD
to give permissions to this hook for entering in your Freenom account.
Parameters
-domain=DOMAIN
: Domain to renew. This parameter is optional, if you don't specify it, the hook will renew all of the free domains registered in your account.-period=DOMAIN
: Period for the new renovation time. This parameter is optional, if you don't specify it the time will be one year (12M
).
Environment variables
FREENOM_EMAIL
: Email of your Freenom account.FREENOM_PASSWORD
: Password of your Freenom account.
How to use standalone
You can use this script directly from the command line in an online workflow.
pip install mondeja-pre-commit-hooks requests
Use the CLI entry freenom-autorenew
to execute it. You can check the
documentation for the script executing frenom-autorenew -h
.
Configuration example for Github Actions:
name: freenom-autorenew
on:
schedule:
- cron: 0 4 * * * # every night at 04:00
workflow_dispatch:
jobs:
freenom-autorenew:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install freenom-autorenew
run: pip install mondeja-pre-commit-hooks requests
- name: Run freenom-autorenew
run: freenom-autorenew-hook
env:
FREENOM_EMAIL: ${{ secrets.FREENOM_EMAIL }}
FREENOM_PASSWORD: ${{ secrets.FREENOM_PASSWORD }}
Don't forget to set the secrets FREENOM_EMAIL
and FREENOM_PASSWORD
with
your credentials in the configuration of the repository
(Settings -> Secrets
).
root-editorconfig-required
Check if your repository has an .editorconfig
file and if this has a root
directive defined as true
before section headers.
wavelint
Check if your WAVE files have the correct number of channels, frame rate, durations...
Parameters
-nchannels=N
(int): Number of channels that your sounds must have.-sample-width=N
(int): Number of bytes that your sounds must have.-frame-rate=N
(int): Sampling frequency that your sounds must have.-nframes=N
(int): Exact number of frames that your sounds must have.-comptype=TYPE
(str): Compression type that your sounds must have.-compname=NAME
(int): Compression that your sounds must have.-min-duration=TIME
(float): Minimum duration in seconds that your sounds must have.-max-duration=TIME
(float): Maximum duration in seconds that your sounds must have.
More hooks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mondeja_pre_commit_hooks-1.5.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae85f838b33dbd1801ac4c4d743c8724b591b39551fe77b221d4d76c99575159 |
|
MD5 | d4d5d2b13d331d97a6358b19047ae287 |
|
BLAKE2b-256 | cabcf6cca51864e8cf366daf789ed9665a41e43e442cf6c6d5ca09ba2095bf13 |
Hashes for mondeja_pre_commit_hooks-1.5.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 953605e3a5d7e036ae9b281ed7907869c4f10da6e49b4aac95874ef888e34d79 |
|
MD5 | 92962c14d5c09ea484ac022f0c2ff591 |
|
BLAKE2b-256 | e59386e8dc45dc9c23d40fc61f12c3990b3046975d65cf4daddd3695335c8d91 |