From 3d535659d5f44b12286ac2941a3f396e633fcbee Mon Sep 17 00:00:00 2001 From: Pawan Prakash Sharma Date: Thu, 4 Mar 2021 16:05:33 +0530 Subject: [PATCH] feat(action): migrating to github action from travis (#27) * move bdd test cases to github action * remove travis file and move ansible to github * set the default image org as openebs Signed-off-by: Pawan --- .github/workflows/build.yml | 63 +++++++++++++++++++++++++++- .github/workflows/pull_request.yml | 33 ++++++++++++++- .travis.yml | 58 ------------------------- changelogs/unreleased/27-pawanpraka1 | 1 + ci/ci-test.sh | 10 +++-- 5 files changed, 102 insertions(+), 63 deletions(-) delete mode 100644 .travis.yml create mode 100644 changelogs/unreleased/27-pawanpraka1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb653d0b..cc4e6ad4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,9 +44,70 @@ jobs: - name: Upload Coverage Report uses: codecov/codecov-action@v1 + bdd-test: + needs: ['unit-test'] + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + kubernetes: [v1.20.1] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: 1.14.7 + + - name: Setup Minikube-Kubernetes + uses: manusa/actions-setup-minikube@v2.3.0 + with: + minikube version: v1.16.0 + kubernetes version: ${{ matrix.kubernetes }} + github token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build images locally + run: make lvm-driver-image || exit 1; + + - name: bootstrap + run: make bootstrap + + - name: Running tests + run: ./ci/ci-test.sh + + ansible: + runs-on: ubuntu-latest + needs: ['lint', 'unit-test', 'bdd-test'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set Image Org + # sets the default IMAGE_ORG to openebs + run: | + [ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}} + echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push the ansible image + uses: docker/build-push-action@v2 + with: + file: ./e2e-tests/Dockerfile + push: true + load: false + platforms: linux/amd64 + tags: | + ${{ env.IMAGE_ORG }}/lvm-localpv-e2e:ci + csi-driver: runs-on: ubuntu-latest - needs: ['lint', 'unit-test'] + needs: ['lint', 'unit-test', 'bdd-test'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 3a2cbc72..6f56e036 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -56,10 +56,41 @@ jobs: - name: Upload Coverage Report uses: codecov/codecov-action@v1 + bdd-test: + needs: ['unit-test'] + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + kubernetes: [v1.20.1] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: 1.14.7 + + - name: Setup Minikube-Kubernetes + uses: manusa/actions-setup-minikube@v2.3.0 + with: + minikube version: v1.16.0 + kubernetes version: ${{ matrix.kubernetes }} + github token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build images locally + run: make lvm-driver-image || exit 1; + + - name: bootstrap + run: make bootstrap + + - name: Running tests + run: ./ci/ci-test.sh csi-driver: runs-on: ubuntu-latest - needs: ['lint', 'unit-test'] + needs: ['lint', 'unit-test', 'bdd-test'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3ba95878..00000000 --- a/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ -sudo: required -dist: bionic -env: - global: - - CHANGE_MINIKUBE_NONE_USER=true - - MINIKUBE_WANTUPDATENOTIFICATION=false - - MINIKUBE_WANTREPORTERRORPROMPT=false - - MINIKUBE_HOME=$HOME - - CHANGE_MINIKUBE_NONE_USER=true - - KUBECONFIG=$HOME/.kube/config -services: - - docker -language: go -go: - - 1.14.7 - -addons: - apt: - update: true -before_install: - - sudo apt-get update -qq -install: - - if [ "$TRAVIS_BUILD_DIR" != "$GOPATH/src/github.com/openebs/lvm-localpv" ]; then - mkdir -p $GOPATH/src/github.com/openebs/; - mv $TRAVIS_BUILD_DIR $GOPATH/src/github.com/openebs; - cd $GOPATH/src/github.com/openebs/lvm-localpv; - fi - - make bootstrap - - make format - - make license-check - - make golint - - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl - && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ - - curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.17.1/minikube-linux-amd64 - && chmod +x minikube && sudo mv minikube /usr/local/bin/ - - mkdir -p $HOME/.kube $HOME/.minikube - - touch $KUBECONFIG - - sudo minikube start --vm-driver=none --kubernetes-version=v1.17.4 - - sudo chown -R $USER $HOME/.minikube - - sudo chown -R $USER $HOME/.kube - - JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; - until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do - sleep 1; done - - kubectl cluster-info - - sudo modprobe dm-snapshot -before_script: - - "./buildscripts/travis-build.sh" -script: - - make ansible-runner-image || travis_terminate 1 - - sudo -E env "PATH=$PATH" make ci -after_success: - - make deploy-images - - make deploy-e2e-images - - bash <(curl -s https://codecov.io/bash) -notifications: - email: - recipients: - - pawan@mayadata.io diff --git a/changelogs/unreleased/27-pawanpraka1 b/changelogs/unreleased/27-pawanpraka1 new file mode 100644 index 00000000..172e9624 --- /dev/null +++ b/changelogs/unreleased/27-pawanpraka1 @@ -0,0 +1 @@ +move the bdd test cases to github action diff --git a/ci/ci-test.sh b/ci/ci-test.sh index 31738918..d4145cda 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -18,9 +18,12 @@ set -e # setup the lvm volume group to create the volume truncate -s 1024G /tmp/disk.img -disk=`losetup -f /tmp/disk.img --show` -pvcreate "$disk" -vgcreate lvmvg "$disk" +disk=`sudo losetup -f /tmp/disk.img --show` +sudo pvcreate "$disk" +sudo vgcreate lvmvg "$disk" + +# install snapshot module for lvm +sudo modprobe dm-snapshot LVM_OPERATOR=deploy/lvm-operator.yaml SNAP_CLASS=deploy/sample/lvmsnapclass.yaml @@ -28,6 +31,7 @@ SNAP_CLASS=deploy/sample/lvmsnapclass.yaml export LVM_NAMESPACE="openebs" export TEST_DIR="tests" export NAMESPACE="kube-system" +export KUBECONFIG=$HOME/.kube/config # Prepare env for running BDD tests # Minikube is already running