From 54e41d04f7f46291aa8a21fd918337a09b65eafa Mon Sep 17 00:00:00 2001 From: NorseGaud Date: Sun, 6 Mar 2022 11:37:49 -0500 Subject: [PATCH 1/5] removed Darwin specific code and modified the docs to indicate macOS is not supported --- docs/content/contributing/tests.md | 14 +++++--------- setup.sh | 8 -------- test/linting/lint.sh | 12 ++---------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/docs/content/contributing/tests.md b/docs/content/contributing/tests.md index aa4456cf..4192a6fd 100644 --- a/docs/content/contributing/tests.md +++ b/docs/content/contributing/tests.md @@ -5,13 +5,9 @@ title: 'Contributing | Tests' 1. Install docker 2. Execute `git submodule update --init --recursive` 3. Install jq - - !!! info "MacOS Specific (needed for tests)" - - ```bash - brew install coreutils - # bash >= 4.0 for associative arrays - brew install bash - ``` - 4. Execute `make clean all` + + +!!! info "Can I use MacOS?" + + We do not support running linting, tests, etc on macOS at this time. Please use a linux VM. \ No newline at end of file diff --git a/setup.sh b/setup.sh index 8dd22b41..02f3a953 100755 --- a/setup.sh +++ b/setup.sh @@ -88,14 +88,6 @@ function _show_local_usage function _get_absolute_script_directory { - if [[ "$(uname)" == 'Darwin' ]] - then - readlink() { - # requires coreutils - greadlink "${@:+$@}" - } - fi - if dirname "$(readlink -f "${0}")" &>/dev/null then DIR="$(dirname "$(readlink -f "${0}")")" diff --git a/test/linting/lint.sh b/test/linting/lint.sh index 2cace83a..c7e6d235 100755 --- a/test/linting/lint.sh +++ b/test/linting/lint.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#! /bin/bash # version v0.2.0 unstable # executed by Make during CI or manually @@ -6,12 +6,6 @@ SCRIPT="lint.sh" -if [[ "$(uname)" == "Darwin" ]] -then - readlink() { - greadlink "${@:+$@}" # Requires coreutils - } -fi SCRIPT_DIR=$(dirname "$(readlink -f "$0")") REPO_ROOT="$(realpath "${SCRIPT_DIR}"/../../)" @@ -104,10 +98,8 @@ function _shellcheck -not -path './test/test_helper/*' \ -not -path './target/docker-configomat/*' )" - # macOS lacks parity for `-executable` but presently produces the same results: https://stackoverflow.com/a/4458361 - [[ "$(uname)" == "Darwin" ]] && FIND_EXEC="-perm -711" || FIND_EXEC="-executable" # shellcheck disable=SC2248 - F_BIN="$(find 'target/bin' ${FIND_EXEC} -type f)" + F_BIN="$(find 'target/bin' -executable -type f)" F_BATS="$(find 'test' -maxdepth 1 -type f -iname '*.bats')" # This command is a bit easier to grok as multi-line. From c56db1380ef22a506154396e0ec2974f8a2f6ce7 Mon Sep 17 00:00:00 2001 From: NorseGaud Date: Sun, 6 Mar 2022 13:37:07 -0500 Subject: [PATCH 2/5] only shellcheck shell scripts --- test/linting/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linting/lint.sh b/test/linting/lint.sh index c7e6d235..b2071b30 100755 --- a/test/linting/lint.sh +++ b/test/linting/lint.sh @@ -99,7 +99,7 @@ function _shellcheck -not -path './target/docker-configomat/*' )" # shellcheck disable=SC2248 - F_BIN="$(find 'target/bin' -executable -type f)" + F_BIN="$(grep -l /bin/bash target/bin/*)" F_BATS="$(find 'test' -maxdepth 1 -type f -iname '*.bats')" # This command is a bit easier to grok as multi-line. From 3be5879fcf4e67307af200e0de0209f6ade96f4d Mon Sep 17 00:00:00 2001 From: NorseGaud Date: Sun, 6 Mar 2022 13:37:34 -0500 Subject: [PATCH 3/5] prevent piling up build intermediate containers --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8987763..2d8d2494 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ VCS_VER = $(shell git describe --tags --contains --always) all: lint build backup generate-accounts tests clean build: - docker build -t $(NAME) . --build-arg VCS_VER=$(VCS_VER) --build-arg VCS_REF=$(VCS_REF) + docker build --force-rm -t $(NAME) . --build-arg VCS_VER=$(VCS_VER) --build-arg VCS_REF=$(VCS_REF) backup: # if backup directories exist, clean hasn't been called, therefore From 1ab8ea96b234fbd1de6df9da69f80fb49cfe1d22 Mon Sep 17 00:00:00 2001 From: NorseGaud Date: Sun, 6 Mar 2022 21:11:46 -0500 Subject: [PATCH 4/5] acme_extract -> acme_extract.py + F_BIN to avoid .py --- Makefile | 2 +- target/bin/{acme_extract => acme_extract.py} | 0 target/bin/print-environment | 0 target/bin/setup | 0 target/scripts/helpers/ssl.sh | 4 ++-- test/linting/lint.sh | 2 +- 6 files changed, 4 insertions(+), 4 deletions(-) rename target/bin/{acme_extract => acme_extract.py} (100%) mode change 100644 => 100755 target/bin/print-environment mode change 100644 => 100755 target/bin/setup diff --git a/Makefile b/Makefile index 2d8d2494..e8987763 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ VCS_VER = $(shell git describe --tags --contains --always) all: lint build backup generate-accounts tests clean build: - docker build --force-rm -t $(NAME) . --build-arg VCS_VER=$(VCS_VER) --build-arg VCS_REF=$(VCS_REF) + docker build -t $(NAME) . --build-arg VCS_VER=$(VCS_VER) --build-arg VCS_REF=$(VCS_REF) backup: # if backup directories exist, clean hasn't been called, therefore diff --git a/target/bin/acme_extract b/target/bin/acme_extract.py similarity index 100% rename from target/bin/acme_extract rename to target/bin/acme_extract.py diff --git a/target/bin/print-environment b/target/bin/print-environment old mode 100644 new mode 100755 diff --git a/target/bin/setup b/target/bin/setup old mode 100644 new mode 100755 diff --git a/target/scripts/helpers/ssl.sh b/target/scripts/helpers/ssl.sh index dc401e22..7731e6d8 100644 --- a/target/scripts/helpers/ssl.sh +++ b/target/scripts/helpers/ssl.sh @@ -418,8 +418,8 @@ function _extract_certs_from_acme fi local KEY CERT - KEY=$(acme_extract /etc/letsencrypt/acme.json "${CERT_DOMAIN}" --key) - CERT=$(acme_extract /etc/letsencrypt/acme.json "${CERT_DOMAIN}" --cert) + KEY=$(acme_extract.py /etc/letsencrypt/acme.json "${CERT_DOMAIN}" --key) + CERT=$(acme_extract.py /etc/letsencrypt/acme.json "${CERT_DOMAIN}" --cert) if [[ -z ${KEY} ]] || [[ -z ${CERT} ]] then diff --git a/test/linting/lint.sh b/test/linting/lint.sh index b2071b30..b67e6c5f 100755 --- a/test/linting/lint.sh +++ b/test/linting/lint.sh @@ -99,7 +99,7 @@ function _shellcheck -not -path './target/docker-configomat/*' )" # shellcheck disable=SC2248 - F_BIN="$(grep -l /bin/bash target/bin/*)" + F_BIN="$(find 'target/bin' -type f -not -name '*.py')" F_BATS="$(find 'test' -maxdepth 1 -type f -iname '*.bats')" # This command is a bit easier to grok as multi-line. From 66cf4f3a54fd26f551bc6feb1a12c92bb98adcf5 Mon Sep 17 00:00:00 2001 From: NorseGaud Date: Tue, 8 Mar 2022 18:30:29 -0500 Subject: [PATCH 5/5] ${@:+$@} -> ${@} --- setup.sh | 8 ++++---- test/linting/lint.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index 02f3a953..ccaed653 100755 --- a/setup.sh +++ b/setup.sh @@ -146,7 +146,7 @@ function _run_in_new_container ${CRI} run --rm "${USE_TTY}" \ -v "${CONFIG_PATH}:${DMS_CONFIG}${USE_SELINUX}" \ - "${IMAGE_NAME}" "${@:+$@}" + "${IMAGE_NAME}" "${@}" } function _main @@ -226,9 +226,9 @@ function _main if [[ -n ${CONTAINER_NAME} ]] then - ${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" setup "${@:+$@}" + ${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" setup "${@}" else - _run_in_new_container setup "${@:+$@}" + _run_in_new_container setup "${@}" fi [[ ${1} == 'help' ]] && _show_local_usage @@ -236,4 +236,4 @@ function _main return 0 } -_main "${@:+$@}" +_main "${@}" diff --git a/test/linting/lint.sh b/test/linting/lint.sh index b67e6c5f..c7e125f8 100755 --- a/test/linting/lint.sh +++ b/test/linting/lint.sh @@ -52,7 +52,7 @@ function __log_success function __in_path { - command -v "${@:+$@}" &>/dev/null && return 0 ; return 1 ; + command -v "${@}" &>/dev/null && return 0 ; return 1 ; } function _eclint @@ -156,4 +156,4 @@ function __main esac } -__main "${@:+$@}" || exit ${?} +__main "${@}" || exit ${?}