Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: separate go cache per job #4551

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading