Skip to content

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.yml
new file mode 100644
index 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.yml
index 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/
+ !**/*.mp4
diff --git a/.github/workflows/api-v1-production-build.yml b/.github/workflows/api-v1-production-build.yml
index 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:5432
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
- uses: ./.github/actions/cache-db
- name: Cache API v1 production build
diff --git a/.github/workflows/api-v2-production-build.yml b/.github/workflows/api-v2-production-build.yml
index 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:5432
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: Generate Prisma schemas
working-directory: apps/api/v2
diff --git a/.github/workflows/api-v2-unit-tests.yml b/.github/workflows/api-v2-unit-tests.yml
index 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-2404
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
- run: yarn prisma generate
- name: Run API v2 unit tests
diff --git a/.github/workflows/atoms-production-build.yml b/.github/workflows/atoms-production-build.yml
index b8fc029acce..ef6f9a42105 100644
--- a/.github/workflows/atoms-production-build.yml
+++ b/.github/workflows/atoms-production-build.yml
@@ -12,7 +12,11 @@ jobs:
timeout-minutes: 30
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: Cache atoms production build
uses: actions/cache@v4
diff --git a/.github/workflows/check-api-v2-breaking-changes.yml b/.github/workflows/check-api-v2-breaking-changes.yml
index 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 Swagger
diff --git a/.github/workflows/check-types.yml b/.github/workflows/check-types.yml
index 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-2404
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: Show info
run: node -e "console.log(require('v8').getHeapStatistics())"
diff --git a/.github/workflows/companion-build.yml b/.github/workflows/companion-build.yml
index 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 Bun
uses: oven-sh/setup-bun@v1
diff --git a/.github/workflows/delete-blacksmith-cache.yml b/.github/workflows/delete-blacksmith-cache.yml
index 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.yml
index 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-2404
steps:
- 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 build
uses: actions/cache@v4
id: cache-docs-build
diff --git a/.github/workflows/e2e-api-v2.yml b/.github/workflows/e2e-api-v2.yml
index 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 Turbo
diff --git a/.github/workflows/e2e-app-store.yml b/.github/workflows/e2e-app-store.yml
index 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 generate
diff --git a/.github/workflows/e2e-embed-react.yml b/.github/workflows/e2e-embed-react.yml
index 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 generate
diff --git a/.github/workflows/e2e-embed.yml b/.github/workflows/e2e-embed.yml
index 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 generate
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 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 generate
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
index 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-db
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 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 Lint
run: yarn lint
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 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 key
id: cache-db-key
uses: ./.github/actions/cache-db-key
diff --git a/.github/workflows/production-build-without-database.yml b/.github/workflows/production-build-without-database.yml
index 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: 30
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
- run: yarn prisma generate
- name: Generate cache key
diff --git a/.github/workflows/setup-db.yml b/.github/workflows/setup-db.yml
index f0634a0c685..66e4ea042fd 100644
--- a/.github/workflows/setup-db.yml
+++ b/.github/workflows/setup-db.yml
@@ -47,7 +47,11 @@ jobs:
- 5432:5432
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
if: inputs.DB_CACHE_HIT != 'true'
- run: yarn prisma generate
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 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-2404
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
- run: yarn prisma generate
- run: yarn test -- --no-isolate