Skip to content

Commit

Permalink
ci: enhance pull_request workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Diwakar Sharma <diwakar.sharma@datacore.com>
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
  • Loading branch information
dsharma-dc authored and niladrih committed Sep 13, 2024
1 parent 439bbc7 commit 19ab684
Show file tree
Hide file tree
Showing 27 changed files with 433 additions and 113 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/chart-lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: Chart Lint and Test

on:
push:
paths:
- 'deploy/helm/**'
branches:
- develop
pull_request:
paths:
- 'deploy/helm/**'
branches:
- develop
#on:
# push:
# paths:
# - 'deploy/helm/**'
# branches:
# - develop
# pull_request:
# paths:
# - 'deploy/helm/**'
# branches:
# - 'develop'
# - 'release/**'

jobs:
lint-test:
Expand Down
61 changes: 34 additions & 27 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
# Copyright 2020 The OpenEBS Authors. All rights reserved.
#
# 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.

name: ci
name: Pull Request CI

on:
pull_request:
branches:
- 'develop'
- 'v*'
- 'release/**'
paths-ignore:
- '*.md'
- 'BUILDMETA'
- 'changelogs/**'
- 'deploy/helm/**'
- 'docs/**'
- 'design/**'
- 'LICENSE'
Expand All @@ -35,6 +20,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go 1.19
uses: actions/setup-go@v5
Expand Down Expand Up @@ -62,7 +49,21 @@ jobs:
path: '.'
pattern: '*.sh'

unit-test:
- uses: cachix/install-nix-action@v22
- uses: rrbutani/use-nix-shell-action@v1.1.0
with:
file: shell.nix

- name: Check if the chart follows a valid semver version
run: |
branch_name="${{ github.event.pull_request.base.ref }}"
./scripts/validate-chart-version.sh --branch $branch_name
- name: Run chart-testing lint
run: |
ct lint --config ct.yaml
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -85,8 +86,8 @@ jobs:
name: coverage-$(date +%s)
flags: unittests

bdd-test:
needs: ['unit-test']
bdd-tests:
needs: ['unit-tests']
runs-on: ubuntu-latest
strategy:
fail-fast: true
Expand All @@ -95,13 +96,21 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: cachix/install-nix-action@v22
- uses: rrbutani/use-nix-shell-action@v1.1.0
with:
file: shell.nix

- name: Set up Go 1.19
uses: actions/setup-go@v5
with:
go-version: 1.19.9
cache: false

- name: Build images locally
run: make lvm-driver-image || exit 1;

- name: Setup Minikube-Kubernetes
uses: medyagh/setup-minikube@latest
with:
Expand All @@ -112,8 +121,10 @@ jobs:
cni: calico
start-args: '--install-addons=false'

- name: Build images locally
run: make lvm-driver-image || exit 1;
- name: Setting environment variables
run: |
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
echo "OPENEBS_NAMESPACE=openebs" >> $GITHUB_ENV
- name: bootstrap
run: make bootstrap
Expand All @@ -131,7 +142,7 @@ jobs:

csi-driver:
runs-on: ubuntu-latest
needs: ['lint', 'unit-test', 'bdd-test']
needs: ['lint', 'unit-tests', 'bdd-tests']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -144,8 +155,6 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.13.1

- name: Build
uses: docker/build-push-action@v5
Expand All @@ -154,5 +163,3 @@ jobs:
file: ./buildscripts/lvm-driver/Dockerfile.buildx
push: false
platforms: linux/amd64, linux/arm64
tags: |
openebs/lvm-driver:ci
12 changes: 6 additions & 6 deletions .github/workflows/release-charts.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Release Charts

on:
push:
paths:
- 'deploy/helm/**'
branches:
- develop
#on:
# push:
# paths:
# - 'deploy/helm/**'
# branches:
# - develop

jobs:
release:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tags
*.swo
*.swn
*.idea
*.test
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ ifeq (${DBUILD_SITE_URL}, )
export DBUILD_SITE_URL
endif

# Set the path to the Chart.yaml file
ROOT_DIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
CHART_YAML:=${ROOT_DIR}/deploy/helm/charts/Chart.yaml

ifeq (${IMAGE_TAG}, )
IMAGE_TAG = ci
IMAGE_TAG := $(shell awk -F': ' '/^version:/ {print $$2}' $(CHART_YAML))
export IMAGE_TAG
endif

