Skip to content

Commit

Permalink
switch from k3d to kind for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mruoss committed Feb 13, 2023
1 parent d32e991 commit 3422466
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ on:

env:
MIX_ENV: test
KUBECONFIG: /home/runner/.kube/config

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
k8s_version: [latest]
k8s_version: [v1.26.0]
elixir: [1.14.x]
otp: [25.x]
steps:
- uses: actions/checkout@v2

- uses: debianmaster/actions-k3s@v1.0.5
id: k3s
- uses: engineerd/setup-kind@v0.5.0
id: kind
with:
version: ${{ matrix.k8s_version }}
version: v0.17.0
image: kindest/node:${{ matrix.k8s_version }}

- name: Setup elixir
id: beam
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/k8s_matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ on:
branches: [master]
pull_request:
branches: [master]

env:
KUBECONFIG: /home/runner/.kube/config

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
k8s_version: [v1.23.10-k3s1, v1.24.4-k3s1, latest] # tags according to https://hub.docker.com/r/rancher/k3s/tags
otp: [25.x] # with 24.3.0 hackney returns :checkout_failure
k8s_version: [v1.22.15, v1.23.13, v1.24.7, v1.25.3, v1.26.0]
otp: [25.x]
elixir: [1.14.x]
steps:
- uses: debianmaster/actions-k3s@v1.0.5
id: k3s
- uses: engineerd/setup-kind@v0.5.0
id: kind
with:
version: ${{ matrix.k8s_version }}
version: v0.17.0
image: kindest/node:${{ matrix.k8s_version }}
- uses: actions/checkout@v1.0.0
- uses: erlef/setup-beam@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
erlang 25.2
elixir 1.14.2
elixir 1.14.2
kind 0.17.0
30 changes: 14 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
K3D_KUBECONFIG_PATH?=./integration.yaml
KUBECONFIG_PATH?=./integration.yaml
CLUSTER_NAME=bonny-ex

.PHONY: help
Expand All @@ -9,27 +9,25 @@ help:
all: test lint docs analyze

integration.yaml: ## Create a k3d cluster
- k3d cluster delete ${CLUSTER_NAME}
k3d cluster create ${CLUSTER_NAME} --servers 1 --wait
k3d kubeconfig get ${CLUSTER_NAME} > ${K3D_KUBECONFIG_PATH}
sleep 5
$(MAKE) cluster.delete cluster.create
kind export kubeconfig --kubeconfig ${KUBECONFIG_PATH} --name "${CLUSTER_NAME}"

.PHONY: test.integration
test.integration: integration.yaml
test.integration: ## Run integration tests using k3d `make cluster`
MIX_ENV=test mix compile
MIX_ENV=test mix bonny.gen.manifest -o - | kubectl apply -f -
kubectl config use-context k3d-${CLUSTER_NAME}
TEST_KUBECONFIG=${K3D_KUBECONFIG_PATH} mix test --only integration
kubectl config use-context kind-${CLUSTER_NAME}
TEST_KUBECONFIG=${KUBECONFIG_PATH} mix test --only integration

.PHONY: k3d.delete
k3d.delete: ## Delete k3d cluster
- k3d cluster delete ${CLUSTER_NAME}
rm ${K3D_KUBECONFIG_PATH}
.PHONY: cluster.delete
cluster.delete: ## Delete k3d cluster
- kind delete cluster --kubeconfig ${KUBECONFIG_PATH} --name "${CLUSTER_NAME}"
rm -f ${KUBECONFIG_PATH}

.PHONY: k3d.create
k3d.create: ## Created k3d cluster
k3d cluster create ${CLUSTER_NAME} --servers 1 --wait
.PHONY: cluster.create
cluster.create: ## Created kind cluster
kind create cluster --wait 600s --name "${CLUSTER_NAME}"

.PHONY: lint
lint:
Expand All @@ -38,12 +36,12 @@ lint:

.PHONY: test
test:
TEST_KUBECONFIG=${K3D_KUBECONFIG_PATH} mix test --include integration --cover
TEST_KUBECONFIG=${KUBECONFIG_PATH} mix test --include integration --cover

.PHONY: test.watch
test.watch: integration.yaml
test.watch: ## Run all tests with mix.watch
TEST_KUBECONFIG=${K3D_KUBECONFIG_PATH} mix test.watch --include integration
TEST_KUBECONFIG=${KUBECONFIG_PATH} mix test.watch --include integration

.PHONY: analyze
analyze:
Expand Down

0 comments on commit 3422466

Please sign in to comment.