From 2a6fcd98a3c9aff1cf076c70253d9ed4cb05c95f Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Thu, 19 Mar 2020 18:18:48 -0700 Subject: [PATCH 1/4] First attempt at CI Testing #204 --- .github/bin/posttests.sh | 101 +++++++++++++++++++++++++ .github/bin/pretests.sh | 145 ++++++++++++++++++++++++++++++++++++ .github/bin/runtests.sh | 145 ++++++++++++++++++++++++++++++++++++ .github/workflows/Tests.yml | 45 +++++++++++ 4 files changed, 436 insertions(+) create mode 100755 .github/bin/posttests.sh create mode 100755 .github/bin/pretests.sh create mode 100755 .github/bin/runtests.sh create mode 100644 .github/workflows/Tests.yml diff --git a/.github/bin/posttests.sh b/.github/bin/posttests.sh new file mode 100755 index 0000000..76c93c4 --- /dev/null +++ b/.github/bin/posttests.sh @@ -0,0 +1,101 @@ +#! /bin/bash +# Disclaimer of Warranties. +# A. YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY +# APPLICABLE LAW, USE OF THIS SHELL SCRIPT AND ANY SERVICES PERFORMED +# BY OR ACCESSED THROUGH THIS SHELL SCRIPT IS AT YOUR SOLE RISK AND +# THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND +# EFFORT IS WITH YOU. +# +# B. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SHELL SCRIPT +# AND SERVICES ARE PROVIDED "AS IS" AND “AS AVAILABLE”, WITH ALL FAULTS AND +# WITHOUT WARRANTY OF ANY KIND, AND THE AUTHOR OF THIS SHELL SCRIPT'S LICENSORS +# (COLLECTIVELY REFERRED TO AS "THE AUTHOR" FOR THE PURPOSES OF THIS DISCLAIMER) +# HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH RESPECT TO THIS SHELL SCRIPT +# SOFTWARE AND SERVICES, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +# NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF +# MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +# ACCURACY, QUIET ENJOYMENT, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS. +# +# C. THE AUTHOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE +# THE AUTHOR's SOFTWARE AND SERVICES, THAT THE FUNCTIONS CONTAINED IN, OR +# SERVICES PERFORMED OR PROVIDED BY, THIS SHELL SCRIPT WILL MEET YOUR +# REQUIREMENTS, THAT THE OPERATION OF THIS SHELL SCRIPT OR SERVICES WILL +# BE UNINTERRUPTED OR ERROR-FREE, THAT ANY SERVICES WILL CONTINUE TO BE MADE +# AVAILABLE, THAT THIS SHELL SCRIPT OR SERVICES WILL BE COMPATIBLE OR +# WORK WITH ANY THIRD PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES, +# OR THAT DEFECTS IN THIS SHELL SCRIPT OR SERVICES WILL BE CORRECTED. +# INSTALLATION OF THIS THE AUTHOR SOFTWARE MAY AFFECT THE USABILITY OF THIRD +# PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES. +# +# D. YOU FURTHER ACKNOWLEDGE THAT THIS SHELL SCRIPT AND SERVICES ARE NOT +# INTENDED OR SUITABLE FOR USE IN SITUATIONS OR ENVIRONMENTS WHERE THE FAILURE +# OR TIME DELAYS OF, OR ERRORS OR INACCURACIES IN, THE CONTENT, DATA OR +# INFORMATION PROVIDED BY THIS SHELL SCRIPT OR SERVICES COULD LEAD TO +# DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE, +# INCLUDING WITHOUT LIMITATION THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT +# NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, LIFE SUPPORT OR +# WEAPONS SYSTEMS. +# +# E. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY THE AUTHOR +# SHALL CREATE A WARRANTY. SHOULD THIS SHELL SCRIPT OR SERVICES PROVE DEFECTIVE, +# YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +# +# Limitation of Liability. +# F. TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHOR +# BE LIABLE FOR PERSONAL INJURY, OR ANY INCIDENTAL, SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, DAMAGES +# FOR LOSS OF PROFITS, CORRUPTION OR LOSS OF DATA, FAILURE TO TRANSMIT OR +# RECEIVE ANY DATA OR INFORMATION, BUSINESS INTERRUPTION OR ANY OTHER +# COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR +# INABILITY TO USE THIS SHELL SCRIPT OR SERVICES OR ANY THIRD PARTY +# SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH THIS SHELL SCRIPT OR +# SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, +# TORT OR OTHERWISE) AND EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +# OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF INCIDENTAL OR +# CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU. In no event +# shall THE AUTHOR's total liability to you for all damages (other than as may +# be required by applicable law in cases involving personal injury) exceed +# the amount of five dollars ($5.00). The foregoing limitations will apply +# even if the above stated remedy fails of its essential purpose. +################################################################################ + +# bootstrap checks (pre post-checks) +EXIT_CODE=0 + + +# if locking was needed: +#### +# ulimit -t 600 +# PATH="/bin:/sbin:/usr/sbin:/usr/bin" +# umask 137 +# +# LOCK_FILE="/tmp/post_test_script_lock" +# +# if [[ -f ${LOCK_FILE} ]] ; then +# exit 0 ; +# fi +# +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGABORT +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGHUP +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGTERM +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGQUIT +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGINT +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 0 ;' EXIT +# +# touch ${LOCK_FILE} 2>/dev/null || exit 0 ; + +# THIS IS THE ACTUAL WORK: +echo "WARNING: No Cleanup" + +############################## +# can more run setup code here +############################## +# ideas: pull down resources need for tests like docker images or test tools + +# if locking is used: clean up here +#### +# rm -f ${LOCK_FILE} >/dev/null || true ; wait ; + +# goodbye +exit ${EXIT_CODE:-255} ; diff --git a/.github/bin/pretests.sh b/.github/bin/pretests.sh new file mode 100755 index 0000000..452ef0f --- /dev/null +++ b/.github/bin/pretests.sh @@ -0,0 +1,145 @@ +#! /bin/bash +# Disclaimer of Warranties. +# A. YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY +# APPLICABLE LAW, USE OF THIS SHELL SCRIPT AND ANY SERVICES PERFORMED +# BY OR ACCESSED THROUGH THIS SHELL SCRIPT IS AT YOUR SOLE RISK AND +# THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND +# EFFORT IS WITH YOU. +# +# B. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SHELL SCRIPT +# AND SERVICES ARE PROVIDED "AS IS" AND “AS AVAILABLE”, WITH ALL FAULTS AND +# WITHOUT WARRANTY OF ANY KIND, AND THE AUTHOR OF THIS SHELL SCRIPT'S LICENSORS +# (COLLECTIVELY REFERRED TO AS "THE AUTHOR" FOR THE PURPOSES OF THIS DISCLAIMER) +# HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH RESPECT TO THIS SHELL SCRIPT +# SOFTWARE AND SERVICES, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +# NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF +# MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +# ACCURACY, QUIET ENJOYMENT, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS. +# +# C. THE AUTHOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE +# THE AUTHOR's SOFTWARE AND SERVICES, THAT THE FUNCTIONS CONTAINED IN, OR +# SERVICES PERFORMED OR PROVIDED BY, THIS SHELL SCRIPT WILL MEET YOUR +# REQUIREMENTS, THAT THE OPERATION OF THIS SHELL SCRIPT OR SERVICES WILL +# BE UNINTERRUPTED OR ERROR-FREE, THAT ANY SERVICES WILL CONTINUE TO BE MADE +# AVAILABLE, THAT THIS SHELL SCRIPT OR SERVICES WILL BE COMPATIBLE OR +# WORK WITH ANY THIRD PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES, +# OR THAT DEFECTS IN THIS SHELL SCRIPT OR SERVICES WILL BE CORRECTED. +# INSTALLATION OF THIS THE AUTHOR SOFTWARE MAY AFFECT THE USABILITY OF THIRD +# PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES. +# +# D. YOU FURTHER ACKNOWLEDGE THAT THIS SHELL SCRIPT AND SERVICES ARE NOT +# INTENDED OR SUITABLE FOR USE IN SITUATIONS OR ENVIRONMENTS WHERE THE FAILURE +# OR TIME DELAYS OF, OR ERRORS OR INACCURACIES IN, THE CONTENT, DATA OR +# INFORMATION PROVIDED BY THIS SHELL SCRIPT OR SERVICES COULD LEAD TO +# DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE, +# INCLUDING WITHOUT LIMITATION THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT +# NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, LIFE SUPPORT OR +# WEAPONS SYSTEMS. +# +# E. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY THE AUTHOR +# SHALL CREATE A WARRANTY. SHOULD THIS SHELL SCRIPT OR SERVICES PROVE DEFECTIVE, +# YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +# +# Limitation of Liability. +# F. TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHOR +# BE LIABLE FOR PERSONAL INJURY, OR ANY INCIDENTAL, SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, DAMAGES +# FOR LOSS OF PROFITS, CORRUPTION OR LOSS OF DATA, FAILURE TO TRANSMIT OR +# RECEIVE ANY DATA OR INFORMATION, BUSINESS INTERRUPTION OR ANY OTHER +# COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR +# INABILITY TO USE THIS SHELL SCRIPT OR SERVICES OR ANY THIRD PARTY +# SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH THIS SHELL SCRIPT OR +# SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, +# TORT OR OTHERWISE) AND EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +# OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF INCIDENTAL OR +# CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU. In no event +# shall THE AUTHOR's total liability to you for all damages (other than as may +# be required by applicable law in cases involving personal injury) exceed +# the amount of five dollars ($5.00). The foregoing limitations will apply +# even if the above stated remedy fails of its essential purpose. +################################################################################ + +# bootstrap checks (pre pre-checks) +EXIT_CODE=0 + +test -x `command -v uname` || exit 1 ; +test -x `command -v git` || exit 1 ; + +if [[ ( $(uname -s) = "Darwin" ) ]] ; then + export CI_OS_NAME="osx" ; +else + export CI_OS_NAME="linux" ; +fi + + +# if locking was needed: +#### +# ulimit -t 600 +# PATH="/bin:/sbin:/usr/sbin:/usr/bin" +# umask 137 +# +# LOCK_FILE="/tmp/pre_test_script_lock" +# +# if [[ -f ${LOCK_FILE} ]] ; then +# exit 0 ; +# fi +# +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGABORT +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGHUP +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGTERM +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGQUIT +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGINT +# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 0 ;' EXIT +# +# touch ${LOCK_FILE} 2>/dev/null || exit 0 ; + +# THIS IS THE ACTUAL WORK: + +# use this for codecov.io if enabled +#export CODECOV_TOKEN="" ; +# use for a github token if enabled (USE HARDCODE AT OWN RISK) +#export GITHUB_TOKEN="" ; +export CI=true ; # we are running CI +export CONTINUOUS_INTEGRATION=true ; +# if you run on-prem +#export GITLAB_CI=true ; +# get the repository name +export CI_REPO=$(basename `git rev-parse --show-toplevel`) ; +export CI_BRANCH=$(git symbolic-ref --short HEAD ) ; +export GIT_BRANCH=$(git symbolic-ref --short HEAD ) ; +export BRANCH_NAME=$(git symbolic-ref --short HEAD) ; +export SOURCE_BRANCH=$(git symbolic-ref --short HEAD ) ; +export CF_BRANCH=$(git symbolic-ref --short HEAD ) ; +export CIRCLE_BRANCH=$(git symbolic-ref --short HEAD ) ; +export APPVEYOR_REPO_BRANCH=$(git symbolic-ref --short HEAD ) ; +export TEAMCITY_BUILD_BRANCH=$(git symbolic-ref --short HEAD ) ; +export VCS_BRANCH_NAME=$(git symbolic-ref --short HEAD ) ; +export TRAVIS_BRANCH=$(git symbolic-ref --short HEAD ) ; +# Next line commented as this can mess with codecov if in use +# export WERCKER_GIT_BRANCH=$(git symbolic-ref --short HEAD ) ; +export TRAVIS_OS_NAME="${TRAVIS_OS_NAME:-${CI_OS_NAME}}" ; +export TRAVIS_PYTHON_VERSION=$($(command -v python) --version 2>&1 3>&1 | head -n 1 | grep -oE "[0-9]+.[0-9]+" | head -n 1 ) ; +export TRAVIS_COMMIT=$(git rev-parse --verify HEAD) +export CI_BUILD_ID=$(git rev-list --all --count) +export CI_BUILD_REF=$(git rev-parse --verify HEAD) +export CI_JOB_ID=$(date '+%y%m%d%H%M%S') +export CI_COMMIT_NAME=$(git symbolic-ref --short HEAD ) ; +# used by some tools to link back to this build's log +#export CI_BUILD_URL="https://localhost:443/codecov/fake/ci/build/${CI_BUILD_ID}/${CI_JOB_ID}" +export VCS_COMMIT_ID=$(git rev-parse --verify HEAD) +export GITHUB_USER=$(git config --get user.name) +export GITHUB_REPO=$(basename `git rev-parse --show-toplevel`) ; +export GITHUB_COMMENTS_URL="https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/commits/${CI_BUILD_REF}/comments" + +############################## +# can more run setup code here +############################## +# ideas: pull down resources need for tests like docker images or test tools + +# if locking is used: clean up here +#### +# rm -f ${LOCK_FILE} >/dev/null || true ; wait ; + +# goodbye +exit ${EXIT_CODE:-255} ; diff --git a/.github/bin/runtests.sh b/.github/bin/runtests.sh new file mode 100755 index 0000000..a32dcc3 --- /dev/null +++ b/.github/bin/runtests.sh @@ -0,0 +1,145 @@ +#! /bin/bash +# Disclaimer of Warranties. +# A. YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY +# APPLICABLE LAW, USE OF THIS SHELL SCRIPT AND ANY SERVICES PERFORMED +# BY OR ACCESSED THROUGH THIS SHELL SCRIPT IS AT YOUR SOLE RISK AND +# THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND +# EFFORT IS WITH YOU. +# +# B. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SHELL SCRIPT +# AND SERVICES ARE PROVIDED "AS IS" AND “AS AVAILABLE”, WITH ALL FAULTS AND +# WITHOUT WARRANTY OF ANY KIND, AND THE AUTHOR OF THIS SHELL SCRIPT'S LICENSORS +# (COLLECTIVELY REFERRED TO AS "THE AUTHOR" FOR THE PURPOSES OF THIS DISCLAIMER) +# HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH RESPECT TO THIS SHELL SCRIPT +# SOFTWARE AND SERVICES, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +# NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF +# MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +# ACCURACY, QUIET ENJOYMENT, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS. +# +# C. THE AUTHOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE +# THE AUTHOR's SOFTWARE AND SERVICES, THAT THE FUNCTIONS CONTAINED IN, OR +# SERVICES PERFORMED OR PROVIDED BY, THIS SHELL SCRIPT WILL MEET YOUR +# REQUIREMENTS, THAT THE OPERATION OF THIS SHELL SCRIPT OR SERVICES WILL +# BE UNINTERRUPTED OR ERROR-FREE, THAT ANY SERVICES WILL CONTINUE TO BE MADE +# AVAILABLE, THAT THIS SHELL SCRIPT OR SERVICES WILL BE COMPATIBLE OR +# WORK WITH ANY THIRD PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES, +# OR THAT DEFECTS IN THIS SHELL SCRIPT OR SERVICES WILL BE CORRECTED. +# INSTALLATION OF THIS THE AUTHOR SOFTWARE MAY AFFECT THE USABILITY OF THIRD +# PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES. +# +# D. YOU FURTHER ACKNOWLEDGE THAT THIS SHELL SCRIPT AND SERVICES ARE NOT +# INTENDED OR SUITABLE FOR USE IN SITUATIONS OR ENVIRONMENTS WHERE THE FAILURE +# OR TIME DELAYS OF, OR ERRORS OR INACCURACIES IN, THE CONTENT, DATA OR +# INFORMATION PROVIDED BY THIS SHELL SCRIPT OR SERVICES COULD LEAD TO +# DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE, +# INCLUDING WITHOUT LIMITATION THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT +# NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, LIFE SUPPORT OR +# WEAPONS SYSTEMS. +# +# E. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY THE AUTHOR +# SHALL CREATE A WARRANTY. SHOULD THIS SHELL SCRIPT OR SERVICES PROVE DEFECTIVE, +# YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +# +# Limitation of Liability. +# F. TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHOR +# BE LIABLE FOR PERSONAL INJURY, OR ANY INCIDENTAL, SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, DAMAGES +# FOR LOSS OF PROFITS, CORRUPTION OR LOSS OF DATA, FAILURE TO TRANSMIT OR +# RECEIVE ANY DATA OR INFORMATION, BUSINESS INTERRUPTION OR ANY OTHER +# COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR +# INABILITY TO USE THIS SHELL SCRIPT OR SERVICES OR ANY THIRD PARTY +# SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH THIS SHELL SCRIPT OR +# SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, +# TORT OR OTHERWISE) AND EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +# OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF INCIDENTAL OR +# CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU. In no event +# shall THE AUTHOR's total liability to you for all damages (other than as may +# be required by applicable law in cases involving personal injury) exceed +# the amount of five dollars ($5.00). The foregoing limitations will apply +# even if the above stated remedy fails of its essential purpose. +################################################################################ + +# bootstrap checks (pre pre-checks) +EXIT_CODE=0 + +test -x `command -v uname` || exit 1 ; +test -x `command -v git` || exit 1 ; + +if [[ ( $(uname -s) = "Darwin" ) ]] ; then + export CI_OS_NAME="osx" ; +else + export CI_OS_NAME="linux" ; +fi + + +# if locking was needed: +#### +# ulimit -t 600 +# PATH="/bin:/sbin:/usr/sbin:/usr/bin" +# umask 137 +# +LOCK_FILE="/tmp/CI_test_script_lock" + +if [[ -f ${LOCK_FILE} ]] ; then + echo "Lock found! ABORT" + exit ${EXIT_CODE:-0} ; +fi +# +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGABRT +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGHUP +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGTERM +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGQUIT +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGINT +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGKILL +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 0 ;' EXIT +# +touch ${LOCK_FILE} 2>/dev/null || exit 0 ; + +# THIS IS THE ACTUAL WORK: + +export CI_TOOLS_BIN=$(dirname "${0}") ; +#TODO: make this more absolute +export CI_TEST_ROOT=$(dirname ${PWD:-./}/.) ; + +${CI_TOOLS_BIN}/pretests.sh + +function fn_test_cmd() { + local CI_TEST_CASE_RESULT=0 ; + local OLDUMASK=$(umask) ; + ( ${CI_TOOLS_BIN%/}/${1} ${@:2:$#-1} ) || CI_TEST_CASE_RESULT=$? ; + wait ; + # clean up + umask "$OLDUMASK" ; + # return to start path + cd "${CI_TEST_ROOT}" ; + return $CI_TEST_CASE_RESULT ; +} + +date ; +echo "TEST START" || EXIT_CODE=2 ; + +echo "Example test for usage output" || EXIT_CODE=2 ; +[[ ( $(fn_test_cmd ../../rsync_tmbackup.sh -h | grep -ci -oF "Usage:") -ge 1 ) ]] && echo "... Passed" || echo "... FAILED" ; + +echo "example fail test" +[[ ( $( fn_test_cmd no such test ) ) ]] && echo "... Passed" || echo "... FAILED" ; + + +cd "${CI_TEST_ROOT}" || true ; + +############################## +# can more run setup code here +############################## + + +echo "TEST END" ; +### KEEP THIS LINE ### +${CI_TOOLS_BIN}/posttests.sh + +# if locking is used: clean up here +#### +rm -f ${LOCK_FILE} >/dev/null || true ; wait ; + +# goodbye +exit ${EXIT_CODE:-255} ; diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 0000000..9fbb019 --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,45 @@ +name: CI + +on: [push] + +jobs: + META: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Check Pre Test Setup Script + run: test -x ./.github/bin/pretests.sh ; + - name: Check Test Scripts + run: test -x ./.github/bin/runtests.sh ; + - name: Check Linter Scripts + run: test -x ./.github/bin/styletests.sh ; + - name: Check Post Test Scripts + run: test -x ./.github/bin/posttests.sh ; + + MATS: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Pre Test Setup + run: ./.github/bin/pretests.sh || true ; + - name: Run Tests + run: ./.github/bin/runtests.sh || true ; + - name: Post Test Clean + run: ./.github/bin/posttests.sh || true ; + + STYLE: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Pre Test Setup + run: ./.github/bin/pretests.sh || true ; + - name: Run Tests + run: ./.github/bin/styletests.sh || true ; + - name: Post Test Clean + run: ./.github/bin/posttests.sh || true ; From 5aada9a7cc46f50fcd4bef96f8d23f86dbe54e4d Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Thu, 19 Mar 2020 20:58:53 -0700 Subject: [PATCH 2/4] #204 Add: Use Shellcheck to test code quality --- .github/bin/runtests.sh | 22 +++++++++++++++++----- .github/workflows/Tests.yml | 13 +++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/bin/runtests.sh b/.github/bin/runtests.sh index a32dcc3..4f55116 100755 --- a/.github/bin/runtests.sh +++ b/.github/bin/runtests.sh @@ -92,7 +92,7 @@ trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGTERM trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGQUIT trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGINT trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGKILL -trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 0 ;' EXIT +trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit ${EXIT_CODE:-0} ;' EXIT # touch ${LOCK_FILE} 2>/dev/null || exit 0 ; @@ -104,6 +104,16 @@ export CI_TEST_ROOT=$(dirname ${PWD:-./}/.) ; ${CI_TOOLS_BIN}/pretests.sh +function fn_test_pass() { + echo "... Passed" ; + return 0 ; +} + +function fn_test_fail() { + echo "... FAILED" ; + return 1 ; +} 1>&2 + function fn_test_cmd() { local CI_TEST_CASE_RESULT=0 ; local OLDUMASK=$(umask) ; @@ -116,14 +126,15 @@ function fn_test_cmd() { return $CI_TEST_CASE_RESULT ; } -date ; echo "TEST START" || EXIT_CODE=2 ; +date ; echo "Example test for usage output" || EXIT_CODE=2 ; -[[ ( $(fn_test_cmd ../../rsync_tmbackup.sh -h | grep -ci -oF "Usage:") -ge 1 ) ]] && echo "... Passed" || echo "... FAILED" ; +[[ ( $(fn_test_cmd ../../rsync_tmbackup.sh -h | grep -ci -oF "Usage:") -ge 1 ) ]] && fn_test_pass || fn_test_fail || EXIT_CODE=1 ; -echo "example fail test" -[[ ( $( fn_test_cmd no such test ) ) ]] && echo "... Passed" || echo "... FAILED" ; +echo "Example fail test" +# the || true prevents the test from erroring because the fail is expected here: use || EXIT_CODE=1 for expected pass +[[ ( $( fn_test_cmd no such test ) ) ]] && fn_test_pass || fn_test_fail || true ; cd "${CI_TEST_ROOT}" || true ; @@ -134,6 +145,7 @@ cd "${CI_TEST_ROOT}" || true ; echo "TEST END" ; + ### KEEP THIS LINE ### ${CI_TOOLS_BIN}/posttests.sh diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 9fbb019..a6d92f0 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -13,8 +13,6 @@ jobs: run: test -x ./.github/bin/pretests.sh ; - name: Check Test Scripts run: test -x ./.github/bin/runtests.sh ; - - name: Check Linter Scripts - run: test -x ./.github/bin/styletests.sh ; - name: Check Post Test Scripts run: test -x ./.github/bin/posttests.sh ; @@ -27,7 +25,7 @@ jobs: - name: Pre Test Setup run: ./.github/bin/pretests.sh || true ; - name: Run Tests - run: ./.github/bin/runtests.sh || true ; + run: ./.github/bin/runtests.sh ; - name: Post Test Clean run: ./.github/bin/posttests.sh || true ; @@ -36,10 +34,5 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Pre Test Setup - run: ./.github/bin/pretests.sh || true ; - - name: Run Tests - run: ./.github/bin/styletests.sh || true ; - - name: Post Test Clean - run: ./.github/bin/posttests.sh || true ; + - name: shellcheck + uses: ludeeus/action-shellcheck@0.1.0 From 5f28dd4e4abaf948befba822f605c8b7ef5ab90d Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Thu, 19 Mar 2020 21:20:01 -0700 Subject: [PATCH 3/4] Fix for PR #205 as part of laurent22/rsync-time-backup#204 --- .github/bin/styletests.sh | 85 +++++++++++++++++++++++++++++++++++++ .github/workflows/Tests.yml | 11 ++++- 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 .github/bin/styletests.sh diff --git a/.github/bin/styletests.sh b/.github/bin/styletests.sh new file mode 100644 index 0000000..7f4b643 --- /dev/null +++ b/.github/bin/styletests.sh @@ -0,0 +1,85 @@ +#! /bin/bash +# Disclaimer of Warranties. +# A. YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY +# APPLICABLE LAW, USE OF THIS SHELL SCRIPT AND ANY SERVICES PERFORMED +# BY OR ACCESSED THROUGH THIS SHELL SCRIPT IS AT YOUR SOLE RISK AND +# THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND +# EFFORT IS WITH YOU. +# +# B. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SHELL SCRIPT +# AND SERVICES ARE PROVIDED "AS IS" AND “AS AVAILABLE”, WITH ALL FAULTS AND +# WITHOUT WARRANTY OF ANY KIND, AND THE AUTHOR OF THIS SHELL SCRIPT'S LICENSORS +# (COLLECTIVELY REFERRED TO AS "THE AUTHOR" FOR THE PURPOSES OF THIS DISCLAIMER) +# HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH RESPECT TO THIS SHELL SCRIPT +# SOFTWARE AND SERVICES, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +# NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF +# MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +# ACCURACY, QUIET ENJOYMENT, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS. +# +# C. THE AUTHOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE +# THE AUTHOR's SOFTWARE AND SERVICES, THAT THE FUNCTIONS CONTAINED IN, OR +# SERVICES PERFORMED OR PROVIDED BY, THIS SHELL SCRIPT WILL MEET YOUR +# REQUIREMENTS, THAT THE OPERATION OF THIS SHELL SCRIPT OR SERVICES WILL +# BE UNINTERRUPTED OR ERROR-FREE, THAT ANY SERVICES WILL CONTINUE TO BE MADE +# AVAILABLE, THAT THIS SHELL SCRIPT OR SERVICES WILL BE COMPATIBLE OR +# WORK WITH ANY THIRD PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES, +# OR THAT DEFECTS IN THIS SHELL SCRIPT OR SERVICES WILL BE CORRECTED. +# INSTALLATION OF THIS THE AUTHOR SOFTWARE MAY AFFECT THE USABILITY OF THIRD +# PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES. +# +# D. YOU FURTHER ACKNOWLEDGE THAT THIS SHELL SCRIPT AND SERVICES ARE NOT +# INTENDED OR SUITABLE FOR USE IN SITUATIONS OR ENVIRONMENTS WHERE THE FAILURE +# OR TIME DELAYS OF, OR ERRORS OR INACCURACIES IN, THE CONTENT, DATA OR +# INFORMATION PROVIDED BY THIS SHELL SCRIPT OR SERVICES COULD LEAD TO +# DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE, +# INCLUDING WITHOUT LIMITATION THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT +# NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, LIFE SUPPORT OR +# WEAPONS SYSTEMS. +# +# E. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY THE AUTHOR +# SHALL CREATE A WARRANTY. SHOULD THIS SHELL SCRIPT OR SERVICES PROVE DEFECTIVE, +# YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +# +# Limitation of Liability. +# F. TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHOR +# BE LIABLE FOR PERSONAL INJURY, OR ANY INCIDENTAL, SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, DAMAGES +# FOR LOSS OF PROFITS, CORRUPTION OR LOSS OF DATA, FAILURE TO TRANSMIT OR +# RECEIVE ANY DATA OR INFORMATION, BUSINESS INTERRUPTION OR ANY OTHER +# COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR +# INABILITY TO USE THIS SHELL SCRIPT OR SERVICES OR ANY THIRD PARTY +# SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH THIS SHELL SCRIPT OR +# SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, +# TORT OR OTHERWISE) AND EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +# OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF INCIDENTAL OR +# CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU. In no event +# shall THE AUTHOR's total liability to you for all damages (other than as may +# be required by applicable law in cases involving personal injury) exceed +# the amount of five dollars ($5.00). The foregoing limitations will apply +# even if the above stated remedy fails of its essential purpose. +################################################################################ + +# bootstrap checks (pre pre-checks) +EXIT_CODE=0 + +test -x `command -v apt-get` || exit 0 ; + +echo "apt available ... attempting shellcheck install" ; + +sudo apt-get install -y shellcheck || EXIT_CODE=1 ; + +echo " ... Done " ; + +test -x `command -v shellcheck` || exit 0 ; +echo "STYLE CHECK" +export CI_TEST_ROOT=$(dirname ${PWD:-./}/.) ; + +shellcheck "${CI_TEST_ROOT}/../../*.sh" || EXIT_CODE=1 ; +echo "... Done" ; + +# TODO: REMOVE THIS LINE TO fail on style checks +EXIT_CODE=0 ; # bypass fail + +# goodbye +exit ${EXIT_CODE:-255} ; diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index a6d92f0..7b9c98e 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -13,6 +13,8 @@ jobs: run: test -x ./.github/bin/pretests.sh ; - name: Check Test Scripts run: test -x ./.github/bin/runtests.sh ; + - name: Check Linter Scripts + run: test -x ./.github/bin/styletests.sh ; - name: Check Post Test Scripts run: test -x ./.github/bin/posttests.sh ; @@ -34,5 +36,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: shellcheck - uses: ludeeus/action-shellcheck@0.1.0 + - uses: actions/checkout@v2 + - name: Pre Test Setup + run: ./.github/bin/pretests.sh || true ; + - name: Run Tests + run: ./.github/bin/styletests.sh || true ; + - name: Post Test Clean + run: ./.github/bin/posttests.sh || true ; From bcc3931c4839ed469494d0b64d1945f8506b7e18 Mon Sep 17 00:00:00 2001 From: reactive-firewall Date: Thu, 19 Mar 2020 21:22:55 -0700 Subject: [PATCH 4/4] Fix for PR laurent22/rsync-time-backup#205 as part of laurent22/rsync-time-backup#204 --- .github/bin/styletests.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/bin/styletests.sh diff --git a/.github/bin/styletests.sh b/.github/bin/styletests.sh old mode 100644 new mode 100755