Integration Tests #311
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 workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Integration Tests | |
env: | |
ENVIRONMENT: INTEGRATION | |
on: | |
# weekday mealtimes | |
schedule: | |
- cron: '0 6,12,18 * * 1-5' | |
# or on-demand | |
workflow_dispatch: | |
# or on push to main | |
push: | |
branches: | |
- 'main' | |
permissions: | |
contents: read | |
jobs: | |
backend-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.COMMIT_HASH }} | |
path: integration | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: false | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.12" | |
- name: Set up Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: 1.7.0 | |
- name: Build Containers | |
run: | | |
cd integration | |
mkdir -p data/elastic/ | |
chmod -R 777 data/ | |
cp .env.integration .env | |
echo AZURE_OPENAI_ENDPOINT=${{ secrets.AZURE_OPENAI_ENDPOINT }} >> .env | |
echo AZURE_OPENAI_API_KEY=${{ secrets.AZURE_OPENAI_API_KEY }} >> .env | |
echo AZURE_OPENAI_MODEL=azure/gpt-4-turbo-2024-04-09 >> .env | |
docker compose up -d --wait core-api django-app | |
docker ps | |
- name: Test integration with pytest | |
run: | | |
cd integration | |
poetry install --only dev | |
poetry run playwright install --with-deps chromium | |
poetry run pytest tests/ --browser chromium | |
- name: notify slack failure | |
id: slack-failure | |
uses: slackapi/[email protected] | |
if: ${{ failure() && github.event_name == 'schedule' }} | |
with: | |
payload: | | |
{ | |
"text": "Scheduled Integration Tests Failed", | |
"blocks": [ | |
{ | |
"type": "header", | |
"text": { | |
"type": "plain_text", | |
"text": "Scheduled integration tests are failing :alert:" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "actions", | |
"elements": [ | |
{ | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": "logs" | |
}, | |
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
] | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
- name: notify slack pass | |
id: slack-pass | |
uses: slackapi/[email protected] | |
if: ${{ success() && github.event_name == 'schedule' }} | |
with: | |
payload: | | |
{ | |
"text": "Scheduled Integration Tests Passed", | |
"blocks": [ | |
{ | |
"type": "header", | |
"text": { | |
"type": "plain_text", | |
"text": "Scheduled integration tests are passing :white_check_mark:" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
- name: Dump logs | |
if: failure() | |
uses: jwalton/gh-docker-logs@v2 |