Updated ShellCheck to 0.8.0 and Hadolint to 2.8.0 (#2329)

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
Georg Lauterbach 2021-12-19 11:56:22 +01:00 committed by GitHub
parent 6d06149581
commit 99cc9fec2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 35 additions and 28 deletions

View file

@ -55,12 +55,13 @@ jobs:
- name: 'Prepare artifact for transfer' - name: 'Prepare artifact for transfer'
run: | run: |
# Save ENV for transfer # Save ENV for transfer
echo "PR_HEADSHA=${{ github.event.pull_request.head.sha }}" >> pr.env {
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> pr.env echo "PR_HEADSHA=${{ github.event.pull_request.head.sha }}"
echo "PR_TITLE=${{ github.event.pull_request.title }}" >> pr.env echo "PR_NUMBER=${{ github.event.pull_request.number }}"
echo "NETLIFY_SITE_PREFIX=${{ env.NETLIFY_SITE_PREFIX }}" >> pr.env echo "PR_TITLE=${{ github.event.pull_request.title }}"
echo "BUILD_DIR=${{ env.BUILD_DIR }}" >> pr.env echo "NETLIFY_SITE_PREFIX=${{ env.NETLIFY_SITE_PREFIX }}"
echo "BUILD_DIR=${{ env.BUILD_DIR }}"
} >> pr.env
tar --zstd -cf artifact.tar.zst pr.env ${{ env.BUILD_DIR }} tar --zstd -cf artifact.tar.zst pr.env ${{ env.BUILD_DIR }}
- name: 'Upload artifact for workflow transfer' - name: 'Upload artifact for workflow transfer'

View file

@ -36,5 +36,5 @@ jobs:
- a maintainer removes the `meta/stale` label or adds the `stale-bot/ignore` label - a maintainer removes the `meta/stale` label or adds the `stale-bot/ignore` label
- new activity occurs, such as a new comment - new activity occurs, such as a new comment
close-pr-label: "meta/closed due to age or inactivity" close-pr-label: "meta/closed due to age or inactivity"
closed-pr-message: > close-pr-message: >
This PR was closed due to inactivity. This PR was closed due to inactivity.

View file

@ -26,7 +26,7 @@ jobs:
run: | run: |
make shellcheck make shellcheck
env: env:
SHELLCHECK_VERSION: 0.7.2 SHELLCHECK_VERSION: 0.8.0
- name: ECLint - name: ECLint
run: | run: |

View file

@ -26,6 +26,7 @@ LBLUE="\e[94m"
RESET="\e[0m" RESET="\e[0m"
set -euEo pipefail set -euEo pipefail
shopt -s inherit_errexit
trap '__err "${BASH_SOURCE}" "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR trap '__err "${BASH_SOURCE}" "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR
function __err function __err

View file

@ -8,7 +8,7 @@
function dovecot_quota_to_hr() function dovecot_quota_to_hr()
{ {
if [ "${1}" == "-" ] if [[ ${1} == "-" ]]
then then
echo "~" echo "~"
else else

View file

@ -35,7 +35,8 @@ fi
create_lock # Protect config file with lock to avoid race conditions create_lock # Protect config file with lock to avoid race conditions
touch "${DATABASE}" touch "${DATABASE}"
if [ -z "${QUOTA}" ]; then if [[ -z ${QUOTA} ]]
then
read -r -s "Enter quota (e.g. 10M): " QUOTA read -r -s "Enter quota (e.g. 10M): " QUOTA
echo echo
[[ -z "${QUOTA}" ]] && errex "Quota must not be empty. Use 0 for unlimited quota" [[ -z "${QUOTA}" ]] && errex "Quota must not be empty. Use 0 for unlimited quota"

View file

@ -54,7 +54,7 @@ do
# 0 files are identical # 0 files are identical
# 1 files differ # 1 files differ
# 2 inaccessible or missing argument # 2 inaccessible or missing argument
if [ $? -eq 1 ] if [[ ${?} -eq 1 ]]
then then
_notify 'inf' "$(_log_date) Change detected" _notify 'inf' "$(_log_date) Change detected"
create_lock # Shared config safety lock create_lock # Shared config safety lock

View file

@ -69,7 +69,7 @@ function _populate_relayhost_map
# note: won't detect domains when lhs has spaces (but who does that?!) # note: won't detect domains when lhs has spaces (but who does that?!)
sed -n '/^\s*[^#[:space:]]/ s/^[^@|]*@\([^|]\+\)|.*$/\1/p' /tmp/docker-mailserver/postfix-accounts.cf sed -n '/^\s*[^#[:space:]]/ s/^[^@|]*@\([^|]\+\)|.*$/\1/p' /tmp/docker-mailserver/postfix-accounts.cf
[ -f /tmp/docker-mailserver/postfix-virtual.cf ] && sed -n '/^\s*[^#[:space:]]/ s/^\s*[^@[:space:]]*@\(\S\+\)\s.*/\1/p' /tmp/docker-mailserver/postfix-virtual.cf [[ -f /tmp/docker-mailserver/postfix-virtual.cf ]] && sed -n '/^\s*[^#[:space:]]/ s/^\s*[^@[:space:]]*@\(\S\+\)\s.*/\1/p' /tmp/docker-mailserver/postfix-virtual.cf
} | while read -r DOMAIN } | while read -r DOMAIN
do do
# DOMAIN not already present *and* not ignored # DOMAIN not already present *and* not ignored

View file

@ -15,11 +15,12 @@ fi
SCRIPT_DIR=$(dirname "$(readlink -f "$0")") SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
REPO_ROOT="$(realpath "${SCRIPT_DIR}"/../../)" REPO_ROOT="$(realpath "${SCRIPT_DIR}"/../../)"
HADOLINT_VERSION=2.4.1 HADOLINT_VERSION=2.8.0
ECLINT_VERSION=2.3.5 ECLINT_VERSION=2.3.5
SHELLCHECK_VERSION=0.7.2 SHELLCHECK_VERSION=0.8.0
set -eEuo pipefail set -eEuo pipefail
shopt -s inherit_errexit
trap '__log_err "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" ${LINENO:-?} ${?:-?}' ERR trap '__log_err "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" ${LINENO:-?} ${?:-?}' ERR
function __log_err function __log_err
@ -121,6 +122,9 @@ function _shellcheck
--wiki-link-count=50 --wiki-link-count=50
--enable=all --enable=all
--exclude=SC2154 --exclude=SC2154
--exclude=SC2310
--exclude=SC2311
--exclude=SC2312
--source-path=SCRIPTDIR --source-path=SCRIPTDIR
"${F_SH} ${F_BIN} ${F_BATS}" "${F_SH} ${F_BIN} ${F_BATS}"
) )

