Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ jobs:
when: on_success
- run:
shell: /bin/bash
name: "install coverage attempt"
name: "install test extras attempt"
command: |
python3 -m pip install --user coverage || true
- run:
name: "install flake8 attempt"
command: |
python3 -m pip install --user flake8 || true
when: on_success
python3 -m pip install --user -r ./test-requirements.txt || true
- save_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
Expand All @@ -61,12 +56,6 @@ jobs:
steps:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
shell: /bin/bash
name: "clean up for test"
command: |
python3 -m pip install --user coverage || true
when: on_success
- run:
shell: /bin/bash
name: "clean up for test"
Expand Down Expand Up @@ -111,17 +100,11 @@ jobs:
steps:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
shell: /bin/bash
name: "clean up for test"
command: |
python3 -m pip install --user coverage || true
when: on_success
- run:
shell: /bin/bash
name: "setup up for pytest"
command: |
python3 -m pip install --user pytest || true
python3 -m pip install --upgrade --user -r ./test-requirements.txt || true
when: on_success
- run:
shell: /bin/bash
Expand Down Expand Up @@ -168,9 +151,9 @@ jobs:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: "install flake8 attempt"
name: "install linters extras attempt"
command: |
python3 -m pip install --user flake8 || true
python3 -m pip install --upgrade --user -r ./test-requirements.txt || true
- run:
shell: /bin/bash
name: "clean up for test"
Expand Down
66 changes: 22 additions & 44 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Setup dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37"
pip install -r ./requirements.txt
pip install --user -r ./test-requirements.txt || true
- name: Pre-build
id: bootstrap
run: |
Expand Down Expand Up @@ -151,8 +152,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies for ${{ matrix.python-version }}
run: |
pip install -r ./requirements.txt ;
pip install coverage || true ;
pip install -r ./requirements.txt
pip install --user -r ./test-requirements.txt || true
- name: Pre-Clean
id: clean
run: make -j1 -f Makefile clean || true ;
Expand Down Expand Up @@ -198,18 +199,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies for python ${{ matrix.python-version }} on ${{ matrix.os }}
run: |
pip install --upgrade --upgrade-strategy eager pip setuptools wheel ;
pip install --upgrade --upgrade-strategy eager -r ./requirements.txt ;
pip install --upgrade --upgrade-strategy eager pytest ;
pip install --upgrade --upgrade-strategy eager pytest-cov ;
pip install --upgrade --upgrade-strategy eager coverage ;
pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37"
pip install -r ./requirements.txt
pip install --user -r ./test-requirements.txt || true
- name: Install code-climate tools for ${{ matrix.python-version }}
if: ${{ runner.os }} == "Linux"
if: ${{ runner.os }} != "Linux"
shell: bash
run: |
if [ $OS == ubuntu-latest ] ; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter || true ; fi ;
if [ $OS == ubuntu-latest ] ; then chmod +x ./cc-test-reporter 2>/dev/null || true ; fi
if [ $OS == ubuntu-latest ] ; then ./cc-test-reporter before-build || true ; fi
run: if [ $OS == macos-latest ] ; then ./tests/fetch_cc-test-reporter || true ; fi ;
- name: Install deepsource tools for ${{ matrix.python-version }}
if: ${{ runner.os }} == "Linux"
shell: bash
Expand Down Expand Up @@ -241,10 +237,10 @@ jobs:
path: ./test-reports/
if-no-files-found: ignore
- name: code-climate for ${{ matrix.python-version }}
if: ${{ runner.os }} == "Linux"
if: ${{ runner.os }} != "Linux"
shell: bash
run: |
if [ $OS == ubuntu-latest ] ; then ./cc-test-reporter after-build --exit-code 0 || true ; else echo "SKIP code climate" ; fi ;
if [ $OS == macos-latest ] ; then ./cc-test-reporter after-build --exit-code 0 || true ; else echo "SKIP code climate" ; fi ;
- name: deepsource for ${{ matrix.python-version }}
if: ${{ runner.os }} == "Linux"
shell: bash
Expand Down Expand Up @@ -282,18 +278,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies for python ${{ matrix.python-version }} on ${{ matrix.os }}
run: |
pip install --upgrade --upgrade-strategy eager pip setuptools wheel ;
pip install --upgrade --upgrade-strategy eager -r ./requirements.txt ;
pip install --upgrade --upgrade-strategy eager pytest ;
pip install --upgrade --upgrade-strategy eager pytest-cov ;
pip install --upgrade --upgrade-strategy eager coverage ;
pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" ;
pip install -r ./requirements.txt ;
pip install --user -r ./test-requirements.txt || true ;
- name: Install code-climate tools for ${{ matrix.python-version }}
if: ${{ runner.os }} == "Linux"
shell: bash
run: |
if [ $OS == ubuntu-latest ] ; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter || true ; fi ;
if [ $OS == ubuntu-latest ] ; then chmod +x ./cc-test-reporter 2>/dev/null || true ; fi
if [ $OS == ubuntu-latest ] ; then ./cc-test-reporter before-build || true ; fi
run: if [ $OS == ubuntu-latest ] ; then ./tests/fetch_cc-test-reporter || true ; fi ;
- name: Install deepsource tools for ${{ matrix.python-version }}
if: ${{ runner.os }} == "Linux"
shell: bash
Expand Down Expand Up @@ -357,11 +348,9 @@ jobs:
python-version: "3.10"
- name: Install dependencies for python Linters
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" ;
pip install -r ./requirements.txt ;
pip install flake8 ;
pip install pyflakes ;
pip install pep8 ;
pip install --user -r ./test-requirements.txt || true ;
- name: Pre-Clean
id: clean
run: make -j1 -f Makefile clean || true ;
Expand Down Expand Up @@ -403,17 +392,12 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies for python ${{ matrix.python-version }} on ${{ matrix.os }}
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" ;
pip install -r ./requirements.txt ;
pip install coverage ;
pip install pytest ;
pip install pytest-cov ;
pip install --user -r ./test-requirements.txt || true ;
- name: Install code-climate tools for ${{ matrix.python-version }}
if: ${{ runner.os }} != "Linux"
run: |
if [ $OS == macos-latest ] ; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter || true ; fi ;
if [ $OS == macos-latest ] ; then chmod +x ./cc-test-reporter 2>/dev/null || true ; fi
if [ $OS == macos-latest ] ; then ./cc-test-reporter before-build || true ; fi
run: if [ $OS == macos-latest ] ; then ./tests/fetch_cc-test-reporter || true ; fi ;
shell: bash
- name: Pre-Clean
id: clean-prep
Expand Down Expand Up @@ -477,15 +461,9 @@ jobs:
python-version: "3.10"
- name: Install dependencies for Tox
run: |
pip install --upgrade pip setuptools wheel tox
pip install --upgrade "pip>=21.0" "setuptools>=45.0" "wheel>=0.37" "tox>=3.0";
pip install -r ./requirements.txt ;
pip install coverage ;
pip install codecov ;
pip install flake8 ;
pip install pyflakes ;
pip install pep8 ;
pip install tox ;
pip install six ;
pip install --user -r ./test-requirements.txt || true ;
- name: Pre-Clean
id: clean
run: make -j1 -f Makefile clean || true ;
Expand Down
34 changes: 34 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#python
# time - builtin - PSF licence
# re - builtin - PSF licence?
# subprocess - PSF licence
# sphinx
# argparse - builtin - PSF licence
argparse>=1.4.0
# argparse - builtin - PSF licence
setuptools>=38.0
# virtualenv - MIT
virtualenv>=15.0.1
# six - MIT
six>=1.0.0
# pgpy - BSD 3-Clause licensed
#pgpy>=0.4.1
tox>=3.0.0
#py>=1.4.33
# pip>=19.0
###
# TESTING ONLY - Do NOT report issues with these optionals on python-repo
###
flake8>=5.0
pyflakes>=2.5.0
pep8>=1.0
pytest>=7
pytest-checkdocs>=2.4
pytest-cov>=4.0.0
pytest-enabler>=1.0.1
pytest-flake8>=1.0
coverage >= 6.3
pytest-cov >= 4.0.0;
pytest-enabler >= 1.0.1
wheel >= 0.37.0
pip >= 21.0
166 changes: 166 additions & 0 deletions tests/fetch_cc-test-reporter
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
#! /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.
################################################################################