Expand Down
42 changes: 13 additions & 29 deletions ci/ci-test.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
#!/usr/bin/env bash
# Copyright 2021 The OpenEBS 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.


set -e

LVM_OPERATOR="$(realpath deploy/lvm-operator.yaml)"
SNAP_CLASS="$(realpath deploy/sample/lvmsnapclass.yaml)"

export LVM_NAMESPACE="openebs"
export TEST_DIR="tests"
export NAMESPACE="kube-system"

# allow override
if [ -z "${KUBECONFIG}" ]
Expand All @@ -46,7 +29,7 @@ cleanup_foreign_lvmvg() {
if [ -f /tmp/openebs_ci_foreign_disk.img ]
then
sudo vgremove foreign_lvmvg --config="${FOREIGN_LVM_CONFIG}" -y || true
rm /tmp/openebs_ci_foreign_disk.img
sudo rm /tmp/openebs_ci_foreign_disk.img
fi
cleanup_loopdev
}
Expand All @@ -60,8 +43,8 @@ cleanup() {

kubectl delete pvc -n openebs lvmpv-pvc
kubectl delete -f "${SNAP_CLASS}"
kubectl delete -f "${LVM_OPERATOR}"

helm uninstall lvm-localpv -n "$OPENEBS_NAMESPACE" || true
# always return true
return 0
}
Expand All @@ -87,29 +70,30 @@ sudo sed -i '/^[^#]*thin_pool_autoextend_percent/ s/= .*/= 20/' /etc/lvm/lvm.con

# Prepare env for running BDD tests
# Minikube is already running
kubectl apply -f "${LVM_OPERATOR}"

helm install lvm-localpv ./deploy/helm/charts -n "$OPENEBS_NAMESPACE" --create-namespace --set lvmPlugin.pullPolicy=Never --set analytics.enabled=false
kubectl apply -f "${SNAP_CLASS}"

dumpAgentLogs() {
NR=$1
AgentPOD=$(kubectl get pods -l app=openebs-lvm-node -o jsonpath='{.items[0].metadata.name}' -n "$NAMESPACE")
kubectl describe po "$AgentPOD" -n "$NAMESPACE"
AgentPOD=$(kubectl get pods -l app=openebs-lvm-node -o jsonpath='{.items[0].metadata.name}' -n "$OPENEBS_NAMESPACE")
kubectl describe po "$AgentPOD" -n "$OPENEBS_NAMESPACE"
printf "\n\n"
kubectl logs --tail="${NR}" "$AgentPOD" -n "$NAMESPACE" -c openebs-lvm-plugin
kubectl logs --tail="${NR}" "$AgentPOD" -n "$OPENEBS_NAMESPACE" -c openebs-lvm-plugin
printf "\n\n"
}

dumpControllerLogs() {
NR=$1
ControllerPOD=$(kubectl get pods -l app=openebs-lvm-controller -o jsonpath='{.items[0].metadata.name}' -n "$NAMESPACE")
kubectl describe po "$ControllerPOD" -n "$NAMESPACE"
ControllerPOD=$(kubectl get pods -l app=openebs-lvm-controller -o jsonpath='{.items[0].metadata.name}' -n "$OPENEBS_NAMESPACE")
kubectl describe po "$ControllerPOD" -n "$OPENEBS_NAMESPACE"
printf "\n\n"
kubectl logs --tail="${NR}" "$ControllerPOD" -n "$NAMESPACE" -c openebs-lvm-plugin
kubectl logs --tail="${NR}" "$ControllerPOD" -n "$OPENEBS_NAMESPACE" -c openebs-lvm-plugin
printf "\n\n"
}

isPodReady(){
[ "$(kubectl get po "$1" -o 'jsonpath={.status.conditions[?(@.type=="Ready")].status}' -n "$NAMESPACE")" = 'True' ]
[ "$(kubectl get po "$1" -o 'jsonpath={.status.conditions[?(@.type=="Ready")].status}' -n "$OPENEBS_NAMESPACE")" = 'True' ]
}