View file

@ -68,7 +68,7 @@ function teardown_file() {
run docker exec mail_smtponly /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/smtp-only.txt" run docker exec mail_smtponly /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/smtp-only.txt"
assert_success assert_success
run docker exec mail_smtponly /bin/sh -c 'grep -cE "to=<user2\@external.tld>.*status\=sent" /var/log/mail/mail.log' run docker exec mail_smtponly /bin/sh -c 'grep -cE "to=<user2\@external.tld>.*status\=sent" /var/log/mail/mail.log'
[ "${status}" -ge 0 ] [[ ${status} -ge 0 ]]
} }
# #

View file

@ -58,5 +58,5 @@ teardown() {
assert_output --partial "250 2.0.0 Ok: queued as " assert_output --partial "250 2.0.0 Ok: queued as "
repeat_until_success_or_timeout 60 run docker exec mail_smtponly_second_network /bin/sh -c 'grep -cE "to=<user2\@external.tld>.*status\=sent" /var/log/mail/mail.log' repeat_until_success_or_timeout 60 run docker exec mail_smtponly_second_network /bin/sh -c 'grep -cE "to=<user2\@external.tld>.*status\=sent" /var/log/mail/mail.log'
[ "${status}" -ge 0 ] [[ ${status} -ge 0 ]]
} }

View file

