Scheduling infrastructure for absolutely everyone.
feat: implement git checkout caching to speed up CI workflows (#26636)
Keith Williamscbb56f6a618b
diff --git a/.github/actions/cache-checkout/action.yml b/.github/actions/cache-checkout/action.ymlnew file mode 100644index 00000000000..514d8e4c007--- /dev/null+++ b/.github/actions/cache-checkout/action.yml@@ -0,0 +1,40 @@+name: Cache Git Checkout+description: "Save or restore git checkout from cache to speed up CI workflows"+inputs:+ mode:+ description: "Mode of operation: 'save' to cache the checkout, 'restore' to restore from cache"+ required: true++runs:+ using: "composite"+ steps:+ - name: Restore git checkout from cache+ if: ${{ inputs.mode == 'restore' }}+ uses: actions/cache/restore@v4+ id: cache-restore+ with:+ path: |+ .+ !.git+ !node_modules+ !**/node_modules+ key: git-checkout-${{ github.head_ref || github.ref_name }}-${{ github.sha }}+ fail-on-cache-miss: true++ - name: Delete previous git-checkout caches for this branch+ if: ${{ inputs.mode == 'save' }}+ uses: useblacksmith/cache-delete@v1+ with:+ key: git-checkout-${{ github.head_ref || github.ref_name }}-+ prefix: "true"++ - name: Save git checkout to cache+ if: ${{ inputs.mode == 'save' }}+ uses: actions/cache/save@v4+ with:+ path: |+ .+ !.git+ !node_modules+ !**/node_modules+ key: git-checkout-${{ github.head_ref || github.ref_name }}-${{ github.sha }}diff --git a/.github/actions/dangerous-git-checkout/action.yml b/.github/actions/dangerous-git-checkout/action.ymlindex c2dccc4e290..6a3dd50f87d 100644--- a/.github/actions/dangerous-git-checkout/action.yml+++ b/.github/actions/dangerous-git-checkout/action.yml@@ -8,3 +8,8 @@ runs:with:ref: ${{ github.event.pull_request.head.sha }}fetch-depth: 2+ sparse-checkout-cone-mode: false+ sparse-checkout: |+ /*+ !/example-apps/+ !**/*.mp4diff --git a/.github/workflows/api-v1-production-build.yml b/.github/workflows/api-v1-production-build.ymlindex 26d08fa9e80..380340d37d1 100644--- a/.github/workflows/api-v1-production-build.yml+++ b/.github/workflows/api-v1-production-build.yml@@ -65,7 +65,11 @@ jobs:- 5432:5432steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- uses: ./.github/actions/cache-db- name: Cache API v1 production builddiff --git a/.github/workflows/api-v2-production-build.yml b/.github/workflows/api-v2-production-build.ymlindex 177199661f6..2d2e9cb4721 100644--- a/.github/workflows/api-v2-production-build.yml+++ b/.github/workflows/api-v2-production-build.yml@@ -35,7 +35,11 @@ jobs:- 5432:5432steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- name: Generate Prisma schemasworking-directory: apps/api/v2diff --git a/.github/workflows/api-v2-unit-tests.yml b/.github/workflows/api-v2-unit-tests.ymlindex 5c6fd7b69c4..bc33f8b4a85 100644--- a/.github/workflows/api-v2-unit-tests.yml+++ b/.github/workflows/api-v2-unit-tests.yml@@ -12,7 +12,11 @@ jobs:runs-on: blacksmith-4vcpu-ubuntu-2404steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- run: yarn prisma generate- name: Run API v2 unit testsdiff --git a/.github/workflows/atoms-production-build.yml b/.github/workflows/atoms-production-build.ymlindex b8fc029acce..ef6f9a42105 100644--- a/.github/workflows/atoms-production-build.yml+++ b/.github/workflows/atoms-production-build.yml@@ -12,7 +12,11 @@ jobs:timeout-minutes: 30steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- name: Cache atoms production builduses: actions/cache@v4diff --git a/.github/workflows/check-api-v2-breaking-changes.yml b/.github/workflows/check-api-v2-breaking-changes.ymlindex b41d3b719b7..270f0bd08cc 100644--- a/.github/workflows/check-api-v2-breaking-changes.yml+++ b/.github/workflows/check-api-v2-breaking-changes.yml@@ -34,7 +34,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- name: Generate Swaggerdiff --git a/.github/workflows/check-types.yml b/.github/workflows/check-types.ymlindex f640b75d963..bd2da476723 100644--- a/.github/workflows/check-types.yml+++ b/.github/workflows/check-types.yml@@ -12,7 +12,11 @@ jobs:runs-on: blacksmith-4vcpu-ubuntu-2404steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- name: Show inforun: node -e "console.log(require('v8').getHeapStatistics())"diff --git a/.github/workflows/companion-build.yml b/.github/workflows/companion-build.ymlindex 12985b43eb2..58cd1be35d9 100644--- a/.github/workflows/companion-build.yml+++ b/.github/workflows/companion-build.yml@@ -17,7 +17,11 @@ jobs:steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- name: Setup Bunuses: oven-sh/setup-bun@v1diff --git a/.github/workflows/delete-blacksmith-cache.yml b/.github/workflows/delete-blacksmith-cache.ymlindex 26addc991fe..5a84df5f482 100644--- a/.github/workflows/delete-blacksmith-cache.yml+++ b/.github/workflows/delete-blacksmith-cache.yml@@ -31,3 +31,13 @@ jobs:with:key: ${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.ref }}prefix: "true"++ delete-git-checkout-cache-on-pr-close:+ if: github.event_name == 'pull_request' && github.event.action == 'closed'+ runs-on: blacksmith-2vcpu-ubuntu-2404+ steps:+ - name: Delete git-checkout cache+ uses: useblacksmith/cache-delete@v1+ with:+ key: git-checkout-${{ github.event.pull_request.head.ref }}-+ prefix: "true"diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.ymlindex ccf44ed8a6a..6e869ff753b 100644--- a/.github/workflows/docs-build.yml+++ b/.github/workflows/docs-build.yml@@ -12,7 +12,11 @@ jobs:runs-on: blacksmith-2vcpu-ubuntu-2404steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- name: Cache Docs builduses: actions/cache@v4id: cache-docs-builddiff --git a/.github/workflows/e2e-api-v2.yml b/.github/workflows/e2e-api-v2.ymlindex 267c6baf958..9656c4b4737 100644--- a/.github/workflows/e2e-api-v2.yml+++ b/.github/workflows/e2e-api-v2.yml@@ -74,7 +74,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- uses: ./.github/actions/cache-db- name: Build platform packages with Turbodiff --git a/.github/workflows/e2e-app-store.yml b/.github/workflows/e2e-app-store.ymlindex e3e1774c805..d7bede4762d 100644--- a/.github/workflows/e2e-app-store.yml+++ b/.github/workflows/e2e-app-store.yml@@ -81,7 +81,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- uses: ./.github/actions/yarn-playwright-install- run: yarn prisma generatediff --git a/.github/workflows/e2e-embed-react.yml b/.github/workflows/e2e-embed-react.ymlindex a58cac84840..5ece5472a75 100644--- a/.github/workflows/e2e-embed-react.yml+++ b/.github/workflows/e2e-embed-react.yml@@ -73,7 +73,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- uses: ./.github/actions/yarn-playwright-install- run: yarn prisma generatediff --git a/.github/workflows/e2e-embed.yml b/.github/workflows/e2e-embed.ymlindex c3b9b5e3c64..eec3307fc36 100644--- a/.github/workflows/e2e-embed.yml+++ b/.github/workflows/e2e-embed.yml@@ -81,7 +81,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- uses: ./.github/actions/yarn-playwright-install- run: yarn prisma generatediff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex 54a20cb066c..8495fef8231 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -82,7 +82,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- uses: ./.github/actions/yarn-playwright-install- run: yarn prisma generatediff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.ymlindex 83605ea5ccb..1ea84258531 100644--- a/.github/workflows/integration-tests.yml+++ b/.github/workflows/integration-tests.yml@@ -79,7 +79,11 @@ jobs:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- run: yarn prisma generate- uses: ./.github/actions/cache-dbdiff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 76dd0d24a40..a141c1579f2 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -10,7 +10,11 @@ jobs:steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- name: Run Lintrun: yarn lintdiff --git a/.github/workflows/pr.yml b/.github/workflows/pr.ymlindex 3a05287fdfb..b99abd9df86 100644--- a/.github/workflows/pr.yml+++ b/.github/workflows/pr.yml@@ -175,6 +175,10 @@ jobs:steps:- uses: actions/checkout@v4- uses: ./.github/actions/dangerous-git-checkout+ - name: Cache git checkout+ uses: ./.github/actions/cache-checkout+ with:+ mode: save- name: Generate DB cache keyid: cache-db-keyuses: ./.github/actions/cache-db-keydiff --git a/.github/workflows/production-build-without-database.yml b/.github/workflows/production-build-without-database.ymlindex 78920c5fb67..512efe6ac71 100644--- a/.github/workflows/production-build-without-database.yml+++ b/.github/workflows/production-build-without-database.yml@@ -43,7 +43,11 @@ jobs:timeout-minutes: 30steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- run: yarn prisma generate- name: Generate cache keydiff --git a/.github/workflows/setup-db.yml b/.github/workflows/setup-db.ymlindex f0634a0c685..66e4ea042fd 100644--- a/.github/workflows/setup-db.yml+++ b/.github/workflows/setup-db.yml@@ -47,7 +47,11 @@ jobs:- 5432:5432steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-installif: inputs.DB_CACHE_HIT != 'true'- run: yarn prisma generatediff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.ymlindex a922ec9698a..532ddb77a81 100644--- a/.github/workflows/unit-tests.yml+++ b/.github/workflows/unit-tests.yml@@ -12,7 +12,11 @@ jobs:runs-on: blacksmith-4vcpu-ubuntu-2404steps:- uses: actions/checkout@v4- - uses: ./.github/actions/dangerous-git-checkout+ with:+ sparse-checkout: .github+ - uses: ./.github/actions/cache-checkout+ with:+ mode: restore- uses: ./.github/actions/yarn-install- run: yarn prisma generate- run: yarn test -- --no-isolate