diff --git a/.github/scripts/kind.sh b/.github/scripts/kind.sh new file mode 100755 index 000000000..1694b7b52 --- /dev/null +++ b/.github/scripts/kind.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + + +wget -q https://github.com/kubernetes-sigs/kind/releases/download/v0.20.0/kind-linux-amd64 +chmod +x kind-linux-amd64 && mv kind-linux-amd64 /usr/local/bin/kind + +K8SVERSION=${K8SVERSION:-"v1.25.3"} +WORKSPACE=$PWD + +sed -i 's/K8SVERSION/'$K8SVERSION'/g' $WORKSPACE/.github/scripts/kind.yaml +sed -i 's#WORKSPACE#'$WORKSPACE'#g' $WORKSPACE/.github/scripts/kind.yaml +kind create cluster --config $WORKSPACE/.github/scripts/kind.yaml +kubectl wait node --all --for condition=ready \ No newline at end of file diff --git a/.github/scripts/kind.yaml b/.github/scripts/kind.yaml new file mode 100644 index 000000000..2765847dd --- /dev/null +++ b/.github/scripts/kind.yaml @@ -0,0 +1,17 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + image: kindest/node:K8SVERSION + extraMounts: + - hostPath: /tmp/kind + containerPath: /var/log + - hostPath: WORKSPACE/.github/scripts/xline.yaml + containerPath: /etc/kubernetes/manifests/xline.yaml + kubeadmConfigPatches: + - | + kind: ClusterConfiguration + etcd: + external: + endpoints: + - http://xline:2379 \ No newline at end of file diff --git a/.github/scripts/xline.yaml b/.github/scripts/xline.yaml new file mode 100644 index 000000000..9a1a54cd6 --- /dev/null +++ b/.github/scripts/xline.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Pod +metadata: + creationTimestamp: null + name: xline + namespace: kube-system +spec: + containers: + - name: xline + image: datenlord/xline:latest + imagePullPolicy: IfNotPresent + env: + - name: RUST_LOG + value: debug + command: + - /bin/sh + - -c + - xline --name node1 --members node1=172.18.0.2:12379 --data-dir /tmp/xline --storage-engine rocksdb + hostNetwork: true +status: {} \ No newline at end of file diff --git a/.github/workflows/kube.yml b/.github/workflows/kube.yml new file mode 100644 index 000000000..f7e6ad703 --- /dev/null +++ b/.github/workflows/kube.yml @@ -0,0 +1,40 @@ +name: e2e + +on: + schedule: + - cron: "00 * * * *" # run ci periodically at 3 am + push: #enabled after the API is stable + workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + kube: + name: e2e_kube + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + k8s: + - v1.25.3 + - v1.26.0 + - v1.27.3 + steps: + - uses: actions/checkout@v2 + - name: work with kubernetes + env: + K8SVERSION: ${{ matrix.k8s }} + run: | + ./.github/scripts/kind.sh + - name: chmod + if: always() + run: | + sudo chmod -R 777 /tmp/kind + ls /tmp/kind + - name: upload kind logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: xline_kind_log_${{ matrix.k8s }} + path: /tmp/kind/ \ No newline at end of file