Skip to content

Commit

Permalink
Add per-version testing restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed May 21, 2024
1 parent 54efa08 commit bb6f48d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ jobs:
run: make install-nbtest
- name: Warm up
continue-on-error: true
run: sleep 30 && PATCH_ES=1 ELASTIC_CLOUD_ID=foo ELASTIC_API_KEY=bar bin/nbtest notebooks/search/00-quick-start.ipynb
run: sleep 30 && PATCH_ES=1 ELASTIC_CLOUD_ID=foo ELASTIC_API_KEY=bar ES_STACK=${{ matrix.es_stack }} bin/nbtest notebooks/search/00-quick-start.ipynb
- name: Run tests
run: PATCH_ES=1 FORCE_COLOR=1 make -s test
run: PATCH_ES=1 FORCE_COLOR=1 ES_STACK=${{ matrix.es_stack }} make -s test
42 changes: 40 additions & 2 deletions bin/find-notebooks-to-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# add any notebooks that are currently not testable to the exempt list

EXEMPT_NOTEBOOKS=(
# Add any notebooks that are currently not testable to the exempt list
"notebooks/esql/esql-getting-started.ipynb"
"notebooks/search/07-inference.ipynb"
"notebooks/search/08-learning-to-rank.ipynb"
Expand All @@ -25,9 +26,46 @@ EXEMPT_NOTEBOOKS=(
"notebooks/enterprise-search/app-search-engine-exporter.ipynb"
)

# Per-version testing exceptions
# use variables named EXEMPT_NOTEBOOKS__{major}_[minor}_{patch} to list
# notebooks that cannot run on that stack version or older
# Examples:
# EXEMPT_NOTEBOOKS__8 for notebooks that must be skipped on all versions 8.x and older
# EXEMPT_NOTEBOOKS__8_14 for notebooks that must skipped on versions 8.14 and older
# EXEMPT_NOTEBOOKS__8_13_2 for notebooks that must be skipped on versions 8.13.2 and older

EXEMPT_NOTEBOOKS__8_14=(
# Add any notebooks that must be skipped on versions 8.14 or older here
"notebooks/search/03-ELSER.ipynb"
"notebooks/model-upgrades/upgrading-index-to-use-elser.ipynb"
"notebooks/langchain/langchain-vector-store-using-elser.ipynb"
)

# this function parses a version given as M[.N[.P]] or M[_N[_P]] into a numeric form
function parse_version { echo "$@" | awk -F'[._]' '{ printf("%02d%02d%02d\n", $1, $2, $3); }'; }

# this is the version CI is running
ci_version=$(parse_version ${ES_STACK:-99.99})

ALL_NOTEBOOKS=$(find notebooks -name "*.ipynb" | grep -v "_nbtest" | grep -v ".ipynb_checkpoints" | sort)
for notebook in $ALL_NOTEBOOKS; do
if [[ ! "${EXEMPT_NOTEBOOKS[@]}" =~ $notebook ]]; then
skip=
# check the master exception list
if [[ "${EXEMPT_NOTEBOOKS[@]}" =~ $notebook ]]; then
skip=yes
else
# check the versioned exception lists
for exempt_key in ${!EXEMPT_NOTEBOOKS__*}; do
exempt_version=$(parse_version ${exempt_key/EXEMPT_NOTEBOOKS__/})
if [ $exempt_version -ge $ci_version ]; then
exempt_notebooks=$(eval 'echo ${'${exempt_key}'[@]}')
if [[ "${exempt_notebooks[@]}" =~ $notebook ]]; then
skip=yes
fi
fi
done
fi
if [[ "$skip" == "" ]]; then
echo $notebook
fi
done
2 changes: 1 addition & 1 deletion notebooks/document-chunking/with-langchain-splitters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python3 -m pip install -qU langchain langchain-elasticsearch elasticsearch eland==8.12.1 jq"
"!python3 -m pip install -qU langchain langchain-community langchain-elasticsearch elasticsearch eland==8.12.1 jq"
]
},
{
Expand Down

0 comments on commit bb6f48d

Please sign in to comment.