Skip to content

Commit 715705c

Browse files
[TESTS] Testing prototype tool to fetch and verify the cc-test-reporter (- WIP #40 -)
Testing only AMD64 for linux and darwin latest. Once working we can look at figuring out arm64.
1 parent 2c020f6 commit 715705c

File tree

2 files changed

+172
-15
lines changed

2 files changed

+172
-15
lines changed

.github/workflows/Tests.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,9 @@ jobs:
203203
pip install -r ./requirements.txt
204204
pip install --user -r ./test-requirements.txt || true
205205
- name: Install code-climate tools for ${{ matrix.python-version }}
206-
if: ${{ runner.os }} == "Linux"
206+
if: ${{ runner.os }} != "Linux"
207207
shell: bash
208-
run: |
209-
if [ $OS == ubuntu-latest ] ; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter || true ; fi ;
210-
if [ $OS == ubuntu-latest ] ; then chmod +x ./cc-test-reporter 2>/dev/null || true ; fi
211-
if [ $OS == ubuntu-latest ] ; then ./cc-test-reporter before-build || true ; fi
208+
run: if [ $OS == macos-latest ] ; then ./tests/fetch_cc-test-reporter || true ; fi ;
212209
- name: Install deepsource tools for ${{ matrix.python-version }}
213210
if: ${{ runner.os }} == "Linux"
214211
shell: bash
@@ -240,10 +237,10 @@ jobs:
240237
path: ./test-reports/
241238
if-no-files-found: ignore
242239
- name: code-climate for ${{ matrix.python-version }}
243-
if: ${{ runner.os }} == "Linux"
240+
if: ${{ runner.os }} != "Linux"
244241
shell: bash
245242
run: |
246-
if [ $OS == ubuntu-latest ] ; then ./cc-test-reporter after-build --exit-code 0 || true ; else echo "SKIP code climate" ; fi ;
243+
if [ $OS == macos-latest ] ; then ./cc-test-reporter after-build --exit-code 0 || true ; else echo "SKIP code climate" ; fi ;
247244
- name: deepsource for ${{ matrix.python-version }}
248245
if: ${{ runner.os }} == "Linux"
249246
shell: bash
@@ -287,10 +284,7 @@ jobs:
287284
- name: Install code-climate tools for ${{ matrix.python-version }}
288285
if: ${{ runner.os }} == "Linux"
289286
shell: bash
290-
run: |
291-
if [ $OS == ubuntu-latest ] ; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter || true ; fi ;
292-
if [ $OS == ubuntu-latest ] ; then chmod +x ./cc-test-reporter 2>/dev/null || true ; fi
293-
if [ $OS == ubuntu-latest ] ; then ./cc-test-reporter before-build || true ; fi
287+
run: if [ $OS == ubuntu-latest ] ; then ./tests/fetch_cc-test-reporter || true ; fi ;
294288
- name: Install deepsource tools for ${{ matrix.python-version }}
295289
if: ${{ runner.os }} == "Linux"
296290
shell: bash
@@ -403,10 +397,7 @@ jobs:
403397
pip install --user -r ./test-requirements.txt || true ;
404398
- name: Install code-climate tools for ${{ matrix.python-version }}
405399
if: ${{ runner.os }} != "Linux"
406-
run: |
407-
if [ $OS == macos-latest ] ; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter || true ; fi ;
408-
if [ $OS == macos-latest ] ; then chmod +x ./cc-test-reporter 2>/dev/null || true ; fi
409-
if [ $OS == macos-latest ] ; then ./cc-test-reporter before-build || true ; fi
400+
run: if [ $OS == macos-latest ] ; then ./tests/fetch_cc-test-reporter || true ; fi ;
410401
shell: bash
411402
- name: Pre-Clean
412403
id: clean-prep

tests/fetch_cc-test-reporter

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#! /bin/bash
2+
# Disclaimer of Warranties.
3+
# A. YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE EXTENT PERMITTED BY
4+
# APPLICABLE LAW, USE OF THIS SHELL SCRIPT AND ANY SERVICES PERFORMED
5+
# BY OR ACCESSED THROUGH THIS SHELL SCRIPT IS AT YOUR SOLE RISK AND
6+
# THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND
7+
# EFFORT IS WITH YOU.
8+
#
9+
# B. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SHELL SCRIPT
10+
# AND SERVICES ARE PROVIDED "AS IS" AND “AS AVAILABLE”, WITH ALL FAULTS AND
11+
# WITHOUT WARRANTY OF ANY KIND, AND THE AUTHOR OF THIS SHELL SCRIPT'S LICENSORS
12+
# (COLLECTIVELY REFERRED TO AS "THE AUTHOR" FOR THE PURPOSES OF THIS DISCLAIMER)
13+
# HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH RESPECT TO THIS SHELL SCRIPT
14+
# SOFTWARE AND SERVICES, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
15+
# NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
16+
# MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE,
17+
# ACCURACY, QUIET ENJOYMENT, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS.
18+
#
19+
# C. THE AUTHOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE
20+
# THE AUTHOR's SOFTWARE AND SERVICES, THAT THE FUNCTIONS CONTAINED IN, OR
21+
# SERVICES PERFORMED OR PROVIDED BY, THIS SHELL SCRIPT WILL MEET YOUR
22+
# REQUIREMENTS, THAT THE OPERATION OF THIS SHELL SCRIPT OR SERVICES WILL
23+
# BE UNINTERRUPTED OR ERROR-FREE, THAT ANY SERVICES WILL CONTINUE TO BE MADE
24+
# AVAILABLE, THAT THIS SHELL SCRIPT OR SERVICES WILL BE COMPATIBLE OR
25+
# WORK WITH ANY THIRD PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES,
26+
# OR THAT DEFECTS IN THIS SHELL SCRIPT OR SERVICES WILL BE CORRECTED.
27+
# INSTALLATION OF THIS THE AUTHOR SOFTWARE MAY AFFECT THE USABILITY OF THIRD
28+
# PARTY SOFTWARE, APPLICATIONS OR THIRD PARTY SERVICES.
29+
#
30+
# D. YOU FURTHER ACKNOWLEDGE THAT THIS SHELL SCRIPT AND SERVICES ARE NOT
31+
# INTENDED OR SUITABLE FOR USE IN SITUATIONS OR ENVIRONMENTS WHERE THE FAILURE
32+
# OR TIME DELAYS OF, OR ERRORS OR INACCURACIES IN, THE CONTENT, DATA OR
33+
# INFORMATION PROVIDED BY THIS SHELL SCRIPT OR SERVICES COULD LEAD TO
34+
# DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE,
35+
# INCLUDING WITHOUT LIMITATION THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
36+
# NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, LIFE SUPPORT OR
37+
# WEAPONS SYSTEMS.
38+
#
39+
# E. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY THE AUTHOR
40+
# SHALL CREATE A WARRANTY. SHOULD THIS SHELL SCRIPT OR SERVICES PROVE DEFECTIVE,
41+
# YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
42+
#
43+
# Limitation of Liability.
44+
# F. TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT SHALL THE AUTHOR
45+
# BE LIABLE FOR PERSONAL INJURY, OR ANY INCIDENTAL, SPECIAL, INDIRECT OR
46+
# CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, DAMAGES
47+
# FOR LOSS OF PROFITS, CORRUPTION OR LOSS OF DATA, FAILURE TO TRANSMIT OR
48+
# RECEIVE ANY DATA OR INFORMATION, BUSINESS INTERRUPTION OR ANY OTHER
49+
# COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR
50+
# INABILITY TO USE THIS SHELL SCRIPT OR SERVICES OR ANY THIRD PARTY
51+
# SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH THIS SHELL SCRIPT OR
52+
# SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT,
53+
# TORT OR OTHERWISE) AND EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
54+
# POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
55+
# OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF INCIDENTAL OR
56+
# CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU. In no event
57+
# shall THE AUTHOR's total liability to you for all damages (other than as may
58+
# be required by applicable law in cases involving personal injury) exceed
59+
# the amount of five dollars ($5.00). The foregoing limitations will apply
60+
# even if the above stated remedy fails of its essential purpose.
61+
################################################################################
62+
63+
ulimit -t 1200
64+
PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:${PATH}"
65+
LANG=${LANG:-"en_US"}
66+
LC_ALL="${LANG:1:5}.utf-8"
67+
umask 127
68+
69+
LOCK_FILE="${TMPDIR:-/tmp}/org.pak.tests.scripts.code-climate.lock"
70+
EXIT_CODE=0
71+
72+
test -x $(command -v grep) || exit 126 ;
73+
test -x $(command -v curl) || exit 126 ;
74+
hash -p ./.github/tool_shlock_helper.sh shlock || exit 255 ;
75+
test -x "$(command -v shlock)" || exit 126 ;
76+
test -x $(command -v gpgv) || exit 126 ;
77+
test -x $(command -v shasum) || exit 126 ;
78+
79+
# sorry no windows support here
80+
if [[ $( \uname -s ) == "*arwin" ]] ; then
81+
CI_OS="darwin"
82+
else
83+
CI_OS="linux"
84+
fi
85+
86+
function cleanup() {
87+
rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ;
88+
rm -f ./test-reporter-latest-*-amd64.SHA*.sig 2>/dev/null || true ; wait ;
89+
hash -d shlock 2>/dev/null > /dev/null || true ;
90+
}
91+
92+
if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then
93+
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129
94+
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143
95+
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131
96+
# SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173
97+
#trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7
98+
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 130 ;' SIGINT || EXIT_CODE=130
99+
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true || true ; wait ; exit 137 ;' SIGABRT || EXIT_CODE=137
100+
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
101+
trap 'cleanup ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
102+
else
103+
echo "CodeCov already in progress by "`head ${LOCK_FILE}` ;
104+
false ;
105+
exit 126 ;
106+
fi
107+
108+
# this is how test files are found:
109+
110+
# THIS IS THE ACTUAL TEST DIR USED (update _TEST_ROOT_DIR as needed)
111+
_TEST_ROOT_DIR="./" ;
112+
if [[ -d ./.git ]] ; then
113+
_TEST_ROOT_DIR="./" ;
114+
elif [[ -d ./tests ]] ; then
115+
_TEST_ROOT_DIR="./" ;
116+
else
117+
echo "FAIL: missing valid folder or file"
118+
EXIT_CODE=1
119+
fi
120+
121+
# This File MUST BE GIT-IGNORED
122+
# to be SAFELY USED to store Tokens and env vars (update logic as needed)
123+
if [[ ( -r ./codecov_env ) ]] ; then
124+
source ./codecov_env 2>/dev/null || true ;
125+
fi
126+
127+
128+
#########################
129+
# actual Work starts here
130+
#########################
131+
curl -fLso ./test-reporter-latest-${CI_OS:-linux}-amd64 https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${CI_OS:-linux}-amd64 ;
132+
for i in 1 256 512 ; do
133+
curl -fLso test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}" ; wait ;
134+
curl -fLso test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}.sig "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}.sig" ; wait ;
135+
# test sha1/sha512 signatures if found and sha256 even if not found
136+
if [[ ( -r test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} ) ]] || [[ ( ${i} -eq 256 ) ]] ; then
137+
if [[ ( -r test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}.sig ) ]] ; then
138+
# configure your CI evironment to trust the key at ????
139+
# FP: KEY FP
140+
# OR...
141+
# Set CI=true to continue on missing keys
142+
gpgv test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}.sig test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} || ${CI} || EXIT_CODE=126
143+
rm -vf codecov.SHA${i}SUM.sig 2>/dev/null ;
144+
fi
145+
shasum -a $i -c --ignore-missing test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} || EXIT_CODE=126
146+
rm -vf test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} 2>/dev/null ;
147+
fi
148+
done
149+
150+
if [[ ( ${EXIT_CODE} -eq 0 ) ]] ; then
151+
mv -f test-reporter-latest-${CI_OS:-linux}-amd64 ./cc-test-reporter 2>/dev/null || EXIT_CODE=126
152+
chmod -v 751 ./cc-test-reporter || EXIT_CODE=126
153+
fi
154+
155+
if [[ ( ${EXIT_CODE} -eq 0 ) ]] ; then
156+
./cc-test-reporter || EXIT_CODE=10 ;
157+
fi
158+
159+
160+
unset _TEST_ROOT_DIR 2>/dev/null || true ;
161+
162+
rm -f ./test-reporter-latest-*-amd64.SHA* 2>/dev/null > /dev/null || true ; wait ;
163+
rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ;
164+
165+
# goodbye
166+
exit ${EXIT_CODE:-255} ;

0 commit comments

Comments
 (0)