@ -614,7 +614,7 @@ EOF
run docker exec mail /bin/sh -c "grep '^user3@domain\.tld|' -i /tmp/docker-mailserver/postfix-accounts.cf" run docker exec mail /bin/sh -c "grep '^user3@domain\.tld|' -i /tmp/docker-mailserver/postfix-accounts.cf"
assert_success assert_success
[ -n "${output}" ] [[ -n ${output} ]]
} }
@test "checking accounts: auser3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf" { @test "checking accounts: auser3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf" {
@ -622,7 +622,7 @@ EOF
run docker exec mail /bin/sh -c "grep '^auser3@domain\.tld|' -i /tmp/docker-mailserver/postfix-accounts.cf" run docker exec mail /bin/sh -c "grep '^auser3@domain\.tld|' -i /tmp/docker-mailserver/postfix-accounts.cf"
assert_success assert_success
[ -n "${output}" ] [[ -n ${output} ]]
} }
@test "checking accounts: a.ser3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf" { @test "checking accounts: a.ser3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf" {
@ -630,7 +630,7 @@ EOF
run docker exec mail /bin/sh -c "grep '^a\.ser3@domain\.tld|' -i /tmp/docker-mailserver/postfix-accounts.cf" run docker exec mail /bin/sh -c "grep '^a\.ser3@domain\.tld|' -i /tmp/docker-mailserver/postfix-accounts.cf"
assert_success assert_success
[ -n "${output}" ] [[ -n ${output} ]]
} }
@test "checking accounts: user3 should have been removed from /tmp/docker-mailserver/postfix-accounts.cf but not auser3" { @test "checking accounts: user3 should have been removed from /tmp/docker-mailserver/postfix-accounts.cf but not auser3" {
@ -638,11 +638,11 @@ EOF
run docker exec mail /bin/sh -c "grep '^user3@domain\.tld' -i /tmp/docker-mailserver/postfix-accounts.cf" run docker exec mail /bin/sh -c "grep '^user3@domain\.tld' -i /tmp/docker-mailserver/postfix-accounts.cf"
assert_failure assert_failure
[ -z "${output}" ] [[ -z ${output} ]]
run docker exec mail /bin/sh -c "grep '^auser3@domain\.tld' -i /tmp/docker-mailserver/postfix-accounts.cf" run docker exec mail /bin/sh -c "grep '^auser3@domain\.tld' -i /tmp/docker-mailserver/postfix-accounts.cf"
assert_success assert_success
[ -n "${output}" ] [[ -n ${output} ]]
} }
@test "checking user updating password for user in /tmp/docker-mailserver/postfix-accounts.cf" { @test "checking user updating password for user in /tmp/docker-mailserver/postfix-accounts.cf" {
@ -654,7 +654,7 @@ EOF
sleep 2 sleep 2
changepass=$(docker exec mail /bin/sh -c "grep '^user4@domain\.tld' -i /tmp/docker-mailserver/postfix-accounts.cf") changepass=$(docker exec mail /bin/sh -c "grep '^user4@domain\.tld' -i /tmp/docker-mailserver/postfix-accounts.cf")
[ "${initialpass}" != "${changepass}" ] [[ ${initialpass} != "${changepass}" ]]
docker exec mail /bin/sh -c "delmailuser -y auser3@domain.tld" docker exec mail /bin/sh -c "delmailuser -y auser3@domain.tld"
@ -678,7 +678,7 @@ EOF
-v "$(duplicate_config_for_container without-accounts/ without-accounts-deleting-user)":/tmp/docker-mailserver/ \ -v "$(duplicate_config_for_container without-accounts/ without-accounts-deleting-user)":/tmp/docker-mailserver/ \
"${IMAGE_NAME:?}" /bin/sh -c 'delmailuser -y user3@domain.tld' "${IMAGE_NAME:?}" /bin/sh -c 'delmailuser -y user3@domain.tld'
assert_success assert_success
[ -z "${output}" ] [[ -z ${output} ]]
} }
@test "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf even when that file does not exist" { @test "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf even when that file does not exist" {
@ -692,7 +692,7 @@ EOF
-v "${PRIVATE_CONFIG}/without-accounts/":/tmp/docker-mailserver/ \ -v "${PRIVATE_CONFIG}/without-accounts/":/tmp/docker-mailserver/ \
"${IMAGE_NAME:?}" /bin/sh -c 'grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf' "${IMAGE_NAME:?}" /bin/sh -c 'grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf'
assert_success assert_success
[ -n "${output}" ] [[ -n ${output} ]]
} }
@ -956,7 +956,7 @@ EOF
assert_success assert_success
value=$(grep setup_email_add@example.com "$(private_config_path mail)/postfix-accounts.cf" | awk -F '|' '{print $1}') value=$(grep setup_email_add@example.com "$(private_config_path mail)/postfix-accounts.cf" | awk -F '|' '{print $1}')
[ "${value}" = "setup_email_add@example.com" ] [[ ${value} == "setup_email_add@example.com" ]]
assert_success assert_success
wait_for_changes_to_be_detected_in_container mail wait_for_changes_to_be_detected_in_container mail
@ -979,15 +979,15 @@ EOF
assert_success assert_success
initialpass=$(grep lorem@impsum.org "$(private_config_path mail)/postfix-accounts.cf" | awk -F '|' '{print $2}') initialpass=$(grep lorem@impsum.org "$(private_config_path mail)/postfix-accounts.cf" | awk -F '|' '{print $2}')
[ "${initialpass}" != "" ] [[ ${initialpass} != "" ]]
assert_success assert_success
run ./setup.sh -c mail email update lorem@impsum.org my password run ./setup.sh -c mail email update lorem@impsum.org my password
assert_success assert_success
updatepass=$(grep lorem@impsum.org "$(private_config_path mail)/postfix-accounts.cf" | awk -F '|' '{print $2}') updatepass=$(grep lorem@impsum.org "$(private_config_path mail)/postfix-accounts.cf" | awk -F '|' '{print $2}')
[ "${updatepass}" != "" ] [[ ${updatepass} != "" ]]
[ "${initialpass}" != "${updatepass}" ] [[ ${initialpass} != "${updatepass}" ]]
docker exec mail doveadm pw -t "${updatepass}" -p 'my password' | grep 'verified' docker exec mail doveadm pw -t "${updatepass}" -p 'my password' | grep 'verified'
assert_success assert_success