isDriverReady(){
Expand All @@ -124,7 +108,7 @@ waitForLVMDriver() {

i=0
while [ "$i" -le "$period" ]; do
lvmDriver="$(kubectl get pods -l role=openebs-lvm -o 'jsonpath={.items[*].metadata.name}' -n "$NAMESPACE")"
lvmDriver="$(kubectl get pods -l role=openebs-lvm -o 'jsonpath={.items[*].metadata.name}' -n "$OPENEBS_NAMESPACE")"
if isDriverReady "$lvmDriver"; then
return 0
fi
Expand All @@ -143,7 +127,7 @@ waitForLVMDriver

cd $TEST_DIR

kubectl get po -n "$NAMESPACE"
kubectl get po -n "$OPENEBS_NAMESPACE"

set +e

Expand Down
1 change: 1 addition & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ chart-dirs:
- deploy/helm
helm-extra-args: --timeout=500s
validate-maintainers: false
check-version-increment: false
6 changes: 3 additions & 3 deletions deploy/helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: lvm-localpv
description: CSI Driver for dynamic provisioning of LVM Persistent Local Volumes.
version: 1.5.1
appVersion: 1.5.0
version: 1.6.1-prerelease
appVersion: 1.6.1-prerelease
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/openebs/icon/color/openebs-icon-color.png
home: https://openebs.io/
keywords:
Expand All @@ -16,5 +16,5 @@ sources:
- https://github.com/openebs/lvm-localpv
dependencies:
- name: crds
version: 1.5.1
version: 1.6.1-prerelease
condition: crds.enabled
4 changes: 2 additions & 2 deletions deploy/helm/charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $ helm install [RELEASE_NAME] openebs-lvmlocalpv/lvm-localpv --namespace [NAMESP


**Note:** If moving from the operator to helm
- Make sure the namespace provided in the helm install command is same as `LVM_NAMESPACE` (by default it is `openebs`) env in the controller deployment.
- Make sure the namespace provided in the helm install command is same as `OPENEBS_NAMESPACE` (by default it is `openebs`) env in the controller deployment.
- Before installing, clean up the stale deployment and daemonset from `kube-system` namespace using the below commands
```sh
kubectl delete deployment openebs-lvm-controller -n kube-system
Expand Down Expand Up @@ -92,7 +92,7 @@ helm install openebs-lvmlocalpv openebs-lvmlocalpv/lvm-localpv --namespace opene
| `lvmPlugin.image.registry` | Registry for openebs-lvm-plugin image | `""` |
| `lvmPlugin.image.repository` | Image repository for openebs-lvm-plugin | `openebs/lvm-driver` |
| `lvmPlugin.image.pullPolicy` | Image pull policy for openebs-lvm-plugin | `IfNotPresent` |
| `lvmPlugin.image.tag` | Image tag for openebs-lvm-plugin | `1.5.0` |
| `lvmPlugin.image.tag` | Image tag for openebs-lvm-plugin | `1.6.1-prerelease` |
| `lvmPlugin.metricsPort` | The TCP port number used for exposing lvm-metrics | `9500` |
| `lvmPlugin.allowedTopologies` | The comma seperated list of allowed node topologies | `kubernetes.io/hostname,` |
| `lvmNode.driverRegistrar.image.registry` | Registry for csi-node-driver-registrar image | `registry.k8s.io/` |
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/charts/charts/crds/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v2
name: crds
version: 1.5.1
version: 1.6.1-prerelease
description: A Helm chart that collects CustomResourceDefinitions (CRDs) from lvm-localpv.
2 changes: 1 addition & 1 deletion deploy/helm/charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Define meta labels for openebs lvm-localpv components
{{- define "lvmlocalpv.common.metaLabels" -}}
chart: {{ template "lvmlocalpv.chart" . }}
heritage: {{ .Release.Service }}
openebs.io/version: {{ .Values.release.version | quote }}
openebs.io/version: {{ .Chart.AppVersion | quote }}
role: {{ .Values.role | quote }}
{{- end -}}

Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/charts/templates/lvm-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ spec:
value: controller
- name: OPENEBS_CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
- name: LVM_NAMESPACE
- name: OPENEBS_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/charts/templates/lvm-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ spec:
value: unix:///plugin/csi.sock
- name: OPENEBS_NODE_DRIVER
value: agent
- name: LVM_NAMESPACE
- name: OPENEBS_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
Expand Down
4 changes: 1 addition & 3 deletions deploy/helm/charts/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Default values for openebs-lvmlocalpv.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
release:
version: "1.5.1"

imagePullSecrets:
# - name: "image-pull-secret"
Expand Down Expand Up @@ -151,7 +149,7 @@ lvmPlugin:
repository: openebs/lvm-driver
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 1.5.0
tag: 1.6.1-prerelease
ioLimits:
enabled: false
containerRuntime: containerd
Expand Down
Loading

0 comments on commit 19ab684

Please sign in to comment.