Skip to content

Commit 238e12e

Browse files
authored
ci: allow making tests workflow green for external contributors (#597)
1 parent ba1dcf6 commit 238e12e

File tree

14 files changed

+35
-19
lines changed

14 files changed

+35
-19
lines changed

.github/workflows/lint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ jobs:
2727

2828
- name: Run golangci-lint
2929
uses: golangci/[email protected]
30+
with:
31+
skip-cache: true # actions/setup-go from v4 handles caching for us

.github/workflows/tests.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,32 @@ jobs:
8585
test: ${{ fromJSON(needs.setup-integration-tests.outputs.test_names) }}
8686
runs-on: ubuntu-latest
8787
steps:
88+
# This step is needed to avoid running the integration tests if the secrets are not available.
89+
# TODO: remove this step once we have a way to run integration tests on forks.
90+
# https://github.com/Kong/kubernetes-testing-framework/issues/596
91+
- name: Detect if we should run (have required secrets)
92+
id: detect_if_should_run
93+
run: echo "result=${{ secrets.PULP_PASSWORD != '' }}" >> $GITHUB_OUTPUT
8894

8995
- name: checkout repository
9096
uses: actions/checkout@v3
9197
with:
9298
fetch-depth: 0
9399

94100
- uses: Kong/kong-license@master
101+
if: steps.detect_if_should_run.outputs.result == 'true'
95102
id: license
96103
with:
97104
password: ${{ secrets.PULP_PASSWORD }}
98105

99106
- name: setup golang
107+
if: steps.detect_if_should_run.outputs.result == 'true'
100108
uses: actions/setup-go@v4
101109
with:
102110
go-version: '^1.19'
103111

104112
- name: run integration test ${{ matrix.test }}
113+
if: steps.detect_if_should_run.outputs.result == 'true'
105114
run: make test.integration
106115
env:
107116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -112,6 +121,7 @@ jobs:
112121
NCPU: 1
113122

114123
- name: Upload coverage to Codecov
124+
if: steps.detect_if_should_run.outputs.result == 'true'
115125
uses: codecov/codecov-action@v3
116126
with:
117127
token: ${{ secrets.CODECOV_TOKEN }}
@@ -132,6 +142,9 @@ jobs:
132142
environment: gcloud
133143
runs-on: ubuntu-latest
134144
steps:
145+
# This step is needed to avoid running the e2e tests if the secrets are not available.
146+
# TODO: remove this step once we have a way to run integration tests on forks.
147+
# https://github.com/Kong/kubernetes-testing-framework/issues/596
135148
- name: Detect if we should run (have required secrets)
136149
id: detect_if_should_run
137150
run: echo "result=${{ secrets.PULP_PASSWORD != '' && secrets.GOOGLE_APPLICATION_CREDENTIALS != '' }}" >> $GITHUB_OUTPUT

pkg/clusters/addons/certmanager/addon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) ([]runtime.
185185
return nil, true, nil
186186
}
187187

188-
func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error) {
188+
func (a *Addon) DumpDiagnostics(context.Context, clusters.Cluster) (map[string][]byte, error) {
189189
diagnostics := make(map[string][]byte)
190190
return diagnostics, nil
191191
}

pkg/clusters/addons/httpbin/addon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) (waitForObj
155155
return utils.IsNamespaceAvailable(ctx, cluster, a.namespace)
156156
}
157157

158-
func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error) {
158+
func (a *Addon) DumpDiagnostics(context.Context, clusters.Cluster) (map[string][]byte, error) {
159159
diagnostics := make(map[string][]byte)
160160
return diagnostics, nil
161161
}

pkg/clusters/addons/istio/addon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) (waitForObj
207207
return utils.IsNamespaceAvailable(ctx, cluster, Namespace)
208208
}
209209

210-
func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error) {
210+
func (a *Addon) DumpDiagnostics(context.Context, clusters.Cluster) (map[string][]byte, error) {
211211
diagnostics := make(map[string][]byte)
212212
return diagnostics, nil
213213
}

pkg/clusters/addons/knative/knative.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) ([]runtime.
8888
return nil, true, nil
8989
}
9090

