Skip to content
Snippets Groups Projects
Commit ebe39681 authored by Danny Marc Rotscher's avatar Danny Marc Rotscher
Browse files

Merge branch 'ci-grep-for-forbidden-words' into 'preview'

Added checks for forbidden words (according to rules).

Closes #13 und #42

See merge request !259
parents b4ea9033 d9511330
No related branches found
No related tags found
3 merge requests!322Merge preview into main,!319Merge preview into main,!259Added checks for forbidden words (according to rules).
......@@ -27,6 +27,13 @@ Test mkdocs:
stage: test
script: docker run ${DOCKER_IMAGE}
Check wording of changed md-files:
stage: test
script:
- docker run --rm -w /src -e CI_MERGE_REQUEST_TARGET_BRANCH_NAME "${DOCKER_IMAGE}"
doc.zih.tu-dresden.de/util/grep-forbidden-words.sh
only: [ merge_requests ]
Lint changed md-files:
stage: test
script:
......
#!/bin/bash
set -euo pipefail
branch="preview"
if [ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then
branch="origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
fi
any_fails=false
files=$(git diff --name-only "$(git merge-base HEAD "$branch")")
for f in $files; do
if [ "$f" != doc.zih.tu-dresden.de/README.md -a "${f: -3}" == ".md" ]; then
#The following checks assume that grep signals success when it finds something,
#while it signals failure if it doesn't find something.
#We assume that we are successful if we DON'T find the pattern,
#which is the other way around, hence the "!".
echo "Checking wording of $f: IO"
#io must be the whole word
if ! grep -n -i '\<io\>' "$f" | grep -v '\.io'; then
any_fails=true
fi
echo "Checking wording of $f: SLURM"
#SLURM must be the whole word, otherwise it might match script variables
#such as SLURM_JOB_ID
if ! grep -n '\<SLURM\>' "$f"; then
any_fails=true
fi
echo "Checking wording of $f: file system"
#arbitrary white space in between
if ! grep -n -i 'file \+system' "$f"; then
any_fails=true
fi
#check for word taurus, except when used in conjunction with .hrsk or /taurus,
#which might appear in code snippets
echo "Checking wording of $f: taurus"
if ! grep -n -i '\<taurus\>' "$f" | grep -v 'taurus\.hrsk' | grep -v '/taurus'; then
any_fails=true
fi
echo "Checking wording of $f: hrskii"
if ! grep -n -i '\<hrskii\>' "$f"; then
any_fails=true
fi
echo "Checking wording of $f: hpc system"
if ! grep -n -i 'hpc \+system' "$f"; then
any_fails=true
fi
echo "Checking wording of $f: hpc-da"
if ! grep -n -i 'hpc[ -]\+da\>' "$f"; then
any_fails=true
fi
fi
done
if [ "$any_fails" == true ]; then
exit 1
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment