Skip to content

Commit

Permalink
Merge pull request #469 from kbase/develop
Browse files Browse the repository at this point in the history
Release 0.2.5: SAM-119, SAM-209, SAM-236
  • Loading branch information
dakotablair authored May 6, 2022
2 parents 951122f + 0fb836e commit 9ffd516
Show file tree
Hide file tree
Showing 45 changed files with 2,302 additions and 1,228 deletions.
78 changes: 9 additions & 69 deletions .github/workflows/non_sdk_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,80 +24,20 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up test environment
if: "!contains(github.event.head_commit.message, 'skip ci')"
shell: bash
env:
KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }}
MONGODB_VER: mongodb-linux-x86_64-3.6.16
ARANGODB_VER: 3.5.1
ARANGODB_V: 35
KAFKA_VER: 2.8.1
SCALA_VER: 2.12
run: |
# upgrade and update
apt update && apt upgrade
# Download necessary components for testing
# mongo is only a test dependency, no point in matrixing it
cd ..
wget http://fastdl.mongodb.org/linux/$MONGODB_VER.tgz
# file may be gzipped over transfer
gzip -d $MONGODB_VER.tgz
tar xf $MONGODB_VER.tar
export MONGOD=`pwd`/$MONGODB_VER/bin/mongod
cd -
echo "Done with Mongo"
# arango
cd ..
curl -O https://download.arangodb.com/arangodb$ARANGODB_V/Community/Linux/arangodb3-linux-$ARANGODB_VER.tar.gz
tar -xf arangodb3-linux-$ARANGODB_VER.tar.gz
export ARANGO_EXE=$(pwd)/arangodb3-$ARANGODB_VER/usr/sbin/arangod
export ARANGO_JS=$(pwd)/arangodb3-$ARANGODB_VER/usr/share/arangodb3/js/
cd -
echo "Done with Arango"
# kafka
cd ..
curl -O http://mirror.metrocast.net/apache/kafka/$KAFKA_VER/kafka_$SCALA_VER-$KAFKA_VER.tgz
tar -xzf kafka_$SCALA_VER-$KAFKA_VER.tgz
export KAFKA_BIN_DIR=$(pwd)/kafka_$SCALA_VER-$KAFKA_VER/bin
cd -
echo "Done with Kafka"
- name: Install pipenv
run: pip install -r requirements.txt

# jars
cd ..
git clone https://github.com/kbase/jars
export JARS=$(pwd)/jars/lib/jars
cd -
echo "Done with Jars"
# copy to test.cfg file
cd test
cp test.cfg.example test.cfg
sed -i "s#^test.jars.dir=.*#test.jars.dir=$JARS#" test.cfg
sed -i "s#^test.temp.dir=.*#test.temp.dir=temp_test_dir#" test.cfg
sed -i "s#^test.arango.exe.*#test.arango.exe=$ARANGO_EXE#" test.cfg
sed -i "s#^test.arango.js.*#test.arango.js=$ARANGO_JS#" test.cfg
sed -i "s#^test.mongo.exe.*#test.mongo.exe=$MONGOD#" test.cfg
sed -i "s#^test.kafka.bin.dir.*#test.kafka.bin.dir=$KAFKA_BIN_DIR#" test.cfg
sed -i "s#^test.mongo.wired_tiger.*#test.mongo.wired_tiger=true#" test.cfg
cat test.cfg
cd -
- name: Install Python dependencies
- name: Set up for tests
if: "!contains(github.event.head_commit.message, 'skip ci')"
shell: bash
run: |
pip install --upgrade pip
pip install -r requirements.txt
make test-setup
- name: Run tests
shell: bash
run: |
echo "Create fake deployment config"
echo "[SampleService]" > service.cfg
echo "srv_wiz_url = https://ci.kbase.us/services/service_wizard" >> service.cfg
export KB_DEPLOYMENT_CONFIG=`pwd`/service.cfg
pipenv install --dev
pipenv run make test-sdkless
make test
- name: Coverage Summary
run: |
make coverage-summary
31 changes: 26 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
.DS_Store
.idea
test/test.cfg
test_local
# Development
__pycache__
.vscode
deploy.cfg
lib/SampleService/SampleServiceImpl.py.bak*
test/test.cfg.bak
/_temp
.mypy_cache
.pytest_cache

