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

ci: enhance pull_request workflow #557

Merged
merged 13 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
53 changes: 0 additions & 53 deletions .github/workflows/chart-lint-test.yml

This file was deleted.

72 changes: 35 additions & 37 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
# 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:
paths-ignore:
- 'deploy/helm/**'
- 'docs/**'
- 'design/**'
- 'changelogs/**'
- '*.md'
- 'MAINTAINERS'
branches:
# on pull requests to develop and release branches
- develop
- 'v*'
- 'release/**'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Shellcheck
uses: reviewdog/action-shellcheck@v1
Expand All @@ -41,9 +28,21 @@ jobs:
reporter: github-pr-review
path: '.'
pattern: '*.sh'

- 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-test:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -60,9 +59,9 @@ jobs:
name: coverage-$(date +%s)
flags: unittests

bdd-test:
needs: ['unit-test']
bdd-tests:
runs-on: ubuntu-latest
needs: ['unit-tests']
strategy:
fail-fast: true
matrix:
Expand All @@ -71,19 +70,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Installation
run: |
sudo apt-get update -qq
sudo apt-get install -y zfsutils-linux
truncate -s 100G /tmp/disk.img
sudo zpool create zfspv-pool `sudo losetup -f /tmp/disk.img --show`
- 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@v4
with:
go-version: 1.19.9
cache: false

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

- name: Setup zfs pools
run: |
sudo apt-get install zfsutils-linux -y
truncate -s 100G /tmp/disk.img
sudo zpool create zfspv-pool $(sudo losetup -f /tmp/disk.img --show)

- name: Setup Minikube-Kubernetes
uses: medyagh/setup-minikube@latest
with:
Expand All @@ -99,9 +105,6 @@ jobs:
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
echo "OPENEBS_NAMESPACE=openebs" >> $GITHUB_ENV

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

niladrih marked this conversation as resolved.
Show resolved Hide resolved
- name: bootstrap
run: make bootstrap

Expand All @@ -120,7 +123,7 @@ jobs:

csi-driver:
runs-on: ubuntu-latest
needs: ['lint', 'bdd-test']
needs: ['lint', 'bdd-tests']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -133,8 +136,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 @@ -143,6 +144,3 @@ jobs:
file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile
push: false
platforms: linux/amd64, linux/arm64
tags: |
openebs/zfs-driver:ci

13 changes: 7 additions & 6 deletions .github/workflows/release-charts.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Release Charts

on:
push:
paths:
- 'deploy/helm/**'
branches:
- develop
# Disable the workflow till we have the proper CI setup
# 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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ ifeq (${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 yq e '.version' $(CHART_YAML)}
Abhinandan-Purkait marked this conversation as resolved.
Show resolved Hide resolved
export IMAGE_TAG
endif

Expand Down
47 changes: 16 additions & 31 deletions ci/ci-test.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,42 @@
#!/usr/bin/env bash
# Copyright 2019 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

ZFS_OPERATOR=deploy/zfs-operator.yaml
SNAP_CLASS=deploy/sample/zfssnapclass.yaml

TEST_DIR="tests"


# Prepare env for runnging BDD tests
# Prepare env for running BDD tests
# Minikube is already running
kubectl apply -f $ZFS_OPERATOR
kubectl apply -f $SNAP_CLASS
helm install zfs-localpv ./deploy/helm/charts -n "$OPENEBS_NAMESPACE" --create-namespace --set zfsPlugin.pullPolicy=Never --set analytics.enabled=false
kubectl apply -f "$SNAP_CLASS"

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

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


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


isDriverReady(){
for pod in $zfsDriver;do
isPodReady $pod || return 1
isPodReady "$pod" || return 1
done
}

Expand All @@ -63,8 +47,8 @@ waitForZFSDriver() {

i=0
while [ "$i" -le "$period" ]; do
zfsDriver="$(kubectl get pods -l role=openebs-zfs -o 'jsonpath={.items[*].metadata.name}' -n kube-system)"
if isDriverReady $zfsDriver; then
zfsDriver="$(kubectl get pods -l role=openebs-zfs -o 'jsonpath={.items[*].metadata.name}' -n openebs)"
if isDriverReady "$zfsDriver"; then
return 0
fi

Expand All @@ -82,7 +66,7 @@ waitForZFSDriver

cd $TEST_DIR

kubectl get po -n kube-system
kubectl get po -n openebs

set +e

Expand Down Expand Up @@ -123,4 +107,5 @@ kubectl get zfssnapshots.zfs.openebs.io -n openebs -oyaml
exit 1
fi

echo "\n\n######### All test cases passed #########\n\n"
printf "\n\n"
echo "######### All test cases passed #########"
28 changes: 7 additions & 21 deletions ci/sanity.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
#!/bin/bash

# Copyright 2020 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 -ex
test_repo="kubernetes-csi"

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

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

Expand Down Expand Up @@ -66,7 +52,7 @@ EOT
make clean
make

UUID=$(kubectl get pod -n kube-system -l "openebs.io/component-name=openebs-zfs-controller" -o 'jsonpath={.items[0].metadata.uid}')
UUID=$(kubectl get pod -n openebs -l "openebs.io/component-name=openebs-zfs-controller" -o 'jsonpath={.items[0].metadata.uid}')
SOCK_PATH=/var/lib/kubelet/pods/"$UUID"/volumes/kubernetes.io~empty-dir/socket-dir/csi.sock

sudo chmod -R 777 /var/lib/kubelet
Expand Down
3 changes: 2 additions & 1 deletion ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ target-branch: develop
chart-dirs:
- deploy/helm
helm-extra-args: --timeout=500s
validate-maintainers: false
validate-maintainers: false
check-version-increment: false
Loading
Loading