A framework for managing and maintaining multi-language pre-commit hooks.
Documentation: https://pre-commit.com
Map your local project to the container's /project directory. Example:
docker run --rm \
-v /path/to/repository:/project \
ifoodhub/pre-commit:2 \
pre-commit run --all-files --verbose
Example stage for Jenkins' declarative pipeline:
stages {
stage('Lint') {
agent {
docker {
image 'ifoodhub/pre-commit:2'
args '-u 0:0' // Avoid permission-related errors
}
}
steps {
sh 'pre-commit run --all-files --verbose --color always'
}
}
}
Example job for .gitlab-ci.yml:
pre-commit:
stage: lint
image: ifoodhub/pre-commit:2
script:
- pre-commit run --all-files --verbose --color always
Example job for GitHub Actions:
jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-2
container:
image: ifoodhub/pre-commit:2
steps:
- uses: actions/checkout@v1
- name: Run pre-commit
run: |
pre-commit run --all-files --verbose --color always
Depending on your hooks you may want to use the Debian-based image (e.g. pre-commit:2-debian).
For example, the markdownlint hook
installs a pre-compiled NodeJS binary that requires glibc, which is not shipped with Alpine-based images (e.g. latest, 2-alpine, etc).
This image doesn't expect any specific environment variables, but you can use any Python-related one.
For example, in CI/CD pipelines you should set PYTHONUNBUFFERED to ensure the pre-commit output will be immediately dumped,
avoiding unordered messages in your build logs:
pre-commit:
stage: lint
image: ifoodhub/pre-commit:2
variables:
PYTHONUNBUFFERED: "1"
script:
- pre-commit run --all-files --verbose --color always
Content type
Image
Digest
sha256:22b1ffca2…
Size
86.3 MB
Last updated
almost 4 years ago
docker pull ifoodhub/pre-commit