ulimit -t 1200
PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:${PATH}"
LANG=${LANG:-"en_US"}
LC_ALL="${LANG:1:5}.utf-8"
umask 127

LOCK_FILE="${TMPDIR:-/tmp}/org.pak.tests.scripts.code-climate.lock"
EXIT_CODE=0

test -x $(command -v grep) || exit 126 ;
test -x $(command -v curl) || exit 126 ;
hash -p ./.github/tool_shlock_helper.sh shlock || exit 255 ;
test -x "$(command -v shlock)" || exit 126 ;
test -x $(command -v gpgv) || exit 126 ;
test -x $(command -v shasum) || exit 126 ;

# sorry no windows support here
if [[ $( \uname -s ) == "*arwin" ]] ; then
CI_OS="darwin"
else
CI_OS="linux"
fi

function cleanup() {
rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ;
rm -f ./test-reporter-latest-*-amd64.SHA*.sig 2>/dev/null || true ; wait ;
hash -d shlock 2>/dev/null > /dev/null || true ;
}

if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 129 ;' SIGHUP || EXIT_CODE=129
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 143 ;' SIGTERM || EXIT_CODE=143
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 131 ;' SIGQUIT || EXIT_CODE=131
# SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173
#trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit 130 ;' SIGINT || EXIT_CODE=130
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true || true ; wait ; exit 137 ;' SIGABRT || EXIT_CODE=137
trap 'cleanup 2>/dev/null || rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
trap 'cleanup ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
else
echo "CodeCov already in progress by "`head ${LOCK_FILE}` ;
false ;
exit 126 ;
fi

