Skip to content

Commit 8862466

Browse files
committed
ci: verify full Go cache workflows
Summary: - opt pulumi-aws into the candidate full Go cache configuration - regenerate workflows with the ci-mgmt feature branch Rationale: - exercise the candidate cache strategy in a real provider CI run before the ci-mgmt change is merged Tests: - candidate provider-ci generation - actionlint on changed generated workflows
1 parent 90c2617 commit 8862466

9 files changed

Lines changed: 143 additions & 74 deletions

File tree

.ci-mgmt.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ XrunUpstreamTools: true
2626
pulumiConvert: 1
2727
allowMissingDocs: false
2828
goBuildParallelism: 2
29+
fullGoCache: true
2930
aws: true
3031
releaseVerification:
3132
nodejs: examples/release-verification
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Setup Go cache
2+
description: Restore Go module and build caches for generated provider workflows
3+
4+
inputs:
5+
cache-key:
6+
description: Identifies the workload that writes the build cache
7+
required: true
8+
target-os:
9+
description: GOOS compiled by this workload; defaults to the host GOOS
10+
required: false
11+
default: ""
12+
target-arch:
13+
description: GOARCH compiled by this workload; defaults to the host GOARCH
14+
required: false
15+
default: ""
16+
prime-modules:
17+
description: Download dependencies for the checked-out Go modules before saving the module cache
18+
required: false
19+
default: "false"
20+
save:
21+
description: Save caches when the job succeeds
22+
required: false
23+
default: "true"
24+
25+
runs:
26+
using: composite
27+
steps:
28+
- name: Get Go cache configuration
29+
id: cache-config
30+
shell: bash
31+
env:
32+
TARGET_OS: ${{ inputs.target-os }}
33+
TARGET_ARCH: ${{ inputs.target-arch }}
34+
run: |
35+
set -euo pipefail
36+
echo "build-cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
37+
echo "module-cache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
38+
echo "go-version=$(go env GOVERSION)" >> "$GITHUB_OUTPUT"
39+
echo "target-os=${TARGET_OS:-$(go env GOOS)}" >> "$GITHUB_OUTPUT"
40+
echo "target-arch=${TARGET_ARCH:-$(go env GOARCH)}" >> "$GITHUB_OUTPUT"
41+
42+
- name: Prepare Go module cache restore
43+
shell: bash
44+
env:
45+
MODULE_CACHE: ${{ steps.cache-config.outputs.module-cache }}
46+
run: |
47+
set -euo pipefail
48+
if [[ -z "$MODULE_CACHE" || "$MODULE_CACHE" == "/" ]]; then
49+
echo "Refusing to remove unsafe Go module cache path: '$MODULE_CACHE'" >&2
50+
exit 1
51+
fi
52+
rm -rf -- "$MODULE_CACHE"
53+
54+
- name: Restore and save Go module cache
55+
if: inputs.save == 'true'
56+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
57+
with:
58+
path: ${{ steps.cache-config.outputs.module-cache }}
59+
key: go-mod-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('provider/*.sum', 'upstream/*.sum', 'sdk/go/*.sum', 'sdk/*.sum', '*.sum') }}
60+
restore-keys: |
61+
go-mod-v2-${{ runner.os }}-${{ runner.arch }}-
62+
63+
- name: Restore Go module cache
64+
if: inputs.save != 'true'
65+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
66+
with:
67+
path: ${{ steps.cache-config.outputs.module-cache }}
68+
key: go-mod-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('provider/*.sum', 'upstream/*.sum', 'sdk/go/*.sum', 'sdk/*.sum', '*.sum') }}
69+
restore-keys: |
70+
go-mod-v2-${{ runner.os }}-${{ runner.arch }}-
71+
72+
- name: Prime Go module cache
73+
if: inputs.prime-modules == 'true'
74+
shell: bash
75+
run: |
76+
set -euo pipefail
77+
shopt -s nullglob
78+
declare -A modules=()
79+
for dependency_file in provider/*.sum upstream/*.sum sdk/go/*.sum sdk/*.sum *.sum; do
80+
module_dir=$(dirname "$dependency_file")
81+
if [[ -f "$module_dir/go.mod" ]]; then
82+
modules["$module_dir"]=1
83+
fi
84+
done
85+
for module_dir in "${!modules[@]}"; do
86+
(cd "$module_dir" && go mod download)
87+
done
88+
89+
- name: Restore and save Go build cache
90+
if: inputs.save == 'true'
91+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
92+
with:
93+
path: ${{ steps.cache-config.outputs.build-cache }}
94+
key: go-build-v2-${{ steps.cache-config.outputs.target-os }}-${{ steps.cache-config.outputs.target-arch }}-${{ steps.cache-config.outputs.go-version }}-${{ inputs.cache-key }}-${{ hashFiles('**/*.go', '**/go.sum') }}
95+
restore-keys: |
96+
go-build-v2-${{ steps.cache-config.outputs.target-os }}-${{ steps.cache-config.outputs.target-arch }}-${{ steps.cache-config.outputs.go-version }}-${{ inputs.cache-key }}-
97+
go-build-v2-${{ steps.cache-config.outputs.target-os }}-${{ steps.cache-config.outputs.target-arch }}-${{ steps.cache-config.outputs.go-version }}-
98+
99+
- name: Restore Go build cache
100+
if: inputs.save != 'true'
101+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
102+
with:
103+
path: ${{ steps.cache-config.outputs.build-cache }}
104+
key: go-build-v2-${{ steps.cache-config.outputs.target-os }}-${{ steps.cache-config.outputs.target-arch }}-${{ steps.cache-config.outputs.go-version }}-${{ inputs.cache-key }}-${{ hashFiles('**/*.go', '**/go.sum') }}
105+
restore-keys: |
106+
go-build-v2-${{ steps.cache-config.outputs.target-os }}-${{ steps.cache-config.outputs.target-arch }}-${{ steps.cache-config.outputs.go-version }}-${{ inputs.cache-key }}-
107+
go-build-v2-${{ steps.cache-config.outputs.target-os }}-${{ steps.cache-config.outputs.target-arch }}-${{ steps.cache-config.outputs.go-version }}-