# Testing
test/test.cfg
test_local
.coverage
test/test_temp/
lib/SampleService/SampleServiceImpl.py.bak*
test/bin/jars
test/bin/mongo
test/bin/arangodb
test/bin/kafka
test/bin/temp
htmlcov/
cov_profile.lcov
temp_test_dir
mongo.log

# IDE
.vscode
.idea

# OS
.DS_Store
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ compile:
--out . \
--html \

test:
echo Use test-sdkless
test: test-sdkless coverage-reports

test-sdkless:
# TODO flake8 and bandit
# TODO check tests run with kb-sdk test - will need to install mongo and update config
MYPYPATH=$(MAKEFILE_DIR)/$(LIB_DIR) mypy --namespace-packages $(LIB_DIR)/$(SERVICE_CAPS)/core $(TEST_DIR)
PYTHONPATH=$(PYPATH) SAMPLESERV_TEST_FILE=$(TSTFL) pytest --verbose --cov $(LIB_DIR)/$(SERVICE_CAPS) --cov-config=$(TEST_DIR)/coveragerc $(TEST_SPEC)
# to print test output immediately: --capture=tee-sys
# TODO flake8 and bandit
# TODO check tests run with kb-sdk test - will need to install mongo and update config
MYPYPATH=$(MAKEFILE_DIR)/$(LIB_DIR) pipenv run mypy --namespace-packages $(LIB_DIR)/$(SERVICE_CAPS)/core $(TEST_DIR)
PYTHONPATH=$(PYPATH) SAMPLESERV_TEST_FILE=$(TSTFL) pipenv run pytest --verbose --cov $(LIB_DIR)/$(SERVICE_CAPS) --cov-config=$(TEST_DIR)/coveragerc $(TEST_SPEC)
# to print test output immediately: --capture=tee-sys

clean:
rm -rfv $(LBIN_DIR)
Expand All @@ -58,3 +57,18 @@ host-start-dev-server:

host-stop-dev-server:
source scripts/dev-server-env.sh && sh scripts/stop-dev-server.sh

# Test support

test-setup:
bash test/scripts/test-setup.sh

coverage-reports:
@echo "Creating html coverage report"
pipenv run coverage html
@echo "Converting coverage to lcov"
pipenv run coverage lcov --data-file .coverage -o cov_profile.lcov

coverage-summary:
@echo "Coverage summary:"
pipenv run coverage report
51 changes: 25 additions & 26 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,37 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"
pytest-cov = "*"
mypy = "*"
coveralls = "*"
flake8 = "*"
pymongo = "*"
semver = "*"
ipython = "*"
black = "*"
pytest = "==7.1.2"
pytest-cov = "==3.0.0"
mypy = "==0.942"
coveralls = "==3.3.1"
flake8 = "==4.0.1"
semver = "==2.13.0"
coverage = "==6.3.2"
pymongo = "==4.1.1"

[packages]
python-arango = "==5.0.0"
jsonrpcbase = "==0.2.0"
apscheduler = "==3.6.3"
apscheduler = "==3.9.1"
maps = "==5.1.1"
requests = "==2.22.0"
cacheout = "==0.11.2"
pyyaml = "==5.4"
requests = "==2.27.1"
cacheout = "==0.13.1"
pyyaml = "==6.0"
jsonschema = "==3.2.0"
pint = "==0.10.1"
python-ranges = "==0.1.3"
pygtrie = "==2.3.2"
jinja2 = "==2.11.3"
gevent = "==20.5.0"
gunicorn = "==20.0.4"
kafka-python = "==2.0.1"
greenlet = "==0.4.16"
typing-extensions = "*"
types-pyyaml = "*"
types-requests = "*"
pipenv = "*"
shell = "*"
# hold pint back to 0.17 - requires code changes at 0.18
pint = "==0.17"
python-ranges = "==0.2.0"
pygtrie = "==2.4.2"
jinja2 = "==3.1.1"
gevent = "==21.12.0"
gunicorn = "==20.1.0"
kafka-python = "==2.0.2"
greenlet = "==1.1.2"
typing-extensions = "==4.2.0"
types-pyyaml = "==6.0.7"
types-requests = "==2.27.20"
shell = "==1.0.1"

[requires]
python_version = "3.7"
Loading

0 comments on commit 9ffd516

Please sign in to comment.