forked from ko-build/ko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the kind and integration tests to actions (ko-build#225)
- Loading branch information
Showing
5 changed files
with
228 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
name: KinD e2e tests | ||
|
||
on: | ||
pull_request: | ||
branches: [ 'master' ] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./src/github.com/google/ko | ||
|
||
jobs: | ||
|
||
e2e-tests: | ||
name: e2e tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false # Keep running if one leg fails. | ||
matrix: | ||
k8s-version: | ||
- v1.17.11 | ||
- v1.18.8 | ||
- v1.19.1 | ||
|
||
include: | ||
# Map between K8s and KinD versions. | ||
# This is attempting to make it a bit clearer what's being tested. | ||
# See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.9.0 | ||
- k8s-version: v1.17.11 | ||
kind-version: v0.9.0 | ||
kind-image-sha: sha256:5240a7a2c34bf241afb54ac05669f8a46661912eab05705d660971eeb12f6555 | ||
- k8s-version: v1.18.8 | ||
kind-version: v0.9.0 | ||
kind-image-sha: sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb | ||
- k8s-version: v1.19.1 | ||
kind-version: v0.9.0 | ||
kind-image-sha: sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600 | ||
|
||
env: | ||
GOPATH: ${{ github.workspace }} | ||
GO111MODULE: off | ||
# https://github.com/google/go-containerregistry/pull/125 allows insecure registry for | ||
# '*.local' hostnames. This works both for `ko` and our own tag-to-digest resolution logic, | ||
# thus allowing us to test without bypassing tag-to-digest resolution. | ||
REGISTRY_NAME: registry.local | ||
REGISTRY_PORT: 5000 | ||
KO_DOCKER_REPO: registry.local:5000/knative | ||
|
||
steps: | ||
- name: Set up Go 1.15.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15.x | ||
|
||
- name: Check out code onto GOPATH | ||
uses: actions/checkout@v2 | ||
with: | ||
path: ./src/github.com/google/ko | ||
|
||
- name: Install ko | ||
run: go install ./cmd/ko | ||
|
||
- name: Install KinD | ||
run: | | ||
set -x | ||
# Disable swap otherwise memory enforcement doesn't work | ||
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600009955324200 | ||
sudo swapoff -a | ||
sudo rm -f /swapfile | ||
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${{ matrix.kind-version }}/kind-$(uname)-amd64 | ||
chmod +x ./kind | ||
sudo mv kind /usr/local/bin | ||
- name: Configure KinD Cluster | ||
run: | | ||
set -x | ||
# KinD configuration. | ||
cat > kind.yaml <<EOF | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
kind: Cluster | ||
# Configure registry for KinD. | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."$REGISTRY_NAME:$REGISTRY_PORT"] | ||
endpoint = ["http://$REGISTRY_NAME:$REGISTRY_PORT"] | ||
# This is needed in order to support projected volumes with service account tokens. | ||
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600268272383600 | ||
kubeadmConfigPatches: | ||
- | | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: ClusterConfiguration | ||
metadata: | ||
name: config | ||
apiServer: | ||
extraArgs: | ||
"service-account-issuer": "kubernetes.default.svc" | ||
"service-account-signing-key-file": "/etc/kubernetes/pki/sa.key" | ||
nodes: | ||
- role: control-plane | ||
image: kindest/node:${{ matrix.k8s-version }}@${{ matrix.kind-image-sha }} | ||
- role: worker | ||
image: kindest/node:${{ matrix.k8s-version }}@${{ matrix.kind-image-sha }} | ||
EOF | ||
- name: Create KinD Cluster | ||
run: kind create cluster --config kind.yaml | ||
|
||
- name: Setup local registry | ||
run: | | ||
# Run a registry. | ||
docker run -d --restart=always \ | ||
-p $REGISTRY_PORT:$REGISTRY_PORT --name $REGISTRY_NAME registry:2 | ||
# Connect the registry to the KinD network. | ||
docker network connect "kind" $REGISTRY_NAME | ||
# Make the $REGISTRY_NAME -> 127.0.0.1, to tell `ko` to publish to | ||
# local reigstry, even when pushing $REGISTRY_NAME:$REGISTRY_PORT/some/image | ||
sudo echo "127.0.0.1 $REGISTRY_NAME" | sudo tee -a /etc/hosts | ||
- name: Wait for ready nodes | ||
run: | | ||
kubectl wait --for=condition=Ready nodes --all | ||
- name: Run Smoke Test | ||
run: | | ||
# Test with kind load | ||
KO_DOCKER_REPO=kind.local ko apply --platform=all -f ./cmd/ko/test | ||
kubectl wait --timeout=10s --for=condition=Ready pod/kodata | ||
kubectl delete pod kodata | ||
# Test with registry | ||
ko apply --platform=all -f ./cmd/ko/test | ||
kubectl wait --timeout=60s --for=condition=Ready pod/kodata | ||
kubectl delete pod kodata | ||
- name: Collect pod diagnostics | ||
if: ${{ failure() }} | ||
env: | ||
SYSTEM_NAMESPACE: default | ||
run: | | ||
kubectl -n${SYSTEM_NAMESPACE} get pods | ||
echo '::group:: describe' | ||
kubectl -n${SYSTEM_NAMESPACE} describe pods | ||
echo '::endgroup::' | ||
for x in $(kubectl get pods -n${SYSTEM_NAMESPACE} -oname); do | ||
echo "::group:: describe $x" | ||
kubectl -n${SYSTEM_NAMESPACE} describe $x | ||
echo '::endgroup::' | ||
echo "::group:: $x logs" | ||
kubectl -n${SYSTEM_NAMESPACE} logs $x --all-containers | ||
echo '::endgroup::' | ||
done | ||
- name: Collect node diagnostics | ||
if: ${{ failure() }} | ||
run: | | ||
kubectl get nodes | ||
echo '::group:: describe' | ||
kubectl describe nodes | ||
echo '::endgroup::' | ||
for x in $(kubectl get nodes -oname); do | ||
echo "::group:: describe $x" | ||
kubectl describe $x | ||
echo '::endgroup::' | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2020 The Knative Authors. | ||
# | ||
# 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. | ||
|
||
# This file is automagically synced here from github.com/knative-sandbox/.github | ||
# repo by knobots: https://github.com/mattmoor/knobots and will be overwritten. | ||
|
||
name: Integration Test | ||
|
||
on: | ||
|
||
pull_request: | ||
branches: [ 'master' ] | ||
|
||
jobs: | ||
|
||
test: | ||
name: Module Tests | ||
strategy: | ||
matrix: | ||
go-version: [1.14.x, 1.15.x] | ||
platform: [ubuntu-latest] | ||
|
||
runs-on: ${{ matrix.platform }} | ||
|
||
steps: | ||
|
||
- name: Set up Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
id: go | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Test | ||
env: | ||
GOPATH: does not matter | ||
run: ./integration_test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters