Files
onyx/.github/workflows/pr-database-tests.yml
T

94 lines
3.1 KiB
YAML

name: Database Tests
concurrency:
group: Database-Tests-${{ github.workflow }}-${{ github.head_ref || github.event.workflow_run.head_branch || github.run_id }}
cancel-in-progress: true
on:
merge_group:
pull_request:
branches:
- main
- "release/**"
push:
tags:
- "v*.*.*"
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
db: ${{ steps.filter.outputs.db || 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
with:
persist-credentials: false
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # ratchet:dorny/paths-filter@v3
id: filter
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
with:
filters: |
db:
- 'backend/**'
- 'tools/ods/**'
- 'pyproject.toml'
- 'deployment/docker_compose/docker-compose.yml'
- 'deployment/docker_compose/docker-compose.dev.yml'
- '.github/workflows/pr-database-tests.yml'
- '.github/actions/setup-python-and-install-dependencies/**'
database-tests:
needs: changes
if: needs.changes.outputs.db == 'true'
runs-on:
- runs-on
- runner=2cpu-linux-arm64
- "run-id=${{ github.run_id }}-database-tests"
timeout-minutes: 45
steps:
- uses: runs-on/action@d141ef83eb66d096ce8afc767e09115a65c63b60
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
with:
persist-credentials: false
- name: Setup Python and Install Dependencies
uses: ./.github/actions/setup-python-and-install-dependencies
with:
requirements: |
backend/requirements/default.txt
backend/requirements/dev.txt
- name: Generate OpenAPI schema and Python client
shell: bash
# OpenAPI client codegen does not handle some EE-only schema shapes;
# disable enforcement so the MIT route set is exported.
env:
LICENSE_ENFORCEMENT_ENABLED: "false"
run: |
ods openapi all
# needed for pulling external images otherwise, we hit the "Unauthenticated users" limit
# https://docs.docker.com/docker-hub/usage/
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Start Docker containers
working-directory: ./deployment/docker_compose
run: |
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d \
relational_db
- name: Run Database Tests
working-directory: ./backend
run: pytest tests/integration/tests/migrations/