Skip to content

Commit

Permalink
chore: separate go cache per job (#4551)
Browse files Browse the repository at this point in the history
  • Loading branch information
techfg authored Feb 3, 2025
1 parent 7b921c6 commit 145c1ab
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
GO_CACHE_INFO_FILE: wf-go-cache-info.txt

jobs:
build:
name: Build and test
Expand Down Expand Up @@ -44,13 +47,21 @@ jobs:
node-version-file: ".nvmrc"
cache: "npm"

# https://github.com/actions/setup-go/issues/358 - cache is shared across jobs by default since the dependency
# graph is the same, however each job results in different dependencies being downloaded and the first one
# to finish wins with regards to saving the cache. To workaround, we create a file to include in the graph
# that contains information specified to the workflow & job so that each job gets a separate go cache.
- name: Create go cache info file
run: echo "go-cache-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}" > ${GO_CACHE_INFO_FILE}

- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: |
apps/*/go.sum
go.work.sum
${{ env.GO_CACHE_INFO_FILE }}
- name: Install NPM dependencies
run: npm ci
Expand Down Expand Up @@ -159,13 +170,21 @@ jobs:
node-version-file: ".nvmrc"
cache: "npm"

# https://github.com/actions/setup-go/issues/358 - cache is shared across jobs by default since the dependency
# graph is the same, however each job results in different dependencies being downloaded and the first one
# to finish wins with regards to saving the cache. To workaround, we create a file to include in the graph
# that contains information specified to the workflow & job so that each job gets a separate go cache.
- name: Create go cache info file
run: echo "go-cache-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}" > ${GO_CACHE_INFO_FILE}

- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: |
apps/*/go.sum
go.work.sum
${{ env.GO_CACHE_INFO_FILE }}
- name: Install NPM dependencies
run: npm ci
Expand Down

0 comments on commit 145c1ab

Please sign in to comment.