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 7 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.

77 changes: 38 additions & 39 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/[0-9]+.[0-9]+'

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,27 @@ jobs:
reporter: github-pr-review
path: '.'
pattern: '*.sh'

- uses: cachix/install-nix-action@v22
- name: Check if the chart follows a valid semver version
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' scripts/nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
branch_name="${{ github.event.pull_request.base.ref }}"
nix-shell --pure --run "./scripts/validate-version.sh --branch $branch_name" ./scripts/shell.nix


unit-test:
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(nix-shell --pure --run "ct list-changed --config ct.yaml" ./scripts/shell.nix)
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Run chart-testing (lint)
run: nix-shell --pure --run "ct lint --config ct.yaml" ./scripts/shell.nix

unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -60,9 +65,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,18 +76,20 @@ 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`

- 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 -y zfsutils-linux
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
Expand All @@ -99,17 +106,14 @@ 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;

- name: bootstrap
run: make bootstrap

- name: Running tests
run: |
make ci
make sanity

- name: Upload CI Test Coverage Report
uses: codecov/codecov-action@v4
with:
Expand All @@ -120,7 +124,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 +137,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 +145,3 @@ jobs:
file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile
push: false
platforms: linux/amd64, linux/arm64
tags: |
openebs/zfs-driver:ci

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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ endif


ifeq (${IMAGE_TAG}, )
IMAGE_TAG = ci
IMAGE_TAG = 2.7.0-develop
export IMAGE_TAG
endif

Expand Down
45 changes: 15 additions & 30 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
# 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
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