Caches DB

pull/7267/head
zomars 2023-02-21 11:27:22 -07:00
parent f5e96ba3f1
commit 747ad8513f
5 changed files with 46 additions and 0 deletions

34
.github/actions/cache-db/action.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Cache databse between jobs
description: "Cache or restore if necessary"
inputs:
DATABASE_URL:
required: true
path:
required: false
default: "backups/backup.sql"
runs:
using: "composite"
steps:
- name: Cache database
id: cache-db
uses: actions/cache@v3
env:
cache-name: cache-db
with:
path: ${{ inputs.path }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-
- name: Postgres Dump Backup
if: steps.cache-db.outputs.cache-hit != 'true'
uses: tj-actions/pg-dump@v2.3
with:
database_url: ${{ inputs.DATABASE_URL }}
path: ${{ inputs.path }}
options: "-O"
- name: Postgres Backup Restore
if: steps.cache-db.outputs.cache-hit == 'true'
uses: tj-actions/pg-restore@v4.5
with:
database_url: ${{ inputs.DATABASE_URL }}
backup_file: ${{ inputs.path }}

View File

@ -53,6 +53,9 @@ jobs:
- run: echo 'NODE_OPTIONS="--max_old_space_size=4096"' >> $GITHUB_ENV
- uses: ./.github/actions/yarn-install
- uses: ./.github/actions/yarn-playwright-install
- uses: ./.github/actions/cache-db
with:
DATABASE_URL: postgresql://postgres:@localhost:5432/calendso
- name: Run Tests
run: yarn test-e2e:app-store

View File

@ -57,6 +57,9 @@ jobs:
- run: echo 'NODE_OPTIONS="--max_old_space_size=4096"' >> $GITHUB_ENV
- uses: ./.github/actions/yarn-install
- uses: ./.github/actions/yarn-playwright-install
- uses: ./.github/actions/cache-db
with:
DATABASE_URL: postgresql://postgres:@localhost:5432/calendso
- name: Run Tests
run: yarn turbo run embed-tests-update-snapshots:ci --scope=@calcom/embed-react --concurrency=1
- name: Upload embed-core results

View File

@ -60,6 +60,9 @@ jobs:
- run: echo 'NODE_OPTIONS="--max_old_space_size=4096"' >> $GITHUB_ENV
- uses: ./.github/actions/yarn-install
- uses: ./.github/actions/yarn-playwright-install
- uses: ./.github/actions/cache-db
with:
DATABASE_URL: postgresql://postgres:@localhost:5432/calendso
- run: yarn test-e2e
- name: Upload test results
if: ${{ always() }}

View File

@ -80,3 +80,6 @@ jobs:
NEXT_PUBLIC_IS_E2E: ${{ env.NEXT_PUBLIC_IS_E2E }}
TURBO_TOKEN: ${{ env.TURBO_TOKEN }}
TURBO_TEAM: ${{ env.TURBO_TEAM }}
- uses: ./.github/actions/cache-db
with:
DATABASE_URL: ${{ env.DATABASE_URL }}