Skip to content

Commit 6bccc37

Browse files
authored
Run live e2e tests on PRs (#2553)
1 parent ed12880 commit 6bccc37

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

.github/workflows/live-e2e.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2021 Google LLC
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+
name: "Kpt Live - e2e Tests"
16+
on:
17+
pull_request:
18+
paths-ignore:
19+
- "docs/**"
20+
- "site/**"
21+
push:
22+
paths-ignore:
23+
- "docs/**"
24+
- "site/**"
25+
26+
jobs:
27+
kind:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
version: [1.20.7]
32+
steps:
33+
- name: Set up Go
34+
uses: actions/setup-go@v2
35+
with:
36+
go-version: 1.16
37+
- uses: actions/checkout@master
38+
# Pinned to Commit to ensure action is consistent: https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
39+
# If you upgrade this version confirm the changes match your expectations
40+
- name: Install KinD
41+
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 # v0.5.0
42+
with:
43+
version: "v0.11.1"
44+
skipClusterCreation: true
45+
- name: Run Tests
46+
env:
47+
K8S_VERSION: ${{ matrix.version }}
48+
run: |
49+
K8S_VERSION=$K8S_VERSION make test-live-apply

pkg/test/live/runner.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
const (
3434
KindClusterName = "live-e2e-test"
35+
K8sVersionEnvName = "K8S_VERSION"
3536
)
3637

3738
// Runner uses the provided Config to run a test.
@@ -154,7 +155,12 @@ func (r *Runner) CheckKindClusterAvailable(t *testing.T) bool {
154155
}
155156

156157
func (r *Runner) CreateKindCluster(t *testing.T) {
157-
cmd := exec.Command("kind", "create", "cluster", fmt.Sprintf("--name=%s", KindClusterName))
158+
args := []string{"create", "cluster", fmt.Sprintf("--name=%s", KindClusterName)}
159+
if k8sVersion := os.Getenv(K8sVersionEnvName); k8sVersion != "" {
160+
t.Logf("Using version %s", k8sVersion)
161+
args = append(args, fmt.Sprintf("--image=kindest/node:v%s", k8sVersion))
162+
}
163+
cmd := exec.Command("kind", args...)
158164
if err := cmd.Run(); err != nil {
159165
t.Fatalf("failed to create new kind cluster: %v", err)
160166
}

0 commit comments

Comments
 (0)