91-
func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error) {
91+
func (a *Addon) DumpDiagnostics(context.Context, clusters.Cluster) (map[string][]byte, error) {
9292
diagnostics := make(map[string][]byte)
9393
return diagnostics, nil
9494
}

pkg/clusters/addons/kong/addon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (a *Addon) Name() clusters.AddonName {
173173
return AddonName
174174
}
175175

176-
func (a *Addon) Dependencies(ctx context.Context, cluster clusters.Cluster) []clusters.AddonName {
176+
func (a *Addon) Dependencies(_ context.Context, cluster clusters.Cluster) []clusters.AddonName {
177177
if _, ok := cluster.(*kind.Cluster); ok {
178178
if a.proxyAdminServiceTypeLoadBalancer {
179179
return []clusters.AddonName{
@@ -361,7 +361,7 @@ func (a *Addon) Delete(ctx context.Context, cluster clusters.Cluster) error {
361361

362362
// delete the chart release from the cluster
363363
stderr := new(bytes.Buffer)
364-
cmd := exec.Command("helm", "--kubeconfig", kubeconfig.Name(), "uninstall", DefaultDeploymentName, "--namespace", a.namespace) //nolint:gosec
364+
cmd := exec.CommandContext(ctx, "helm", "--kubeconfig", kubeconfig.Name(), "uninstall", DefaultDeploymentName, "--namespace", a.namespace) //nolint:gosec
365365
cmd.Stdout = io.Discard
366366
cmd.Stderr = stderr
367367
if err := cmd.Run(); err != nil {

pkg/clusters/addons/kuma/addon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (a *Addon) Delete(ctx context.Context, cluster clusters.Cluster) error {
181181

182182
// delete the chart release from the cluster
183183
stderr := new(bytes.Buffer)
184-
cmd := exec.Command("helm", "--kubeconfig", kubeconfig.Name(), "uninstall", DefaultReleaseName, "--namespace", Namespace) //nolint:gosec
184+
cmd := exec.CommandContext(ctx, "helm", "--kubeconfig", kubeconfig.Name(), "uninstall", DefaultReleaseName, "--namespace", Namespace) //nolint:gosec
185185
cmd.Stdout = io.Discard
186186
cmd.Stderr = stderr
187187
if err := cmd.Run(); err != nil {
@@ -195,7 +195,7 @@ func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) (waitForObj
195195
return utils.IsNamespaceAvailable(ctx, cluster, Namespace)
196196
}
197197

198-
func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error) {
198+
func (a *Addon) DumpDiagnostics(context.Context, clusters.Cluster) (map[string][]byte, error) {
199199
diagnostics := make(map[string][]byte)
200200
return diagnostics, nil
201201
}

pkg/clusters/addons/loadimage/addon.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (a *Addon) Dependencies(_ context.Context, _ clusters.Cluster) []clusters.A
4343
func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
4444
switch ctype := cluster.Type(); ctype {
4545
case kind.KindClusterType:
46-
if err := a.loadIntoKind(cluster); err != nil {
46+
if err := a.loadIntoKind(ctx, cluster); err != nil {
4747
return err
4848
}
4949
default:
@@ -53,7 +53,7 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
5353
return nil
5454
}
5555

56-
func (a *Addon) Delete(ctx context.Context, cluster clusters.Cluster) error {
56+
func (a *Addon) Delete(_ context.Context, cluster clusters.Cluster) error {
5757
switch ctype := cluster.Type(); ctype {
5858
case kind.KindClusterType:
5959
// per https://github.com/kubernetes-sigs/kind/issues/658 this is basically impossible
@@ -66,12 +66,12 @@ func (a *Addon) Delete(ctx context.Context, cluster clusters.Cluster) error {
6666
}
6767
}
6868

69-
func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) ([]runtime.Object, bool, error) {
69+
func (a *Addon) Ready(context.Context, clusters.Cluster) ([]runtime.Object, bool, error) {
7070
// no way to verify this, we rely on Deploy's cmd.Run() not failing
7171
return nil, a.loaded, nil
7272
}
7373

74-
func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error) {
74+
func (a *Addon) DumpDiagnostics(context.Context, clusters.Cluster) (map[string][]byte, error) {
7575
diagnostics := make(map[string][]byte)
7676
return diagnostics, nil
7777
}

pkg/clusters/addons/loadimage/cluster_implementations.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package loadimage
22

33
import (
44
"bytes"
5+
"context"
56
"fmt"
67
"io"
78
"os/exec"
89

910
"github.com/kong/kubernetes-testing-framework/pkg/clusters"
1011
)
1112

12-
func (a *Addon) loadIntoKind(cluster clusters.Cluster) error {
13+
func (a *Addon) loadIntoKind(ctx context.Context, cluster clusters.Cluster) error {
1314
if len(a.images) == 0 {
1415
return fmt.Errorf("no images provided")
1516
}
@@ -22,7 +23,7 @@ func (a *Addon) loadIntoKind(cluster clusters.Cluster) error {
2223
deployArgs = append(deployArgs, a.images...)
2324

2425
stderr := new(bytes.Buffer)
25-
cmd := exec.Command("kind", deployArgs...)
26+
cmd := exec.CommandContext(ctx, "kind", deployArgs...)
2627
cmd.Stdout = io.Discard
2728
cmd.Stderr = stderr
2829

0 commit comments

Comments
 (0)