Integration Tests #355
Workflow file for this run
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
# Integration Tests | |
# Build aiverify and run QA test suites | |
name: Integration Tests | |
on: | |
# Runs when a pull request review is being submitted | |
pull_request_review: | |
types: [submitted] | |
branches: | |
- 'main' | |
- 'v0.*' | |
# Run this workflow manually from Actions tab | |
workflow_dispatch: | |
inputs: | |
branch_to_test: | |
description: 'Branch or tag to run test' | |
required: true | |
default: 'main' | |
type: string | |
# Allow one concurrent deployment | |
concurrency: | |
group: ${{ github.repository }}-${{ github.workflow }} | |
cancel-in-progress: false | |
jobs: | |
integration-tests: | |
# Run only when PR is approved | |
if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
timeout-minutes: 100 | |
steps: | |
- name: Install redis | |
run: | | |
sudo apt update | |
sudo apt install redis-server | |
pattern='notify-keyspace-events ""' | |
replacement='notify-keyspace-events Kh' | |
sudo sed -i 's/'"$pattern"'/'"$replacement"'/g' "/etc/redis/redis.conf" | |
sudo systemctl restart redis-server | |
- name: Install mongod | |
run: | | |
wget -nc https://www.mongodb.org/static/pgp/server-6.0.asc | |
cat server-6.0.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/mongodb.gpg >/dev/null | |
sudo sh -c 'echo "deb [ arch=amd64,arm64 signed-by=/etc/apt/keyrings/mongodb.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" >> /etc/apt/sources.list.d/mongo.list' | |
sudo apt update | |
sudo apt install -y mongodb-org | |
sudo systemctl start mongod | |
sleep 2 | |
mongosh << EOF | |
admin = db.getSiblingDB('admin') | |
admin.createUser({ | |
user: 'mongodb', | |
pwd: 't1oj5L_xQI8dTrVuZ', | |
roles: [{ role: 'root', db: 'admin' }], | |
}); | |
aiverify = db.getSiblingDB('aiverify') | |
aiverify.createUser({ | |
user: 'aiverify', | |
pwd: 't1oj5L_xQI8dTrVuZ', | |
roles: [{ role: 'readWrite', db: 'aiverify' }], | |
}); | |
aiverify.createCollection('test-collection'); | |
EOF | |
- name: Install libraries | |
run: | | |
sudo apt-get update | |
# amd64, install libs needed by puppeteer/chromium | |
sudo apt-get install -y libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 \ | |
libxi-dev libxtst-dev libnss3 libcups2 libxss1 libxrandr2 \ | |
libasound2 libatk1.0-0 libatk-bridge2.0-0 libpangocairo-1.0-0 \ | |
libgtk-3-0 libgbm1 | |
# For shap-toolbox plugin | |
sudo apt-get install -y gcc g++ python3-dev | |
sudo apt-get install unzip | |
- name: Checkout code (workflow_dispatch) | |
if: github.event_name == 'workflow_dispatch' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ inputs.branch_to_test }} | |
- name: Checkout code (pull_request_review) | |
if: github.event_name == 'pull_request_review' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- name: Setup npm cache/install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install node dependencies | |
run: | | |
cd ai-verify-shared-library | |
npm install | |
npm run build | |
cd ../ai-verify-apigw | |
#cp .env.development .env | |
npm install --omit=dev | |
cd ../ai-verify-portal | |
npm install --omit=dev | |
npm link ../ai-verify-shared-library | |
echo "APIGW_URL=http://127.0.0.1:4000 | |
MONGODB_URI=mongodb://aiverify:[email protected]:27017/aiverify | |
REDIS_URI=redis://127.0.0.1:6379 | |
TEST_ENGINE_URL=http://127.0.0.1:8080" > .env.local | |
#cp .env.development .env.local | |
npm run build | |
- name: Setup pip cache/install | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Install python dependencies | |
run: | | |
pip install test-engine-core/dist/test_engine_core-*.tar.gz | |
find ./ -type f -name 'requirements.txt' -exec pip install -r "{}" \; | |
- name: Install stock plugins | |
run: | | |
mkdir -p ai-verify-portal/plugins | |
cd stock-plugins | |
for plugin_dir in *; do | |
echo "Unzipping plugin $plugin_dir"; | |
unzip $plugin_dir/dist/*.zip -d ../ai-verify-portal/plugins/$plugin_dir; | |
done | |
- name: Run aiverify services | |
run: | | |
sudo systemctl restart mongod | |
sudo systemctl restart redis-server | |
wdir=$(pwd) | |
cd test-engine-app | |
echo "CORE_MODULES_FOLDER=\"$wdir/test-engine-core-modules\" | |
VALIDATION_SCHEMAS_FOLDER=\"$wdir/test-engine-app/test_engine_app/validation_schemas/\" | |
REDIS_CONSUMER_GROUP=\"MyGroup\" | |
REDIS_SERVER_HOSTNAME=\"127.0.0.1\" | |
REDIS_SERVER_PORT=6379 | |
API_SERVER_PORT=8080" > .env | |
python3 -m test_engine_app &>engine.log & | |
cd ../ai-verify-apigw | |
echo "MONGODB_URI=\"mongodb://aiverify:[email protected]:27017/aiverify\" | |
DB_URI=\"mongodb://aiverify:[email protected]:27017/aiverify\" | |
WEB_REPORT_URL=\"http://127.0.0.1:3000/reportStatus/printview\" | |
REDIS_HOST=\"localhost\" | |
REDIS_PORT=6379 | |
DB_HOST=127.0.0.1 | |
DB_PORT=27017 | |
DB_USERNAME=aiverify | |
DB_PASSWORD=t1oj5L_xQI8dTrVuZ | |
ALLOWED_ORIGINS=http://127.0.0.1:3000,http://127.0.0.1:3001,http://127.0.0.1:4000" > .env | |
node app.mjs &> apigw.log & | |
cd ../ai-verify-portal | |
npm run start &> portal.log & | |
- name: Checkout API Mock Server | |
uses: actions/checkout@v3 | |
with: | |
repository: aiverify-foundation/api-model-server | |
ref: main | |
path: qa-test/api-model-server | |
- name: Checkout smoke tests | |
uses: actions/checkout@v3 | |
with: | |
repository: aiverify-foundation/smoke-testing | |
ref: main | |
path: qa-test/smoke-testing | |
submodules: recursive | |
- name: Checkout frontend tests | |
uses: actions/checkout@v3 | |
with: | |
repository: aiverify-foundation/frontend-testing | |
ref: main | |
path: qa-test/frontend-testing | |
- name: Checkout backend tests | |
uses: actions/checkout@v3 | |
with: | |
repository: aiverify-foundation/backend-testing | |
ref: main | |
path: qa-test/backend-testing | |
submodules: recursive | |
- name: Run API Mock Server | |
if: ${{ ! cancelled() }} | |
run: | | |
cd qa-test/api-model-server | |
python3 -m venv venv | |
source venv/bin/activate | |
pip3 install -r requirements.txt | |
bash regression_run_https.sh && fg & | |
bash classification_run_https.sh & | |
- name: Run smoke tests | |
if: ${{ ! cancelled() }} | |
run: | | |
cd qa-test/smoke-testing | |
npm install | |
npx playwright install | |
ENVIRONMENT_URL=https://127.0.0.1 npx playwright test | |
- name: Run frontend tests | |
if: ${{ ! cancelled() }} | |
run: | | |
cd qa-test/frontend-testing | |
npm install | |
ENVIRONMENT_URL=https://127.0.0.1 npx playwright test | |
- name: Run backend tests | |
if: ${{ ! cancelled() }} | |
run: | | |
cd qa-test/backend-testing | |
npm install | |
BASEDIR=${{ github.workspace }} npx playwright test | |
- name: Show logs | |
if: ${{ ! cancelled() }} | |
run: | | |
echo "================= Start of test-engine log =================" | |
cat test-engine-app/engine.log | |
echo "================= Start of apigw log =================" | |
cat ai-verify-apigw/apigw.log | |
echo "================= Start of portal log =================" | |
cat ai-verify-portal/portal.log | |