added unit tests #10
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
name: E2E Test | |
on: | |
push: | |
branches: | |
- "master" | |
paths: | |
- '**.go' | |
- '**.yaml' | |
- '**.mod' | |
pull_request: | |
paths: | |
- '**.go' | |
- '**.yaml' | |
- '**.mod' | |
jobs: | |
kind: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Get dependencies | |
run: | | |
go get -v -t -d ./... | |
- name: Go build | |
run: | | |
go build -ldflags="-X github.com/sunny0826/kubecm/version.Version=${{ github.run_id }} \ | |
-X github.com/sunny0826/kubecm/version.GitRevision=${{ github.sha }} \ | |
-X 'github.com/sunny0826/kubecm/version.BuildDate=${{ steps.date.outputs.date }}'" \ | |
-o bin/kubecm . | |
- name: Setup Kind | |
uses: engineerd/setup-kind@v0.5.0 | |
with: | |
version: "v0.20.0" | |
- name: Setup 2nd Kind | |
run: | | |
kind create cluster --image kindest/node:v1.24.15 --name 2nd-kind --kubeconfig 2nd-kind | |
kind get clusters | |
- name: Setup 3rd Kind | |
run: | | |
kind create cluster --image kindest/node:v1.21.14 --name 3rd-kind --kubeconfig 3rd-kind | |
kind get clusters | |
- name: E2E Test | |
run: | | |
bin/kubecm version | |
echo "********************************************************************************" | |
echo "Running kubecm add..." | |
echo "********************************************************************************" | |
bin/kubecm add -cf 2nd-kind | |
bin/kubecm add -cf 3rd-kind --context-prefix 3rd | |
echo "********************************************************************************" | |
echo "Running kubecm merge multiple kubeconfig..." | |
echo "********************************************************************************" | |
bin/kubecm merge -y 2nd-kind 3rd-kind --config multi.config | |
cat multi.config | |
echo "********************************************************************************" | |
echo "Running kubecm merge in dir..." | |
echo "********************************************************************************" | |
mkdir -p tmp/kubecm-merge | |
cp -r 2nd-kind tmp/kubecm-merge/2nd-kind | |
cp -r 3rd-kind tmp/kubecm-merge/3rd-kind | |
bin/kubecm merge -f tmp/kubecm-merge -y --config merge.config | |
cat merge.config | |
echo "********************************************************************************" | |
echo "Running kubecm ls..." | |
echo "********************************************************************************" | |
bin/kubecm list | |
echo "********************************************************************************" | |
echo "Running kubecm switch..." | |
echo "********************************************************************************" | |
bin/kubecm s 3rd-kind-3rd-kind | |
echo "********************************************************************************" | |
echo "Running kubecm delete..." | |
echo "********************************************************************************" | |
bin/kubecm d kind-kind | |
echo "********************************************************************************" | |
echo "Running kubecm global flag --config..." | |
echo "********************************************************************************" | |
bin/kubecm s kind-2nd-kind --config merge.config | |
echo "********************************************************************************" | |
echo "Running kubecm namespace..." | |
echo "********************************************************************************" | |
bin/kubecm ns kube-system | |
echo "********************************************************************************" | |
echo "Running kubecm list from env KUBECONFIG..." | |
echo "********************************************************************************" | |
echo "default config" | |
bin/kubecm ls | |
echo "set env" | |
export KUBECONFIG="$PWD/multi.config" | |
bin/kubecm s kind-2nd-kind | |
echo "********************************************************************************" | |
echo "Running kubecm create..." | |
echo "********************************************************************************" | |
bin/kubecm create --user e2e --namespace default --cluster-role view --context-name kind-2nd-kind | |
kubectl get all --kubeconfig e2e-kubeconfig.yaml |