Skip to content

Commit

Permalink
fix: CI caching wasn't working (#913)
Browse files Browse the repository at this point in the history
This splits cache saving and restoration into two steps. Restoring
occurs in every step, while saving only occurs in a single action on
main.
  • Loading branch information
alecthomas authored Feb 9, 2024
1 parent e02ead5 commit 3628357
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
12 changes: 5 additions & 7 deletions .github/actions/build-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ name: Build Cache
description: Cache builds
runs:
using: "composite"
# Make sure to keep these cache entries in sync with those in writecache.yml
steps:
- name: Cache Go Modules
- name: Restore Go Modules Cache
id: cache-go-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-{{ hashFiles('**/go.sum') }}-go
- name: Cache Maven Modules
- name: Restore Maven Modules Cache
id: cache-maven
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-{{ hashFiles('**/pom.xml') }}-maven
- name: Populate Cache
id: populate-cache
uses: ./.github/actions/populate-cache

6 changes: 0 additions & 6 deletions .github/actions/populate-cache/action.yml

This file was deleted.

Empty file.
12 changes: 0 additions & 12 deletions .github/actions/populate-cache/post.js

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ jobs:
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Test
run: |
find ~/.m2 -ls
mvn test --batch-mode
run: mvn test --batch-mode
test:
name: Test Go
runs-on: ubuntu-latest
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/writecache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches:
- main
name: Write Cache
jobs:
write-cache:
name: Write Cache
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Download Maven Dependencies
run: mvn dependency:resolve --batch-mode
- name: Download Go Dependencies
run: go mod download -x
- name: Save Go Modules Cache
id: cache-go-modules
uses: actions/cache/save@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-{{ hashFiles('**/go.sum') }}-go
- name: Save Maven Modules Cache
id: cache-maven
uses: actions/cache/save@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-{{ hashFiles('**/pom.xml') }}-maven

0 comments on commit 3628357

Please sign in to comment.