mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -04:00
precommit: Switch from markdownlint to mdformat
This commit is contained in:
parent
f95d3a4a5d
commit
786bc82ff9
35 changed files with 266 additions and 579 deletions
|
|
@ -4,23 +4,25 @@ The precommit system consists of the following tools that analyze and format the
|
|||
source code:
|
||||
|
||||
- [doxify](../doxify/)
|
||||
to add Doxygen templates.
|
||||
to add Doxygen templates.
|
||||
- [prettify](../prettify/)
|
||||
to format Fortran files.
|
||||
to format Fortran files.
|
||||
- [analyze_src](../conventions/analyze_src.py)
|
||||
to check copyright banners and a few other things.
|
||||
to check copyright banners and a few other things.
|
||||
- [ast.parse](https://docs.python.org/3/library/ast.html)
|
||||
to check Python syntax.
|
||||
to check Python syntax.
|
||||
- [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
|
||||
to format C and Cuda files.
|
||||
to format C and Cuda files.
|
||||
- [black](https://github.com/psf/black)
|
||||
to format Python scripts.
|
||||
to format Python scripts.
|
||||
- [shfmt](https://github.com/mvdan/sh)
|
||||
to format Shell scripts.
|
||||
to format Shell scripts.
|
||||
- [shellcheck](https://github.com/koalaman/shellcheck)
|
||||
to analyze Shell scripts.
|
||||
- [markdownlint](https://github.com/DavidAnson/markdownlint)
|
||||
to analyze Markdown files.
|
||||
to analyze Shell scripts.
|
||||
- [mdformat](https://github.com/executablebooks/mdformat) with [gfm plugin](https://github.com/hukkin/mdformat-gfm)
|
||||
to format Markdown scripts.
|
||||
- [cmake-format](https://github.com/cheshirekow/cmake_format)
|
||||
to format CMake scripts.
|
||||
|
||||
In contrast to the [CP2K-CI](https://github.com/cp2k/cp2k-ci) these tools
|
||||
process each file individually, which makes them much more lightweight.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ apt-get install -qq --no-install-recommends \
|
|||
git \
|
||||
less \
|
||||
nano \
|
||||
npm \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-wheel \
|
||||
|
|
@ -22,14 +21,9 @@ apt-get install -qq --no-install-recommends \
|
|||
wget
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install markdownlint-cli and dependencies.
|
||||
# https://github.com/DavidAnson/markdownlint
|
||||
# https://github.com/igorshubovych/markdownlint-cli
|
||||
npm install .
|
||||
ln -s /opt/cp2k-precommit/node_modules/markdownlint-cli/markdownlint.js /usr/bin/markdownlint
|
||||
|
||||
# Install black, flask, gunicorn, and dependencies.
|
||||
# https://github.com/psf/black
|
||||
# Install Python packages. Upgrade via:
|
||||
# pip3 install black flask gunicorn mdformat-gfm cmake-format
|
||||
# pip3 freeze > requirements.txt
|
||||
pip3 install --quiet -r requirements.txt
|
||||
|
||||
# Install shfmt.
|
||||
|
|
|
|||
257
tools/precommit/package-lock.json
generated
257
tools/precommit/package-lock.json
generated
|
|
@ -1,257 +0,0 @@
|
|||
{
|
||||
"name": "cp2k-precommit",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"requires": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
|
||||
"integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
|
||||
"requires": {
|
||||
"graceful-readlink": ">= 1.0.0"
|
||||
}
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"deep-extend": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.1.tgz",
|
||||
"integrity": "sha512-N8vBdOa+DF7zkRrDCsaOXoCs/E2fJfx9B9MrKnnSiHNh4ws7eSys6YQE4KvT1cecKmOASYQBhbKjeuDD9lT81w=="
|
||||
},
|
||||
"entities": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz",
|
||||
"integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ=="
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz",
|
||||
"integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"graceful-readlink": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
|
||||
"integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU="
|
||||
},
|
||||
"ignore": {
|
||||
"version": "5.1.8",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
|
||||
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw=="
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
|
||||
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"jsonc-parser": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.2.1.tgz",
|
||||
"integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w=="
|
||||
},
|
||||
"linkify-it": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz",
|
||||
"integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==",
|
||||
"requires": {
|
||||
"uc.micro": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"lodash.differencewith": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.differencewith/-/lodash.differencewith-4.5.0.tgz",
|
||||
"integrity": "sha1-uvr7yRi1UVTheRdqALsK76rIVLc="
|
||||
},
|
||||
"lodash.flatten": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
|
||||
"integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8="
|
||||
},
|
||||
"markdown-it": {
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz",
|
||||
"integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==",
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"entities": "~2.0.0",
|
||||
"linkify-it": "^2.0.0",
|
||||
"mdurl": "^1.0.1",
|
||||
"uc.micro": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"markdownlint": {
|
||||
"version": "0.20.4",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.20.4.tgz",
|
||||
"integrity": "sha512-jpfaPgjT0OpeBbemjYNZbzGG3hCLcAIvrm/pEY3+q/szDScG6ZonDacqySVRJAv9glbo8y4wBPJ0wgW17+9GGA==",
|
||||
"requires": {
|
||||
"markdown-it": "10.0.0"
|
||||
}
|
||||
},
|
||||
"markdownlint-cli": {
|
||||
"version": "0.23.2",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.23.2.tgz",
|
||||
"integrity": "sha512-OSl5OZ8xzGN6z355cqRkiq67zPi3reJimklaF72p0554q85Dng5ToOjjSB9tDKZebSt85jX8cp+ruoQlPqOsPA==",
|
||||
"requires": {
|
||||
"commander": "~2.9.0",
|
||||
"deep-extend": "~0.5.1",
|
||||
"get-stdin": "~5.0.1",
|
||||
"glob": "~7.1.2",
|
||||
"ignore": "~5.1.4",
|
||||
"js-yaml": "~3.13.1",
|
||||
"jsonc-parser": "~2.2.0",
|
||||
"lodash.differencewith": "~4.5.0",
|
||||
"lodash.flatten": "~4.4.0",
|
||||
"markdownlint": "~0.20.4",
|
||||
"markdownlint-rule-helpers": "~0.11.0",
|
||||
"minimatch": "~3.0.4",
|
||||
"minimist": "~1.2.5",
|
||||
"rc": "~1.2.7"
|
||||
}
|
||||
},
|
||||
"markdownlint-rule-helpers": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.11.0.tgz",
|
||||
"integrity": "sha512-PhGii9dOiDJDXxiRMpK8N0FM9powprvRPsXALgkjlSPTwLh6ymH+iF3iUe3nq8KGu26tclFBlLL5xAGy/zb7FA=="
|
||||
},
|
||||
"mdurl": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
|
||||
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"rc": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
|
||||
"integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
|
||||
"requires": {
|
||||
"deep-extend": "^0.6.0",
|
||||
"ini": "~1.3.0",
|
||||
"minimist": "^1.2.0",
|
||||
"strip-json-comments": "~2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"deep-extend": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
||||
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo="
|
||||
},
|
||||
"uc.micro": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
|
||||
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA=="
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name": "cp2k-precommit",
|
||||
"version": "1.0.0",
|
||||
"description": "Tools used by the cp2k-precomit system",
|
||||
"main": "index.js",
|
||||
"repository": "",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": ""
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"markdownlint-cli": "^0.23.2"
|
||||
}
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ def process_file(fn: str, allow_modifications: bool) -> None:
|
|||
run_remote_tool("shellcheck", fn)
|
||||
|
||||
if re.match(r".*\.md$", fn):
|
||||
run_remote_tool("markdownlint", fn)
|
||||
run_remote_tool("mdformat", fn)
|
||||
|
||||
if re.match(r"(.*/CMakeLists.txt)|(.*\.cmake)$", fn):
|
||||
run_remote_tool("cmakeformat", fn)
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ def shellcheck():
|
|||
|
||||
|
||||
# ======================================================================================
|
||||
@app.route("/markdownlint", methods=["POST"])
|
||||
def markdownlint():
|
||||
return run_tool(["markdownlint"])
|
||||
@app.route("/mdformat", methods=["POST"])
|
||||
@app.route("/markdownlint", methods=["POST"]) # for backwards compatibility
|
||||
def mdformat():
|
||||
return run_tool(["mdformat"])
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
appdirs==1.4.4
|
||||
attrs==21.4.0
|
||||
black==22.3.0
|
||||
black==22.10.0
|
||||
click==8.1.3
|
||||
cmake-format==0.6.13
|
||||
cmakelang==0.6.13
|
||||
Flask==2.1.2
|
||||
Flask==2.2.2
|
||||
gunicorn==20.1.0
|
||||
gyp==0.1
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
linkify-it-py==1.0.3
|
||||
markdown-it-py==2.1.0
|
||||
MarkupSafe==2.1.1
|
||||
mdformat==0.7.16
|
||||
mdformat-gfm==0.3.5
|
||||
mdformat_tables==0.4.1
|
||||
mdit-py-plugins==0.3.1
|
||||
mdurl==0.1.2
|
||||
mypy-extensions==0.4.3
|
||||
pathspec==0.9.0
|
||||
pathspec==0.10.1
|
||||
platformdirs==2.5.2
|
||||
regex==2022.4.24
|
||||
six==1.16.0
|
||||
toml==0.10.2
|
||||
tomli==2.0.1
|
||||
typed-ast==1.5.3
|
||||
Werkzeug==2.1.2
|
||||
uc-micro-py==1.0.1
|
||||
Werkzeug==2.2.2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue