Add pre-commit hook (#1071)
This commit is contained in:
parent
5a2b8f7ff9
commit
2db70c96ed
|
@ -152,12 +152,6 @@ yarn lint:
|
||||||
script:
|
script:
|
||||||
- yarn lint
|
- yarn lint
|
||||||
|
|
||||||
check-editorconfig:
|
|
||||||
image: mstruebing/editorconfig-checker
|
|
||||||
stage: validate
|
|
||||||
script:
|
|
||||||
- ec -v
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build
|
# Build
|
||||||
#
|
#
|
||||||
|
@ -175,7 +169,6 @@ build-image:
|
||||||
<<: *container_definition
|
<<: *container_definition
|
||||||
stage: build
|
stage: build
|
||||||
needs:
|
needs:
|
||||||
- check-editorconfig
|
|
||||||
- phpcs
|
- phpcs
|
||||||
- phpstan
|
- phpstan
|
||||||
- composer validate
|
- composer validate
|
||||||
|
|
|
@ -38,13 +38,23 @@ The following instructions explain how to get, build and run the latest Engelsys
|
||||||
find resources/lang/ -type f -name '*.po' -exec sh -c 'file="{}"; msgfmt "${file%.*}.po" -o "${file%.*}.mo"' \;
|
find resources/lang/ -type f -name '*.po' -exec sh -c 'file="{}"; msgfmt "${file%.*}.po" -o "${file%.*}.mo"' \;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Git setup (optional, recommended)
|
## Pre-commit hooks
|
||||||
Ignore mass-changes like code formatting in Git blame:
|
You should set up the pre-commit hook to check the code style and run tests on commit:
|
||||||
|
|
||||||
```bash
|
Docker (recommended):
|
||||||
git config blame.ignoreRevsFile .git-blame-ignore-revs
|
|
||||||
|
```sh
|
||||||
|
echo "docker exec engelsystem_dev-es_workspace-1 bin/pre-commit" > .git/hooks/pre-commit
|
||||||
|
chmod u+x .git/hooks/pre-commit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Host machine:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln -s ../../bin/pre-commit .git/hooks/pre-commit
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
To run the unit tests use
|
To run the unit tests use
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# immediate exit after an error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
yarn check
|
||||||
|
yarn lint
|
||||||
|
|
||||||
|
composer validate
|
||||||
|
composer phpcs
|
||||||
|
composer phpstan
|
||||||
|
./vendor/bin/phpunit
|
|
@ -9,9 +9,10 @@
|
||||||
"build": "NODE_ENV=production yarn build:webpack",
|
"build": "NODE_ENV=production yarn build:webpack",
|
||||||
"build:webpack": "webpack",
|
"build:webpack": "webpack",
|
||||||
"build:watch": "webpack --watch",
|
"build:watch": "webpack --watch",
|
||||||
"lint": "yarn lint:eslint && yarn lint:prettier",
|
"lint": "yarn lint:eslint && yarn lint:prettier && yarn lint:ec",
|
||||||
"lint:eslint": "eslint .",
|
"lint:eslint": "eslint .",
|
||||||
"lint:prettier": "prettier --check resources/assets",
|
"lint:prettier": "prettier --check resources/assets",
|
||||||
|
"lint:ec": "ec --exclude \"node_modules|vendor|public/assets|.git\"",
|
||||||
"lint:fix": "yarn lint:fix:eslint && yarn lint:fix:prettier",
|
"lint:fix": "yarn lint:fix:eslint && yarn lint:fix:prettier",
|
||||||
"lint:fix:eslint": "eslint --fix .",
|
"lint:fix:eslint": "eslint --fix .",
|
||||||
"lint:fix:prettier": "prettier --write resources/assets"
|
"lint:fix:prettier": "prettier --write resources/assets"
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
"bootstrap-icons": "^1.10.2",
|
"bootstrap-icons": "^1.10.2",
|
||||||
"css-loader": "^6.7.2",
|
"css-loader": "^6.7.2",
|
||||||
"css-minimizer-webpack-plugin": "^3.4.1",
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
||||||
|
"editorconfig-checker": "^5.0.1",
|
||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
"eslint-plugin-editorconfig": "^4.0.2",
|
"eslint-plugin-editorconfig": "^4.0.2",
|
||||||
"mini-css-extract-plugin": "^2.7.0",
|
"mini-css-extract-plugin": "^2.7.0",
|
||||||
|
|
|
@ -1762,6 +1762,11 @@ domutils@^2.8.0:
|
||||||
domelementtype "^2.2.0"
|
domelementtype "^2.2.0"
|
||||||
domhandler "^4.2.0"
|
domhandler "^4.2.0"
|
||||||
|
|
||||||
|
editorconfig-checker@^5.0.1:
|
||||||
|
version "5.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/editorconfig-checker/-/editorconfig-checker-5.0.1.tgz#cb4bf7a9b80f1b63b141b8897d7cc326fce0d3ae"
|
||||||
|
integrity sha512-6hXq9VVDkyCxVYKdGtIj+yhVR1fi/6W6Ykz/+kItLPARulJvr2/VXgWZ5OGWx1UYm2RD6XOzWyx1JF6DLgQ/8Q==
|
||||||
|
|
||||||
editorconfig@^0.15.0:
|
editorconfig@^0.15.0:
|
||||||
version "0.15.3"
|
version "0.15.3"
|
||||||
resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5"
|
resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5"
|
||||||
|
|
Loading…
Reference in New Issue