Skip to content

Commit 381c6c5

Browse files
Cache plugin installation in CI (#3113)
This prevents GH rate limits due to plugin installations in CI. fixes #3114
1 parent 92748b5 commit 381c6c5

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

.github/workflows/build-and-test.yml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,42 @@ env:
2020
PULUMI_SKIP_UPDATE_CHECK: true
2121

2222
jobs:
23+
install-plugins:
24+
strategy:
25+
matrix:
26+
platform: [ubuntu-latest, macos-latest, windows-latest]
27+
runs-on: ${{ matrix.platform }}
28+
steps:
29+
- name: Check out source code
30+
uses: actions/checkout@master
31+
- name: Install Go
32+
uses: actions/setup-go@v5
33+
with:
34+
# Use latest - we only need this for the toolchain
35+
go-version: 1.24.x
36+
- name: Find pulumi version
37+
id: pulumi_version
38+
shell: bash
39+
run: |
40+
GO_MODULE_VERSION=$(go list -m -f '{{.Version}}' github.com/pulumi/pulumi/pkg/v3)
41+
GO_VERSION=$(echo "$GO_MODULE_VERSION" | sed 's/^v//')
42+
echo "pulumi_version=$GO_VERSION"
43+
echo "pulumi_version=$GO_VERSION" >> $GITHUB_OUTPUT
44+
- name: Install pulumi
45+
uses: pulumi/actions@v5
46+
with:
47+
pulumi-version: ${{ steps.pulumi_version.outputs.pulumi_version }}
48+
- name: Cache plugins
49+
uses: actions/cache@v4
50+
with:
51+
path: ~/.pulumi/plugins
52+
key: ${{ matrix.platform }}-plugins
53+
restore-keys: |
54+
${{ matrix.platform }}-plugins
55+
- name: Install plugins
56+
run: make install_plugins
2357
test:
58+
needs: install-plugins
2459
strategy:
2560
# Collect all test failures instead of stopping when only one test is failing.
2661
fail-fast: false
@@ -197,6 +232,13 @@ jobs:
197232
- name: Shard tests
198233
run: echo "RUN_TEST_CMD=$(go run github.com/pulumi/shard@0c8eaa6 --total ${{ env.TOTAL_SHARDS }} --index ${{ matrix.shard }} --seed 314 --error-on-name-clash)" >> $GITHUB_ENV
199234
if: ${{ matrix.platform == 'ubuntu-latest' }}
235+
- name: Restore plugins
236+
uses: actions/cache/restore@v4
237+
with:
238+
path: ~/.pulumi/plugins
239+
key: ${{ matrix.platform }}-plugins
240+
restore-keys: |
241+
${{ matrix.platform }}-plugins
200242
- name: Test
201243
run: make test
202244
- name: Upload coverage reports to Codecov
@@ -226,18 +268,6 @@ jobs:
226268
version: v2.1
227269
- name: Lint
228270
run: make lint
229-
version-check:
230-
name: Verify Pulumi Version Consistency
231-
runs-on: ubuntu-latest
232-
233-
steps:
234-
- name: Checkout code
235-
uses: actions/checkout@v3
236-
237-
- name: Set up Go
238-
uses: actions/setup-go@v4
239-
with:
240-
check-latest: true
241271
sentinel:
242272
name: sentinel
243273
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository

0 commit comments

Comments
 (0)