.github/workflows/build_provider.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,12 @@ jobs:
8080
github_token: ${{ steps.app-auth.outputs.token }}
8181
# only saving the cache in the prerequisites job
8282
cache_save: false
83-
# Based on https://github.com/actions/cache/blob/main/examples.md#go---modules
84-
- name: Get GOCACHE
85-
id: gocache
86-
shell: bash
87-
run: |
88-
echo "path=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}"
89-
- name: Get GOMODCACHE
90-
id: gomodcache
91-
shell: bash
92-
run: |
93-
echo "path=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}"
94-
- name: Go Cache
95-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
83+
- name: Setup Go cache
84+
uses: ./.github/actions/setup-go-cache
9685
with:
97-
path: |
98-
${{ steps.gocache.outputs.path }}
99-
${{ steps.gomodcache.outputs.path }}
100-
key: go-provider-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ hashFiles('provider/go.sum') }}
101-
restore-keys: |
102-
go-provider-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-
86+
cache-key: provider
87+
target-os: ${{ matrix.platform.os }}
88+
target-arch: ${{ matrix.platform.arch }}
10389
- name: Prepare local workspace before restoring previously built
10490
run: make prepare_local_workspace
10591
env:

.github/workflows/build_sdk.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,11 @@ jobs:
8080
github_token: ${{ steps.app-auth.outputs.token }}
8181
# only saving the cache in the prerequisites job
8282
cache_save: false
83-
- name: Setup Go Cache
83+
- name: Setup Go cache
8484
if: matrix.language == 'go' || contains(matrix.language, 'go')
85-
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
85+
uses: ./.github/actions/setup-go-cache
8686
with:
87-
cache-dependency-path: |
88-
provider/*.sum
89-
upstream/*.sum
90-
sdk/go/*.sum
91-
sdk/*.sum
92-
*.sum
87+
cache-key: sdk-go
9388
- name: Prepare local workspace
9489
run: make prepare_local_workspace
9590
env:
@@ -129,9 +124,13 @@ jobs:
129124
git config --global user.email "bot@pulumi.com"
130125
git config --global user.name "pulumi-bot"
131126
132-
# Stash local changes and check out the PR's branch directly.
127+
# Stash local changes and check out the PR's branch directly. Fetch
128+
# only that ref: a bare fetch pulls every branch in the repo, and
129+
# on-demand submodule recursion then tries to resolve the submodule
130+
# gitlink of every commit it pulls, including long-dead branches
131+
# pointing at commits the submodule's remote no longer serves.
133132
git stash
134-
git fetch
133+
git fetch --no-recurse-submodules origin "+refs/heads/$HEAD_REF:refs/remotes/origin/$HEAD_REF"
135134
git checkout "origin/$HEAD_REF"
136135
137136
# Apply and add our changes, but don't commit any files we expect to

.github/workflows/main-post-build.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,10 @@ jobs:
6767
github_token: ${{ steps.app-auth.outputs.token }}
6868
# only saving the cache in the prerequisites job
6969
cache_save: false
70-
- name: Setup Go Cache
71-
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
70+
- name: Setup Go cache
71+
uses: ./.github/actions/setup-go-cache
7272
with:
73-
cache-dependency-path: |
74-
provider/*.sum
75-
upstream/*.sum
76-
sdk/go/*.sum
77-
sdk/*.sum
78-
*.sum
73+
cache-key: coverage
7974
- name: Echo Coverage Output Dir
8075
run: 'echo "Coverage output directory: ${{ env.COVERAGE_OUTPUT_DIR }}"'
8176
- name: Generate Coverage Data

.github/workflows/prerequisites.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,11 @@ jobs:
9090
github_token: ${{ steps.app-auth.outputs.token }}
9191
# only saving the cache in the prerequisites job
9292
cache_save: true
93-
- name: Setup Go Cache
94-
if: inputs.acceptance_fanout
95-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
96-
with:
97-
path: |
98-
~/go/pkg/mod
99-
~/.cache/go-build
100-
key: ${{ runner.os }}-go-prerequisites-${{ hashFiles('provider/*.sum', 'upstream/*.sum', 'sdk/go/*.sum', 'sdk/*.sum', '*.sum') }}
101-
- name: Setup Go Cache
102-
if: inputs.acceptance_fanout == false
103-
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
93+
- name: Setup Go cache
94+
uses: ./.github/actions/setup-go-cache
10495
with:
105-
cache-dependency-path: |
106-
provider/*.sum
107-
upstream/*.sum
108-
sdk/go/*.sum
109-
sdk/*.sum
110-
*.sum
96+
cache-key: prerequisites
97+
prime-modules: true
11198
- name: Prepare local workspace before restoring previously built files
11299
run: make prepare_local_workspace
113100
env:

.github/workflows/run-acceptance-tests.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,10 @@ jobs:
102102
version: 2026.3.7
103103
github_token: ${{ steps.app-auth.outputs.token }}
104104
cache_save: false
105-
- name: Restore Go Cache
106-
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
105+
- name: Setup Go cache
106+
uses: ./.github/actions/setup-go-cache
107107
with:
108-
path: |
109-
~/go/pkg/mod
110-
~/.cache/go-build
111-
key: ${{ runner.os }}-go-prerequisites-${{ hashFiles('provider/*.sum', 'upstream/*.sum', 'sdk/go/*.sum', 'sdk/*.sum', '*.sum') }}
108+
cache-key: test-provider
112109
- name: Prepare local workspace
113110
run: make prepare_local_workspace
114111
env:
@@ -176,13 +173,10 @@ jobs:
176173
version: 2026.3.7
177174
github_token: ${{ steps.app-auth.outputs.token }}
178175
cache_save: false
179-
- name: Restore Go Cache
180-
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
176+
- name: Setup Go cache
177+
uses: ./.github/actions/setup-go-cache
181178
with:
182-
path: |
183-
~/go/pkg/mod
184-
~/.cache/go-build
185-
key: ${{ runner.os }}-go-prerequisites-${{ hashFiles('provider/*.sum', 'upstream/*.sum', 'sdk/go/*.sum', 'sdk/*.sum', '*.sum') }}
179+
cache-key: schema
186180
- name: Prepare local workspace before restoring previously built files
187181
run: make prepare_local_workspace
188182
env:

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ jobs:
7575
github_token: ${{ steps.app-auth.outputs.token }}
7676
# also save this cache since we are using a different mise env.
7777
cache_save: true
78+
- name: Setup Go cache
79+
uses: ./.github/actions/setup-go-cache
80+
with:
81+
cache-key: integration-tests
82+
save: ${{ matrix.current-shard == 0 }}
7883
- name: Prepare local workspace
7984
run: make prepare_local_workspace
8085
env:

.github/workflows/verify-release.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,10 @@ jobs:
7676
version: 2026.3.7
7777
github_token: ${{ secrets.GITHUB_TOKEN }}
7878
cache_save: false
79-
- name: Setup Go Cache
80-
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
79+
- name: Setup Go cache
80+
uses: ./.github/actions/setup-go-cache
8181
with:
82-
cache-dependency-path: |
83-
provider/*.sum
84-
upstream/*.sum
85-
sdk/go/*.sum
86-
sdk/*.sum
87-
*.sum
82+
cache-key: verify-release
8883
- name: Generate Pulumi Access Token
8984
id: generate_pulumi_token
9085
uses: pulumi/auth-actions@141415910c3beb54e03b48e9057c204c97b956f2 # v2.1.0

0 commit comments

Comments
 (0)