-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows for codeql and component testing (#350)
* add workflows for codeql and component testing * remove codeql workflow * disable live tests during workflow * run action when pr is updated * remove duplicate key * remove type restriction * add cleanup to tests and improve logging * fix handling of pytest exit code * add manual installation of pytest if required * use unified env for python tests * update transformer version * try caching of virtual environments * disable client logging for tests * add exclusion checks for submodules * add KGQAnWrapper submodule * exit if external environment dir not possible
- Loading branch information
Showing
13 changed files
with
177 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Qanary component test pipeline | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test-java: | ||
runs-on: ubuntu-latest | ||
env: | ||
BABELFY_API_KEY : someapikey | ||
CHATGPT_API_KEY : someapikey | ||
DANDELION_API_KEY : someapikey | ||
MEANINGCLOUD_API_KEY : someapikey | ||
TAGME_API_KEY : someapikey | ||
TEXTRAZOR_API_KEY : someapikey | ||
OPENAI_API_KEY : someapikey | ||
BABELFY_API_LIVE_TEST_ACTIVE : false | ||
PLATYPUS_API_LIVE_TEST_ACTIVE : false | ||
TEXTRAZOR_API_LIVE_TEST_ACTIVE : false | ||
CHATGPT_API_LIVE_TEST_ACTIVE : false | ||
DANDELION_API_LIVE_TEST_ACTIVE : false | ||
MEANINGCLOUD_API_LIVE_TEST_ACTIVE : false | ||
AGDISTIS_API_LIVE_TEST_ACTIVE : false | ||
OPENAI_API_LIVE_TEST_ACTIVE : false | ||
TAGME_API_LIVE_TEST_ACTIVE : false | ||
steps: | ||
- name: Configure java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '17' | ||
- uses: actions/checkout@v4 | ||
- name: Test Java components | ||
run: bash -c ./service_config/test_java_components.sh | ||
test-python: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure Python | ||
uses: actions/setup-python@v4 | ||
id: setup_python | ||
with: | ||
python-version: '3.12' | ||
- uses: actions/checkout@v4 | ||
- name: Cache virtual environments | ||
uses: actions/cache@v4 | ||
with: | ||
key: environments-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('**/requirements.txt') }} | ||
path: environments | ||
- name: Test Python components | ||
run: bash -c ./service_config/test_python_components.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Qanary-component-QB-Python-KGQAnWrapper"] | ||
path = Qanary-component-QB-Python-KGQAnWrapper | ||
url = https://github.com/WSE-research/Qanary-component-QB-Python-KGQAnWrapper.git |
Submodule Qanary-component-QB-Python-KGQAnWrapper
added at
1c1d44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# ensure that submodules are not in maven reactor | ||
submodules=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') | ||
for submodule in $submodules; | ||
do | ||
if grep -qi $submodule "pom.xml"; then | ||
echo "Submodules should be tested and built externally. Please remove \"${submodule}\" from the maven reactor list." | ||
exit 4 | ||
fi | ||
done | ||
|
||
# test components | ||
if ! mvn --batch-mode --no-transfer-progress test; | ||
then | ||
echo "Maven test failed" | ||
exit 4 # stop if test fails | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/bash | ||
|
||
declare -A summary | ||
failures=false | ||
# get a list of all Python component directories | ||
# exclude submodules (external component repositories) | ||
components=$(comm -3 <(ls | grep -P "[qQ]anary-component.*Python-[a-zA-Z]+$") <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')) | ||
|
||
# create a super directory to hold virtual environments (for caching) | ||
|
||
if [ -d environments ]; then | ||
echo "External evironment directory exists" | ||
else | ||
if mkdir environments; then | ||
echo "External environment directory created" | ||
else | ||
echo "External environment directory could not be created" | ||
exit 4 | ||
fi | ||
fi | ||
|
||
printf "Found Python components:\n\n${components}\n\n" | ||
|
||
|
||
# iterate over components | ||
for dir in $components | ||
do | ||
# iterate over Python components | ||
name=$(echo ${dir} | tr "[:upper:]" "[:lower:]") | ||
printf "\n\n===== ${name} =====\n\n" | ||
|
||
cd $dir | ||
# setup virtual environment in external super directory | ||
envname=../environments/${name} | ||
python -m venv ${envname} | ||
if source ${envname}/bin/activate; then | ||
pip install -r requirements.txt | ||
else | ||
echo "Something went wrong trying to install requirements! Exiting ..." | ||
exit 4 | ||
fi | ||
|
||
# install pytest manually if not included in requirements | ||
if ! pip show pytest; then | ||
echo "Installing pytest manually..." | ||
pip install pytest | ||
fi | ||
if ! pip show pytest-env; then | ||
echo "Installing pytest-env manually..." | ||
pip install pytest-env | ||
fi | ||
|
||
# run tests | ||
pytest | ||
test_status=$? | ||
# check exit codes | ||
if [ $test_status -eq 0 ]; then # all tests successful | ||
summary[${name}]="passed" | ||
elif [ $test_status -eq 5 ]; then # no tests found | ||
summary[${name}]="no tests" | ||
else # tests failed or something else went wrong | ||
summary[${name}]="failed" | ||
failures=true | ||
fi | ||
|
||
#pip freeze | xargs pip uninstall -y TODO: disabled because that would mess with caching | ||
deactivate | ||
rm -r ${envname} | ||
|
||
cd .. | ||
|
||
done | ||
|
||
|
||
# print a summary | ||
printf "\n\n===== SUMMARY =====\n\n" | ||
for x in "${!summary[@]}"; do printf "%s\t:\t[%s]\n" "$x" "${summary[$x]}"; done | column -s$'\t' -t | ||
if $failures; then | ||
printf "\nSome tests failed!\n" | ||
exit 4 | ||
else | ||
printf "\nTests succeeded\n" | ||
fi |