Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github actions-based e2e workflow #32

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"on":
workflow_dispatch:
inputs:
kne_ref:
description: "openconfig/kne reference (tag, commit, branch)"
type: string
default: v0.24.4
kind_version:
description: "KinD version"
type: string
required: true
default: v0.17.0

jobs:
e2e:
name: End-to-end test
runs-on: ubuntu-latest

steps:
- name: Set env vars
run: |
echo "KNE_REF=${{ inputs.kne_ref }}" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVER }}

- name: set up kind cluster
uses: engineerd/setup-kind@v0.5.0
with:
version: ${{ inputs.kind_version }}

- uses: actions/checkout@v3
# - uses: fregante/setup-git-user@v1

- name: Publish structs
run: make install-srl-controller
36 changes: 36 additions & 0 deletions .mk/e2e.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# KNE_REF is a git reference to use for KNE. It can be a branch, tag, or commit hash.
KNE_REF ?= dee1995a7ec0f446b159a35fad201df9185ee75d
KNE_REPO := https://github.com/openconfig/kne.git
KNE_TEMP_DIR := /tmp/.srlcontroller-tests/kne
KNE_TEST_DEPLOYMENT_FILE := ${KNE_TEMP_DIR}/deploy/kne/kind-bridge-no-controllers.yaml
KIND_CLUSTER_NAME ?= srl-test

.PHONY: install-kne
install-kne: ## Install KNE
rm -rf ${KNE_TEMP_DIR} && \
mkdir -p ${KNE_TEMP_DIR} && \
git clone ${KNE_REPO} ${KNE_TEMP_DIR} && \
cd ${KNE_TEMP_DIR} && git checkout ${KNE_REF} && \
make install

.PHONY: kne-test-deployment-cfg-file
kne-test-deployment-cfg-file: ## Create a KNE test deployment config file without controllers section
sed -n '/controllers:/q;p' < ${KNE_TEMP_DIR}/deploy/kne/kind-bridge.yaml > ${KNE_TEST_DEPLOYMENT_FILE}
sed -i 's/name: kne/name: ${KIND_CLUSTER_NAME}/g' ${KNE_TEST_DEPLOYMENT_FILE}

.PHONY: deploy-kne
deploy-kne: ## Deploy KNE kind cluster
kind delete cluster --name=${KIND_CLUSTER_NAME} && \
cd ${KNE_TEMP_DIR} && kne deploy ${KNE_TEST_DEPLOYMENT_FILE}

.PHONY: temp-docker-build
temp-docker-build: ## Built controller container using the image and tag specified in the manager's manifest
image="$(shell docker run -i --rm mikefarah/yq '.images[0].newName' < config/manager/kustomization.yaml)" tag="$(shell docker run -i --rm mikefarah/yq '.images[0].newTag' < config/manager/kustomization.yaml)" && \
docker build -t $$image:$$tag . && \
kind load docker-image $$image:$$tag --name ${KIND_CLUSTER_NAME}

.PHONY: install-srl-controller
install-srl-controller: install-kne kne-test-deployment-cfg-file deploy-kne temp-docker-build ## Install srl-controller from current working dir
kubectl apply -k config/default
@echo "wait for controller manager to be ready"
kubectl -n srlinux-controller wait --for=condition=Available deployment.apps/srlinux-controller-controller-manager
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include .mk/lint.mk
include .mk/e2e.mk

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To install the latest version of this controller on a cluster referenced in `~/.
# latest version
kubectl apply -k https://github.com/srl-labs/srl-controller/config/default

# specific version
# specific version (using git reference, e.g. tag or commit)
kubectl apply -k https://github.com/srl-labs/srl-controller/config/default?ref=v0.3.1
```

Expand Down