Integration Tests #14
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: | |
inputs: | |
COMMIT_HASH: | |
description: 'The SHA of the Git commit to use' | |
required: false | |
type: string | |
default: refs/heads/main | |
# or on push to main | |
push: | |
branches: | |
- 'main' | |
workflow_call: | |
inputs: | |
COMMIT_HASH: | |
description: 'The SHA of the Git commit to use' | |
required: false | |
type: string | |
default: refs/heads/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.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.11" | |
- 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/slack-github-action@v1.24.0 | |
if: ${{ failure() && github.event_name == 'schedule' }} | |
with: | |
channel-id: 'C05D67P6M34' | |
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_NOTIFICATIONS_TOKEN }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
- name: notify slack pass | |
id: slack-pass | |
uses: slackapi/slack-github-action@v1.24.0 | |
if: ${{ success() && github.event_name == 'schedule' }} | |
with: | |
channel-id: 'C05D67P6M34' | |
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_NOTIFICATIONS_TOKEN }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
- name: Dump logs | |
if: failure() | |
uses: jwalton/gh-docker-logs@v2 |