Skip to content

Integration Test

Integration Test #59

# GitHub Action for performing Integration Tests on the API
# Author: Andrew Jarombek
# Date: 10/8/2022
name: Integration Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
schedule:
- cron: "0 5 * * 5"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
container: ajarombek/saints-xctf-api-cicd:latest
timeout-minutes: 5
services:
db:
image: mysql:5.7.36
env:
MYSQL_ROOT_PASSWORD: saintsxctf
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
auth:
image: ajarombek/mock-saints-xctf-auth
functions:
image: ajarombek/mock-saints-xctf-functions
steps:
- run: echo "Job running on a ${{ runner.os }} server"
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup Database
working-directory: ./api/src
run: |
mysql --protocol=tcp -h db -u root --password=saintsxctf -e "DROP USER IF EXISTS 'saintsxctflocal'@'%'" -v
mysql --protocol=tcp -h db -u root --password=saintsxctf -e "CREATE USER 'saintsxctflocal'@'%' IDENTIFIED BY 'saintsxctf'" -v
mysql --protocol=tcp -h db -u root --password=saintsxctf -e "CREATE DATABASE IF NOT EXISTS saintsxctf" -v
mysql --protocol=tcp -h db -u root --password=saintsxctf -e "GRANT ALL ON saintsxctf.* TO 'saintsxctflocal'@'%'" -v
mysql --protocol=tcp -h db -u saintsxctflocal -D saintsxctf --password=saintsxctf -v < test-db-init.sql
mysql --protocol=tcp -h db -u saintsxctflocal -D saintsxctf --password=saintsxctf -v < test-db-update.sql
- name: Create Log File
working-directory: /
run: |
mkdir logs
cd logs
touch saints-xctf-api.log
- name: Install libraries
working-directory: ./api/src
run: pipenv install --ignore-pipfile
- name: Run tests
working-directory: ./api/src
run: pipenv run flask test
env:
FLASK_ENV: cicdtest
ENV: cicdtest