restore-tenancy.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. name: Restore tenancy
  2. # The differential test of the backup restore against a real PostgreSQL:
  3. # two workshops, a restore into one of them, and a row-by-row comparison
  4. # that the other was never touched. It runs when the restore or the schema
  5. # changes, since that is when it could start being wrong.
  6. on:
  7. pull_request:
  8. branches: [main]
  9. paths:
  10. - 'src/lib/backup/**'
  11. - 'src/app/api/protected/backup/**'
  12. - 'src/__tests__/db/**'
  13. - 'prisma/**'
  14. - 'vitest.db.config.ts'
  15. - '.github/workflows/restore-tenancy.yml'
  16. workflow_dispatch:
  17. concurrency:
  18. group: restore-tenancy-${{ github.ref }}
  19. cancel-in-progress: true
  20. jobs:
  21. restore-tenancy:
  22. name: Restore never touches another workshop
  23. runs-on: ubuntu-latest
  24. timeout-minutes: 20
  25. services:
  26. postgres:
  27. image: postgres:16-alpine
  28. env:
  29. POSTGRES_USER: torqvoice
  30. POSTGRES_PASSWORD: torqvoice
  31. # The name carries "test": the suite refuses a database that does not.
  32. POSTGRES_DB: torqvoice_restore_test
  33. ports:
  34. - 5432:5432
  35. options: >-
  36. --health-cmd "pg_isready -U torqvoice -d torqvoice_restore_test"
  37. --health-interval 10s
  38. --health-timeout 5s
  39. --health-retries 5
  40. env:
  41. E2E_DATABASE_URL: postgresql://torqvoice:torqvoice@127.0.0.1:5432/torqvoice_restore_test
  42. steps:
  43. - uses: actions/checkout@v4
  44. - uses: actions/setup-node@v4
  45. with:
  46. node-version: 22
  47. cache: npm
  48. - name: Install
  49. run: npm ci
  50. - name: Generate the Prisma client
  51. run: npx prisma generate
  52. - name: Apply every migration to the empty database
  53. run: npx prisma migrate deploy
  54. env:
  55. DATABASE_URL: ${{ env.E2E_DATABASE_URL }}
  56. - name: Run the differential restore test
  57. run: npm run test:db