commit 4b7b9ab5036de2c38bc0dc55c6312cc99c3ed7ca Author: Timothée Floure Date: Tue Feb 16 08:49:08 2021 +0100 Initial repository structure diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d90da1e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +stages: + - test + +image: code.ungleich.ch:5050/ungleich-public/cdist-contrib/ci-container:latest + +shellcheck: + stage: test + script: + - ./scripts/run-shellcheck.sh + +manpages: + stage: test + script: + - ./scripts/run-manpage-checks.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..c516dba --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# ungleich CDIST types + +The repository contains [cdist](https://www.cdi.st/) types used to define the +ungleich infrastructure. They usually are called from the +[cdist-workdir](https://code.ungleich.ch/ungleich-intern/cdist-workdir) +repository. + +The types in this repository must comply with the +[cdist-contrib](https://code.ungleich.ch/ungleich-public/cdist-contrib) +guidelines (manpage must be present, shellcheck-compliant, etc.). + +Unless specified otherwise, the content of this repository is licensed under +the GPLv3. diff --git a/scripts/run-manpage-checks.sh b/scripts/run-manpage-checks.sh new file mode 100755 index 0000000..828179b --- /dev/null +++ b/scripts/run-manpage-checks.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Move to top-level cdist-contrib directory. +cd $(dirname $0)/.. + +# Check that each type has a man page. +status=0 +for t in type/*; do + if [ ! -f "$t/man.rst" ]; then + echo "No manpage for type $t!" + status=1 + fi +done + +exit $status diff --git a/scripts/run-shellcheck.sh b/scripts/run-shellcheck.sh new file mode 100755 index 0000000..d6c2db6 --- /dev/null +++ b/scripts/run-shellcheck.sh @@ -0,0 +1,29 @@ +#!/bin/sh -eu + +SHELLCHECKCMD='shellcheck -s sh -f gcc -x' +# Skip SC2154 for variables starting with __ since such variables are cdist +# environment variables. +SHELLCHECK_SKIP=': __.*is referenced but not assigned.*\[SC2154\]' +SHELLCHECKTMP='.shellcheck.tmp' + +# Move to top-level cdist-contrib directory. +cd "$(dirname $0)"/.. + +check() { + find type/ -type f "$@" -exec ${SHELLCHECKCMD} {} + \ + | grep -v "${SHELLCHECK_SKIP}" >>"${SHELLCHECKTMP}" || true +} + +rm -f "${SHELLCHECKTMP}" + +check -path '*/explorer/*' +check -path '*/files/*' -name '*.sh' +check -name manifest +check -name gencode-local +check -name gencode-remote + +if test -s "${SHELLCHECKTMP}" +then + cat "${SHELLCHECKTMP}" >&2 + exit 1 +fi diff --git a/type/.keep b/type/.keep new file mode 100644 index 0000000..e69de29