Skip to content

Commit e79f534

Browse files
authored
chore(ci): more optimisations for writecache pipeline (#5485)
1 parent d676202 commit e79f534

File tree

1 file changed

+64
-26
lines changed

1 file changed

+64
-26
lines changed

.github/workflows/writecache.yml

+64-26
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ on:
66
concurrency:
77
group: ${{ github.ref }}-writecache
88
cancel-in-progress: true
9-
name: Write Cache
9+
name: Write Hermit Cache
1010
jobs:
11-
write-os-specific-cache:
11+
write-hermit-cache:
1212
strategy:
1313
matrix:
1414
runner: [ubuntu-latest, ftl]
15-
name: Write Cache
15+
name: Write Hermit Cache
1616
runs-on: ${{ matrix.runner }}
1717
steps:
1818
- name: Checkout code
@@ -31,43 +31,86 @@ jobs:
3131
echo "key=$key" >> "$GITHUB_OUTPUT"
3232
exists="$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/block/ftl/actions/caches?key=$key" | jq '.actions_caches | length')"
3333
echo "exists=$exists" >> "$GITHUB_OUTPUT"
34+
- name: Install Hermit Packages
35+
if: ${{ steps.hermit-hash.outputs.exists == 0 }}
36+
run: hermit install
3437
- name: Save Hermit Cache
3538
if: ${{ steps.hermit-hash.outputs.exists == 0 }}
3639
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # ratchet:actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
3740
with:
3841
path: ${{ runner.os == 'macOS' && '~/Library/Caches/hermit/pkg' || '~/.cache/hermit/pkg' }}
3942
key: ${{ steps.hermit-hash.outputs.key }}
40-
- name: Install Hermit Packages
41-
if: ${{ steps.hermit-hash.outputs.exists == 0 }}
42-
run: hermit install
43-
- name: Rebuild All
44-
run: just build-all
45-
- name: Download Go Dependencies
46-
run: go mod download -x
43+
44+
write-pnpm-cache:
45+
strategy:
46+
matrix:
47+
runner: [ubuntu-latest, ftl]
48+
name: Write PNPM Cache
49+
runs-on: ${{ matrix.runner }}
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
53+
- name: Init Hermit
54+
uses: cashapp/activate-hermit@12a728b03ad41eace0f9abaf98a035e7e8ea2318 # ratchet:cashapp/[email protected]
55+
- name: Hash PNPM
56+
id: pnpm-hash
57+
shell: bash
58+
env:
59+
GH_TOKEN: ${{ github.token }}
60+
run: |
61+
hash="${{ hashFiles('**/pnpm-lock.yaml') }}"
62+
echo "hash=$hash" >> "$GITHUB_OUTPUT"
63+
key="${{ runner.os }}-${{ runner.arch }}-pnpm-${hash}"
64+
echo "key=$key" >> "$GITHUB_OUTPUT"
65+
exists="$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/block/ftl/actions/caches?key=$key" | jq '.actions_caches | length')"
66+
echo "exists=$exists" >> "$GITHUB_OUTPUT"
4767
- name: Download pnpm dependencies
68+
if: ${{ steps.pnpm-hash.outputs.exists == 0 }}
4869
run: pnpm install
49-
- name: Download playwright browsers
50-
run: npx playwright install
51-
- id: find-go-build-cache
52-
shell: bash
53-
run: echo "cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
5470
- name: Save pnpm Modules Cache
55-
id: cache-pnpm
71+
if: ${{ steps.pnpm-hash.outputs.exists == 0 }}
5672
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # ratchet:actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
5773
with:
5874
path: |
5975
~/.pnpm-store
6076
node_modules
61-
key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
77+
key: ${{ steps.pnpm-hash.outputs.key }}
78+
79+
write-playright-cache:
80+
strategy:
81+
matrix:
82+
runner: [ubuntu-latest, ftl]
83+
name: Write Playwright Cache
84+
runs-on: ${{ matrix.runner }}
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
88+
- name: Init Hermit
89+
uses: cashapp/activate-hermit@12a728b03ad41eace0f9abaf98a035e7e8ea2318 # ratchet:cashapp/[email protected]
90+
- name: Hash Playwright
91+
id: playwright-hash
92+
shell: bash
93+
env:
94+
GH_TOKEN: ${{ github.token }}
95+
run: |
96+
hash="${{ hashFiles('**/pnpm-lock.yaml') }}"
97+
echo "hash=$hash" >> "$GITHUB_OUTPUT"
98+
key="${{ runner.os }}-${{ runner.arch }}-playwright-${hash}"
99+
echo "key=$key" >> "$GITHUB_OUTPUT"
100+
exists="$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/block/ftl/actions/caches?key=$key" | jq '.actions_caches | length')"
101+
echo "exists=$exists" >> "$GITHUB_OUTPUT"
102+
- name: Download playwright browsers
103+
if: ${{ steps.playwright-hash.outputs.exists == 0 }}
104+
run: npx playwright install
62105
- name: Save Playwright Browser Cache
63-
id: cache-playwright
106+
if: ${{ steps.playwright-hash.outputs.exists == 0 }}
64107
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # ratchet:actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
65108
with:
66109
path: ~/.cache/ms-playwright
67-
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
110+
key: ${{ steps.playwright-hash.outputs.key }}
68111

69-
write-cache:
70-
name: Write Cache
112+
write-go-maven-cache:
113+
name: Write Go+Maven Cache
71114
runs-on: ubuntu-latest
72115
steps:
73116
- name: Checkout code
@@ -83,11 +126,6 @@ jobs:
83126
- id: find-go-build-cache
84127
shell: bash
85128
run: echo "cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
86-
- id: hermit-hash
87-
shell: bash
88-
run: |
89-
hash="$(find ./bin ! -type d | sort | xargs openssl sha256 | openssl sha256 -r | cut -d' ' -f1)"
90-
echo "hash=$hash" >> "$GITHUB_OUTPUT"
91129
- name: Save Go Module Cache
92130
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # ratchet:actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4
93131
with:

0 commit comments

Comments
 (0)