Skip to content

Commit 8b5a96f

Browse files
authored
Test shim as a normal unit test (#4917)
This removes the `go_test_shim` job defined in `extraTests` by making it a normal provider unit test instead of something that needs to be run as part of upstream. We currently attempt to upload coverage as part of this test, but it [doesn't work](https://app.codecov.io/gh/pulumi/pulumi-aws). pulumi/ci-mgmt#1224 will start uploading unit test coverage by default.
1 parent 35d54ab commit 8b5a96f

File tree

7 files changed

+31
-209
lines changed

7 files changed

+31
-209
lines changed

.ci-mgmt.yaml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,6 @@ actions:
6565
run: make upstream
6666

6767
extraTests:
68-
go_test_shim:
69-
name: Run test of provider shim
70-
runs-on: ubuntu-latest
71-
timeout-minutes: 60
72-
steps:
73-
- name: Free Disk Space (Ubuntu)
74-
uses: jlumbroso/free-disk-space@main
75-
with:
76-
swap-storage: false
77-
tool-cache: false
78-
- name: Checkout Repo
79-
uses: actions/checkout@v4
80-
with:
81-
ref: ${{ env.PR_COMMIT_SHA }}
82-
submodules: true
83-
- uses: pulumi/provider-version-action@v1
84-
with:
85-
set-env: 'PROVIDER_VERSION'
86-
- name: Setup tools
87-
uses: ./.github/actions/setup-tools
88-
with:
89-
tools: pulumictl, pulumi, go
90-
- name: Prepare local workspace
91-
run: make prepare_local_workspace
92-
- name: go test
93-
run: |
94-
cd upstream
95-
go get github.com/hashicorp/[email protected]
96-
cd shim
97-
go test -v -coverprofile="coverage.txt" .
98-
- name: Upload coverage reports to Codecov
99-
uses: codecov/codecov-action@v4
100-
env:
101-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
10268

10369
upstream_lint:
10470
name: Run upstream provider-lint

.github/workflows/master.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ jobs:
9999
- build_provider
100100
- test
101101
- license_check
102-
- go_test_shim
103102
- upstream_lint
104103
uses: ./.github/workflows/publish.yml
105104
secrets: inherit
@@ -202,40 +201,6 @@ jobs:
202201
- dotnet
203202
- go
204203
- java
205-
go_test_shim:
206-
name: Run test of provider shim
207-
runs-on: ubuntu-latest
208-
steps:
209-
- name: Free Disk Space (Ubuntu)
210-
uses: jlumbroso/free-disk-space@main
211-
with:
212-
swap-storage: false
213-
tool-cache: false
214-
- name: Checkout Repo
215-
uses: actions/checkout@v4
216-
with:
217-
ref: ${{ env.PR_COMMIT_SHA }}
218-
submodules: true
219-
- uses: pulumi/provider-version-action@v1
220-
with:
221-
set-env: PROVIDER_VERSION
222-
- name: Setup tools
223-
uses: ./.github/actions/setup-tools
224-
with:
225-
tools: pulumictl, pulumi, go
226-
- name: Prepare local workspace
227-
run: make prepare_local_workspace
228-
- name: go test
229-
run: |
230-
cd upstream
231-
go get github.com/hashicorp/[email protected]
232-
cd shim
233-
go test -v -coverprofile="coverage.txt" .
234-
- env:
235-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
236-
name: Upload coverage reports to Codecov
237-
uses: codecov/codecov-action@v4
238-
timeout-minutes: 60
239204
upstream_lint:
240205
name: Run upstream provider-lint
241206
runs-on: ubuntu-latest

.github/workflows/prerelease.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ jobs:
5959
- build_provider
6060
- test
6161
- license_check
62-
- go_test_shim
6362
- upstream_lint
6463
uses: ./.github/workflows/publish.yml
6564
secrets: inherit
@@ -142,40 +141,6 @@ jobs:
142141
- dotnet
143142
- go
144143
- java
145-
go_test_shim:
146-
name: Run test of provider shim
147-
runs-on: ubuntu-latest
148-
steps:
149-
- name: Free Disk Space (Ubuntu)
150-
uses: jlumbroso/free-disk-space@main
151-
with:
152-
swap-storage: false
153-
tool-cache: false
154-
- name: Checkout Repo
155-
uses: actions/checkout@v4
156-
with:
157-
ref: ${{ env.PR_COMMIT_SHA }}
158-
submodules: true
159-
- uses: pulumi/provider-version-action@v1
160-
with:
161-
set-env: PROVIDER_VERSION
162-
- name: Setup tools
163-
uses: ./.github/actions/setup-tools
164-
with:
165-
tools: pulumictl, pulumi, go
166-
- name: Prepare local workspace
167-
run: make prepare_local_workspace
168-
- name: go test
169-
run: |
170-
cd upstream
171-
go get github.com/hashicorp/[email protected]
172-
cd shim
173-
go test -v -coverprofile="coverage.txt" .
174-
- env:
175-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
176-
name: Upload coverage reports to Codecov
177-
uses: codecov/codecov-action@v4
178-
timeout-minutes: 60
179144
upstream_lint:
180145
name: Run upstream provider-lint
181146
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ jobs:
6565
- build_provider
6666
- test
6767
- license_check
68-
- go_test_shim
6968
- upstream_lint
7069
uses: ./.github/workflows/publish.yml
7170
secrets: inherit
@@ -148,40 +147,6 @@ jobs:
148147
- dotnet
149148
- go
150149
- java
151-
go_test_shim:
152-
name: Run test of provider shim
153-
runs-on: ubuntu-latest
154-
steps:
155-
- name: Free Disk Space (Ubuntu)
156-
uses: jlumbroso/free-disk-space@main
157-
with:
158-
swap-storage: false
159-
tool-cache: false
160-
- name: Checkout Repo
161-
uses: actions/checkout@v4
162-
with:
163-
ref: ${{ env.PR_COMMIT_SHA }}
164-
submodules: true
165-
- uses: pulumi/provider-version-action@v1
166-
with:
167-
set-env: PROVIDER_VERSION
168-
- name: Setup tools
169-
uses: ./.github/actions/setup-tools
170-
with:
171-
tools: pulumictl, pulumi, go
172-
- name: Prepare local workspace
173-
run: make prepare_local_workspace
174-
- name: go test
175-
run: |
176-
cd upstream
177-
go get github.com/hashicorp/[email protected]
178-
cd shim
179-
go test -v -coverprofile="coverage.txt" .
180-
- env:
181-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
182-
name: Upload coverage reports to Codecov
183-
uses: codecov/codecov-action@v4
184-
timeout-minutes: 60
185150
upstream_lint:
186151
name: Run upstream provider-lint
187152
runs-on: ubuntu-latest

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

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ jobs:
9494
- test
9595
- build_provider
9696
- license_check
97-
- go_test_shim
9897
- upstream_lint
9998
runs-on: ubuntu-latest
10099
steps:
@@ -203,40 +202,6 @@ jobs:
203202
name: License Check
204203
uses: ./.github/workflows/license.yml
205204
secrets: inherit
206-
go_test_shim:
207-
name: Run test of provider shim
208-
runs-on: ubuntu-latest
209-
steps:
210-
- name: Free Disk Space (Ubuntu)
211-
uses: jlumbroso/free-disk-space@main
212-
with:
213-
swap-storage: false
214-
tool-cache: false
215-
- name: Checkout Repo
216-
uses: actions/checkout@v4
217-
with:
218-
ref: ${{ env.PR_COMMIT_SHA }}
219-
submodules: true
220-
- uses: pulumi/provider-version-action@v1
221-
with:
222-
set-env: PROVIDER_VERSION
223-
- name: Setup tools
224-
uses: ./.github/actions/setup-tools
225-
with:
226-
tools: pulumictl, pulumi, go
227-
- name: Prepare local workspace
228-
run: make prepare_local_workspace
229-
- name: go test
230-
run: |
231-
cd upstream
232-
go get github.com/hashicorp/[email protected]
233-
cd shim
234-
go test -v -coverprofile="coverage.txt" .
235-
- env:
236-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
237-
name: Upload coverage reports to Codecov
238-
uses: codecov/codecov-action@v4
239-
timeout-minutes: 60
240205
upstream_lint:
241206
name: Run upstream provider-lint
242207
runs-on: ubuntu-latest

patches/0025-move-shim-logic-to-upstream-as-a-patch.patch

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,3 @@ index 0000000000..2af7c06925
4646
+func NewTagConfig(ctx context.Context, i interface{}) TagConfig {
4747
+ return TagConfig{Tags: tags.New(ctx, i)}
4848
+}
49-
diff --git a/shim/shim_test.go b/shim/shim_test.go
50-
new file mode 100644
51-
index 0000000000..f8ee8a0c54
52-
--- /dev/null
53-
+++ b/shim/shim_test.go
54-
@@ -0,0 +1,29 @@
55-
+// Copyright 2023, Pulumi Corporation.
56-
+//
57-
+// Licensed under the Apache License, Version 2.0 (the "License");
58-
+// you may not use this file except in compliance with the License.
59-
+// You may obtain a copy of the License at
60-
+//
61-
+// http://www.apache.org/licenses/LICENSE-2.0
62-
+//
63-
+// Unless required by applicable law or agreed to in writing, software
64-
+// distributed under the License is distributed on an "AS IS" BASIS,
65-
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66-
+// See the License for the specific language governing permissions and
67-
+// limitations under the License.
68-
+
69-
+package shim
70-
+
71-
+import (
72-
+ "context"
73-
+ "testing"
74-
+)
75-
+
76-
+// This checks that any runtime checks in the underlying provider (with patches) are passed.
77-
+func TestProviderShim(t *testing.T) {
78-
+ ctx := context.Background()
79-
+ _, err := NewUpstreamProvider(ctx)
80-
+ if err != nil {
81-
+ t.Fatal(err)
82-
+ }
83-
+}

provider/shim_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2024, Pulumi Corporation.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package provider
16+
17+
import (
18+
"context"
19+
"testing"
20+
21+
shim "github.com/hashicorp/terraform-provider-aws/shim"
22+
)
23+
24+
// This checks that any runtime checks in the underlying provider (with patches) are passed.
25+
func TestProviderShim(t *testing.T) {
26+
ctx := context.Background()
27+
_, err := shim.NewUpstreamProvider(ctx)
28+
if err != nil {
29+
t.Fatal(err)
30+
}
31+
}

0 commit comments

Comments
 (0)