Scheduling infrastructure for absolutely everyone.
ci: simplify DB cache key and skip yarn-install on cache hit (#26344)
Keith Williams16f6099e46ef
diff --git a/.github/actions/cache-db-key/action.yml b/.github/actions/cache-db-key/action.ymlnew file mode 100644index 00000000000..f8bd9211bca--- /dev/null+++ b/.github/actions/cache-db-key/action.yml@@ -0,0 +1,23 @@+name: Generate cache-db key+description: "Generate the cache key for database caching"+inputs:+ path:+ required: false+ default: "backups/backup.sql"+ description: "Path to the backup file"+outputs:+ key:+ description: "The generated cache key"+ value: ${{ steps.generate-key.outputs.key }}+runs:+ using: "composite"+ steps:+ - name: Generate cache key+ id: generate-key+ shell: bash+ env:+ CACHE_NAME: cache-db+ PATH_KEY: ${{ inputs.path }}+ PRISMA_HASH: ${{ hashFiles('packages/prisma/schema.prisma', 'packages/prisma/migrations/**/**.sql', 'packages/prisma/*.ts') }}+ run: |+ echo "key=${CACHE_NAME}-${PATH_KEY}-${PRISMA_HASH}" >> $GITHUB_OUTPUTdiff --git a/.github/actions/cache-db/action.yml b/.github/actions/cache-db/action.ymlindex 876bebd2a16..ec5738e4267 100644--- a/.github/actions/cache-db/action.yml+++ b/.github/actions/cache-db/action.yml@@ -7,21 +7,18 @@ inputs:path:required: falsedefault: "backups/backup.sql"- COMMIT_SHA:- required: false- default: ""- description: "Commit SHA to include in cache key (passed from workflow)"runs:using: "composite"steps:+ - name: Generate cache key+ id: cache-key+ uses: ./.github/actions/cache-db-key+ with:+ path: ${{ inputs.path }}- name: Cache databaseid: cache-dbuses: actions/cache@v4env:- cache-name: cache-db- key-1: ${{ hashFiles('packages/prisma/schema.prisma', 'packages/prisma/migrations/**/**.sql', 'packages/prisma/*.ts') }}- key-2: ${{ github.event.pull_request.number || github.ref }}- key-3: ${{ inputs.COMMIT_SHA || github.event.pull_request.head.sha || github.sha }}DATABASE_URL: ${{ inputs.DATABASE_URL }}DATABASE_DIRECT_URL: ${{ inputs.DATABASE_URL }}E2E_TEST_CALCOM_QA_EMAIL: ${{ inputs.E2E_TEST_CALCOM_QA_EMAIL }}@@ -29,7 +26,7 @@ runs:E2E_TEST_CALCOM_QA_GCAL_CREDENTIALS: ${{ inputs.E2E_TEST_CALCOM_QA_GCAL_CREDENTIALS }}with:path: ${{ inputs.path }}- key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.path }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}+ key: ${{ steps.cache-key.outputs.key }}- run: yarn db-seedif: steps.cache-db.outputs.cache-hit != 'true'shell: bashdiff --git a/.github/workflows/pr.yml b/.github/workflows/pr.ymlindex d15fcc6c45c..d0df09ea1ad 100644--- a/.github/workflows/pr.yml+++ b/.github/workflows/pr.yml@@ -161,9 +161,20 @@ jobs:has_companion: ${{ steps.filter.outputs.has_companion }}commit-sha: ${{ steps.get_sha.outputs.commit-sha }}run-e2e: ${{ steps.check-if-pr-has-label.outputs.run-e2e == 'true' }}+ db-cache-hit: ${{ steps.cache-db-check.outputs.cache-hit }}steps:- uses: actions/checkout@v4- uses: ./.github/actions/dangerous-git-checkout+ - name: Generate DB cache key+ id: cache-db-key+ uses: ./.github/actions/cache-db-key+ - name: Check DB cache (lookup-only)+ id: cache-db-check+ uses: actions/cache/restore@v4+ with:+ path: backups/backup.sql+ key: ${{ steps.cache-db-key.outputs.key }}+ lookup-only: true- uses: dorny/paths-filter@v3id: filterwith:@@ -288,7 +299,7 @@ jobs:if: ${{ needs.prepare.outputs.run-e2e == 'true' && needs.prepare.outputs.has-files-requiring-all-checks == 'true' }}uses: ./.github/workflows/setup-db.ymlwith:- COMMIT_SHA: ${{ needs.prepare.outputs.commit-sha }}+ DB_CACHE_HIT: ${{ needs.prepare.outputs.db-cache-hit }}secrets: inheritbuild-api-v1:diff --git a/.github/workflows/setup-db.yml b/.github/workflows/setup-db.ymlindex 468dbbabbd7..a4618d1fb92 100644--- a/.github/workflows/setup-db.yml+++ b/.github/workflows/setup-db.yml@@ -3,11 +3,11 @@ name: Setup Databaseon:workflow_call:inputs:- COMMIT_SHA:+ DB_CACHE_HIT:required: falsetype: string- default: ""- description: "Commit SHA to include in cache key"+ default: "false"+ description: "Whether the DB cache was hit (skip yarn-install and cache-db if true)"permissions:contents: read@@ -49,6 +49,6 @@ jobs:- uses: actions/checkout@v4- uses: ./.github/actions/dangerous-git-checkout- uses: ./.github/actions/yarn-install+ if: inputs.DB_CACHE_HIT != 'true'- uses: ./.github/actions/cache-db- with:- COMMIT_SHA: ${{ inputs.COMMIT_SHA || github.sha }}+ if: inputs.DB_CACHE_HIT != 'true'