pre-commit
Image which wrap the pre-commit suite could be used in CI/CD pipelines and on command line.
626
Image which wrap the pre-commit suite could be used in CD/CD pipelines and on command line
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need following tools installed:
on Mac:
brew install make orbstack docker-buildx
Create a local image with make build
Runs docker build and docker scout cves
$ make docker-login -e DOCKERUSER=<Username> build
Build the multiarch image and push it to docker hub:
make docker-login -e DOCKERUSER=<Username> build-and-push
Logout form docker hub:
make docker-logout
There are two blocks of parameters, one for the image self and second for the pre-commit command
to get the image options:
$ docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:1.1.0 --image-help
Docker image options:
-i | --image-help Show this help page
-s | --shell Open a shell into the container
-n | --no-build-in-config Do not use the internal .pre-commit-config.yaml
-e | --env Set environment variables for pre-commit
-u | --update-hook Updates the hook versions in the config file,
should used with --no-build-in-config
-c | --copy-config-example copy the internal pre-commit config as .pre-commit-config-example.yaml
into the volume path
and you got the options for pre-commit with
docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:latest --no-build-in-config --help
or get help for a specific pre-commit command:
docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:latest --no-build-in-config -- help [pre-commit command]
Get a shell into the container
docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:latest --shell
Update your local pre-commit config
docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:latest --update-hook .pre-commit-config.yaml
Get a copy of the internal pre-commit configuration as example
docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:latest --copy-config-example
Example run of the pre-commit image:
docker run --rm -v $(pwd):/builds jfheinrich/pre-commit:latest \
--no-build-in-config \
--env SKIP="check-executables-have-shebangs" -- \
run --color always --config .pre-commit-ci.yaml --all-files
This runs the pre-commit command with
check-executables-have-shebangs hook.pre-commit-ci.yaml instead of the build in configpre-commit:
stage: test
image:
name: jfheinrich/pre-commit:latest
entrypoint: [""]
environment:
SKIP="check-executables-have-shebangs"
script:
- pre-commit run --color always --config .pre-commit-ci.yaml --files $(git diff-tree --name-only --no-commit-id $CI_MERGE_REQUEST_TARGET_BRANCH_SHA)
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: no-commit-to-branch
args: [--branch, develop, --branch, main, --branch, master]
- id: check-merge-conflict
args: [--assume-in-merge]
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/thoughtworks/talisman
rev: "v1.33.0"
hooks:
# both pre-commit and pre-push supported
# - id: talisman-push
- id: talisman-commit
Content type
Image
Digest
sha256:ae8fd8d08…
Size
47.3 MB
Last updated
about 1 year ago
docker pull jfheinrich/pre-commit