From 4b7b9ab5036de2c38bc0dc55c6312cc99c3ed7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Tue, 16 Feb 2021 08:49:08 +0100 Subject: [PATCH] Initial repository structure --- .gitlab-ci.yml | 14 ++++++++++++++ README.md | 13 +++++++++++++ scripts/run-manpage-checks.sh | 15 +++++++++++++++ scripts/run-shellcheck.sh | 29 +++++++++++++++++++++++++++++ type/.keep | 0 5 files changed, 71 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 README.md create mode 100755 scripts/run-manpage-checks.sh create mode 100755 scripts/run-shellcheck.sh create mode 100644 type/.keep 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