# this is how test files are found:

# THIS IS THE ACTUAL TEST DIR USED (update _TEST_ROOT_DIR as needed)
_TEST_ROOT_DIR="./" ;
if [[ -d ./.git ]] ; then
_TEST_ROOT_DIR="./" ;
elif [[ -d ./tests ]] ; then
_TEST_ROOT_DIR="./" ;
else
echo "FAIL: missing valid folder or file"
EXIT_CODE=1
fi

# This File MUST BE GIT-IGNORED
# to be SAFELY USED to store Tokens and env vars (update logic as needed)
if [[ ( -r ./codecov_env ) ]] ; then
source ./codecov_env 2>/dev/null || true ;
fi


#########################
# actual Work starts here
#########################
curl -fLso ./test-reporter-latest-${CI_OS:-linux}-amd64 https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${CI_OS:-linux}-amd64 ;
for i in 1 256 512 ; do
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 ;
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 ;
# test sha1/sha512 signatures if found and sha256 even if not found
if [[ ( -r test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} ) ]] || [[ ( ${i} -eq 256 ) ]] ; then
if [[ ( -r test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}.sig ) ]] ; then
# configure your CI evironment to trust the key at ????
# FP: KEY FP
# OR...
# Set CI=true to continue on missing keys
gpgv test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i}.sig test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} || ${CI} || EXIT_CODE=126
rm -vf codecov.SHA${i}SUM.sig 2>/dev/null ;
fi
shasum -a $i -c --ignore-missing test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} || EXIT_CODE=126
rm -vf test-reporter-latest-${CI_OS:-linux}-amd64.SHA${i} 2>/dev/null ;
fi
done

if [[ ( ${EXIT_CODE} -eq 0 ) ]] ; then
mv -f test-reporter-latest-${CI_OS:-linux}-amd64 ./cc-test-reporter 2>/dev/null || EXIT_CODE=126
chmod -v 751 ./cc-test-reporter || EXIT_CODE=126
fi

if [[ ( ${EXIT_CODE} -eq 0 ) ]] ; then
./cc-test-reporter || EXIT_CODE=10 ;
fi


unset _TEST_ROOT_DIR 2>/dev/null || true ;

rm -f ./test-reporter-latest-*-amd64.SHA* 2>/dev/null > /dev/null || true ; wait ;
rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ;

# goodbye
exit ${EXIT_CODE:-255} ;