restore-tenancy.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # Job numbering reads the database with a raw pattern query.
  14. - 'src/lib/job-number.ts'
  15. # A vehicle's reading is moved and corrected in the database's own
  16. # WHERE, under a row lock; the rule and every writer of it.
  17. - 'src/features/vehicles/Lib/vehicleReading.ts'
  18. - 'src/features/vehicles/Actions/serviceActions.ts'
  19. - 'src/features/vehicles/Actions/vehicleActions.ts'
  20. - 'src/app/api/v1/tech/jobs/*/checkin/route.ts'
  21. - 'prisma/**'
  22. - 'vitest.db.config.ts'
  23. - '.github/workflows/restore-tenancy.yml'
  24. workflow_dispatch:
  25. concurrency:
  26. group: restore-tenancy-${{ github.ref }}
  27. cancel-in-progress: true
  28. jobs:
  29. restore-tenancy:
  30. name: Restore never touches another workshop
  31. runs-on: ubuntu-latest
  32. timeout-minutes: 20
  33. services:
  34. postgres:
  35. image: postgres:16-alpine
  36. env:
  37. POSTGRES_USER: torqvoice
  38. POSTGRES_PASSWORD: torqvoice
  39. # The name carries "test": the suite refuses a database that does not.
  40. POSTGRES_DB: torqvoice_restore_test
  41. ports:
  42. - 5432:5432
  43. options: >-
  44. --health-cmd "pg_isready -U torqvoice -d torqvoice_restore_test"
  45. --health-interval 10s
  46. --health-timeout 5s
  47. --health-retries 5
  48. env:
  49. E2E_DATABASE_URL: postgresql://torqvoice:torqvoice@127.0.0.1:5432/torqvoice_restore_test
  50. steps:
  51. - uses: actions/checkout@v4
  52. - uses: actions/setup-node@v4
  53. with:
  54. node-version: 22
  55. cache: npm
  56. - name: Install
  57. run: npm ci
  58. - name: Generate the Prisma client
  59. run: npx prisma generate
  60. - name: Apply every migration to the empty database
  61. run: npx prisma migrate deploy
  62. env:
  63. DATABASE_URL: ${{ env.E2E_DATABASE_URL }}
  64. - name: Run the differential restore test
  65. run: npm run test:db