Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: API smoke tests

on:
push:
branches: [ master, dev*, feature/docker*, feature/repo*, jupyterhub-update ]
pull_request:
branches: [ master, dev*, feature/docker*, feature/repo*, jupyterhub-update ]

jobs:

build:

runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.12" ]
runs-on: [ ubuntu-latest ]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install pytest requests==2.31.0

- name: Run API tests
run: |
pytest tests/test_apis.py -vs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class BiomodelsAdapter:
"""
Adapter for Biomodels

https://www.ebi.ac.uk/biomodels/
https://www.biomodels.org/
"""

def __init__(self, osbrepository, uri=None):
self.osbrepository = osbrepository
self.uri = uri if uri else osbrepository.uri
self.api_url = "https://www.ebi.ac.uk/biomodels"
self.api_url = "https://www.biomodels.org"

try:
self.model_id = re.search(
Expand Down
77 changes: 53 additions & 24 deletions local-scripts/osbv2-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ CLOUD_HARNESS_DIR="${CLOUD_HARNESS_DIR_LOCATION}/cloud-harness"
CLOUD_HARNESS_DEFAULT="develop"
CLOUD_HARNESS_BRANCH=""
SKAFFOLD="skaffold"
SKAFFOLD_MAX_VERSION="2.14.2"
SKAFFOLD_MAX_VERSION="2.15.0"
HELM_MAX_VERSION="4.0.0"

# Application to deploy
DEPLOYMENT_APP=""
Expand Down Expand Up @@ -54,7 +55,7 @@ start_minikube () {
echo "🍏 Assuming Docker is already running on OS: $(uname -s)"
fi

echo "-> starting minkube"
echo "-> starting minikube"
if minikube status
then
echo "-> Minikube is already running: not restarting it"
Expand All @@ -66,10 +67,10 @@ start_minikube () {
minikube addons enable metrics-server || notify_fail "Failed: ingress add on"
echo "-> setting up ${OSB_NAMESPACE} namespace"
kubectl get ns ${OSB_NAMESPACE} || kubectl create ns ${OSB_NAMESPACE} || notify_fail "Failed: ns set up"
kubectl config set-context NAME --namespace=${OSB_NAMESPACE} || notify_fail "Failed: ns set up"
kubectl config set-context --current --namespace=${OSB_NAMESPACE} || notify_fail "Failed: ns set up"
echo "-> setting up minikube docker env"

eval $(minikube docker-env) || notify_fail "Failed: env setup"
eval "$(minikube docker-env)" || notify_fail "Failed: env setup"
fi
}

Expand All @@ -86,7 +87,7 @@ deploy_live () {

LIVE="YES"

pushd $OSB_DIR
pushd $OSB_DIR || exit 1
echo "-> deploying live configuration"

start_minikube
Expand All @@ -97,9 +98,9 @@ deploy_live () {
echo
echo "-> Deploying with helm: helm install -n ${OSB_NAMESPACE} osb deployment/helm"

helm install -n ${OSB_NAMESPACE} osb deployment/helm
helm install --debug -n ${OSB_NAMESPACE} osb deployment/helm

popd
popd || exit 1
}

show_deployment_status () {
Expand Down Expand Up @@ -137,29 +138,43 @@ deploy () {

skaffold_version="$($SKAFFOLD version)"

if [ $(get_version ${skaffold_version:1}) -gt $(get_version $SKAFFOLD_MAX_VERSION) ]
if [ "$(get_version ${skaffold_version:1})" -gt "$(get_version $SKAFFOLD_MAX_VERSION)" ]
then
echo "-> Found Skaffold version: ${skaffold_version:1}"
echo "-> Skaffold version <= ${SKAFFOLD_MAX_VERSION} is currently required"
echo "-> Skaffold version < ${SKAFFOLD_MAX_VERSION} is currently required"
echo "-> Please install it from: https://github.com/GoogleContainerTools/skaffold/releases/tag/v${SKAFFOLD_MAX_VERSION}"
echo "-> See: https://github.com/GoogleContainerTools/skaffold/issues/9788"
exit 1
else
echo "Got skaffold version: ${skaffold_version}"
fi

pushd $OSB_DIR

helm_version="$(helm version | grep -o 'Version:"v[^"]*"' | cut -d'"' -f2 )"

if [ "$(get_version ${helm_version:1})" -gt "$(get_version $HELM_MAX_VERSION)" ]
then
echo "-> Found helm version: ${skaffold_version:1}"
echo "-> helm version < ${HELM_MAX_VERSION} is currently required"
echo "-> Please install it from: https://github.com/helm/helm/releases#release-v${HELM_MAX_VERSION}"
exit 1
else
echo "Got helm version: ${helm_version}"
fi
pushd $OSB_DIR || exit 1
echo "-> deploying"
start_minikube

harness_deployment

echo "-> running skaffold"
$SKAFFOLD dev --cleanup=false || { notify_fail "Failed: skaffold" ; minikube stop; }
#$SKAFFOLD dev || notify_fail "Failed: skaffold"
popd
#$SKAFFOLD dev --cleanup=false || { notify_fail "Failed: skaffold" ; minikube stop; }
$SKAFFOLD dev || notify_fail "Failed: skaffold"
popd || exit 1
}

list_versions () {
if ! command -v harness-deployment 2>&1 >/dev/null ; then
if ! command -v harness-deployment >/dev/null 2>&1 ; then
echo "cloud-harness is required but were not found."
echo "To install cloud-harness, please see the -u/-U options"
exit 1
Expand Down Expand Up @@ -189,7 +204,7 @@ harness_deployment() {
# use -e dev for that, but that will send e-mails to Metacell folks
# suggested: create a new file in deploy/values-something.yaml where you use
# your e-mail address, and then use `-e something` to use these values.
pushd $OSB_DIR
pushd $OSB_DIR || exit 1
if [ "YES" == "$LIVE" ]
then
echo "-> harnessing live configuration deployment, and deploying"
Expand All @@ -198,7 +213,7 @@ harness_deployment() {
echo "-> harnessing development deployment"
harness-deployment ../cloud-harness . -l -n ${OSB_NAMESPACE} -d osb.local -dtls -e "local" ${DEPLOYMENT_APP:+-i $DEPLOYMENT_APP} || notify_fail "Failed: harness-deployment (dev)"
fi
popd
popd || exit 1
}

notify_fail () {
Expand All @@ -213,20 +228,35 @@ notify_fail () {

update_cloud_harness() {
echo "Updating cloud harness"
CLOUD_HARNESS_PACKAGES=$(pip list | grep cloud | tr -s " " | cut -d " " -f1 | tr '\n' ' ')
pip uninstall ${CLOUD_HARNESS_PACKAGES} -y || echo "No cloud harness packages installed"
if command -v uv >/dev/null
then
CLOUD_HARNESS_PACKAGES=$(uv pip list | grep cloud | tr -s " " | cut -d " " -f1 | tr '\n' ' ')
uv pip uninstall ${CLOUD_HARNESS_PACKAGES} || echo "No cloud harness packages installed"
else
CLOUD_HARNESS_PACKAGES=$(pip list | grep cloud | tr -s " " | cut -d " " -f1 | tr '\n' ' ')
pip uninstall "${CLOUD_HARNESS_PACKAGES}" -y || echo "No cloud harness packages installed"
fi
if ! [ -d "${CLOUD_HARNESS_DIR}" ]
then
echo "Cloud harness folder does not exist. Cloning"
pushd "${CLOUD_HARNESS_DIR_LOCATION}" && git clone "${CLOUD_HARNESS_URL}" && popd
pushd "${CLOUD_HARNESS_DIR_LOCATION}" && git clone "${CLOUD_HARNESS_URL}" && popd || exit 1
fi
if command -v uv >/dev/null
then
pushd "$CLOUD_HARNESS_DIR" && git clean -dfx && git fetch && git checkout "${CLOUD_HARNESS_BRANCH}" && git pull && uv pip install -r requirements.txt && popd || exit 1
else
pushd "$CLOUD_HARNESS_DIR" && git clean -dfx && git fetch && git checkout "${CLOUD_HARNESS_BRANCH}" && git pull && pip install -r requirements.txt && popd || exit 1
fi
pushd "$CLOUD_HARNESS_DIR" && git clean -dfx && git fetch && git checkout ${CLOUD_HARNESS_BRANCH} && git pull && pip install -r requirements.txt && popd
}

activate_venv() {
if [ -f "${VENV_DIR}/bin/activate" ]
then
source "${VENV_DIR}/bin/activate"
elif command -v uv >/dev/null
then
echo "No virtual environment found at ${VENV_DIR}. Creating (uv)"
uv venv --python "${PY_VERSION}" "${VENV_DIR}" && source "${VENV_DIR}/bin/activate"
else
echo "No virtual environment found at ${VENV_DIR}. Creating"
${PY_VERSION} -m venv "${VENV_DIR}" && source "${VENV_DIR}/bin/activate"
Expand All @@ -245,7 +275,7 @@ print_versions() {
echo -e "\n** minikube **"
minikube version
echo -e "\n** cloud harness **"
pushd "${CLOUD_HARNESS_DIR}" && git log --oneline | head -1 && popd
pushd "${CLOUD_HARNESS_DIR}" && git log --oneline | head -1 && popd || exit 1
echo -e "\n** helm **"
helm version
echo -e "\n** skaffold **"
Expand All @@ -257,7 +287,7 @@ print_versions() {
}

clean () {
pushd $OSB_DIR
pushd $OSB_DIR || exit 1
echo "-> Cleaning up all images."
#docker image prune --all
docker builder prune --all
Expand All @@ -266,7 +296,7 @@ clean () {
minikube delete
#docker image prune --all
docker builder prune --all
popd
popd || exit 1
}

usage () {
Expand Down Expand Up @@ -355,7 +385,6 @@ do
exit 0
;;
l)
CLOUD_HARNESS_BRANCH="${OPTARG}"
activate_venv
deploy_live
exit 0
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
markers =
network: marks tests as requiring network access (deselect with '-m "not network"')
Empty file added tests/__init__.py
Empty file.
Loading
Loading