Skip to content

Commit

Permalink
Run live e2e tests on PRs (#2553)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortent committed Oct 21, 2021
1 parent ed12880 commit 6bccc37
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/live-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: "Kpt Live - e2e Tests"
on:
pull_request:
paths-ignore:
- "docs/**"
- "site/**"
push:
paths-ignore:
- "docs/**"
- "site/**"

jobs:
kind:
runs-on: ubuntu-latest
strategy:
matrix:
version: [1.20.7]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/checkout@master
# 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
# If you upgrade this version confirm the changes match your expectations
- name: Install KinD
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 # v0.5.0
with:
version: "v0.11.1"
skipClusterCreation: true
- name: Run Tests
env:
K8S_VERSION: ${{ matrix.version }}
run: |
K8S_VERSION=$K8S_VERSION make test-live-apply
8 changes: 7 additions & 1 deletion pkg/test/live/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

const (
KindClusterName = "live-e2e-test"
K8sVersionEnvName = "K8S_VERSION"
)

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

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

0 comments on commit 6bccc37

Please sign in to comment.