Skip to content

Commit

Permalink
add test workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
heinpa committed Apr 24, 2024
1 parent ca9b646 commit 65018fc
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
# push:
# branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '25 0 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Qanary Component Build Pipeline

on:
push:
pull_request:
branches: [ master ]

jobs:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Qanary component test pipeline

on:
pull_request:
branches: [master]
schedule:
- cron: '25 0 * * 0'

jobs:
test-java:
runs-on: ubuntu-latest
env:
BABELFY_API_KEY: ${{ secrets.BABELFY_API_KEY }}
CHATGPT_API_KEY: ${{ secrets.CHATGPT_API_KEY }}
DANDELION_API_KEY: ${{ secrets.DANDELION_API_KEY }}
MEANINGCLOUD_API_KEY: ${{ secrets.MEANINGCLOUD_API_KEY }}
TAGME_API_KEY: ${{ secrets.TAGME_API_KEY }}
TEXTRAZOR_API_KEY: ${{ secrets.TEXTRAZOR_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
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:
- uses: actions/checkout@v4
- name: Test Python components
run: bash -c ./service_config/test_python_components.sh


24 changes: 24 additions & 0 deletions service_config/test_java_components.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# clone Qanary pipeline
git clone https://github.com/WDAqua/Qanary.git

# subshell building the Qanary pipeline
(
cd Qanary/
mvn --batch-mode clean install -Ddockerfile.skip=true -DskipTests -Dgpg.skip=true
)

# delete Qanary pipeline repository
rm -rf Qanary/


# TODO: replacing of keys required?

# test components
if ! mvn --batch-mode test;
then
echo "Maven test failed"
exit 4 # stop if tests fail
fi

# DONE
18 changes: 18 additions & 0 deletions service_config/test_python_components.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# TODO: navigate into individual python components, setup venv and run tests, then deactivate

components=$(ls | grep -P "qanary-component.*Python-[a-zA-Z]+$")

for dir in $components
do
name=$(echo ${dir} | tr "[:upper:]" "[:lower:]")
echo "Testing ${name} ..."
cd $dir
python -m venv env
source env/bin/activate
pip install -r requirements.txt
pytest
deactivate
cd ..
done

0 comments on commit 65018fc

Please sign in to comment.