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

chore(build): merge jiva-csi and jiva-operator repos #28

Merged
merged 6 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
100 changes: 100 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# 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: build

on: ['push']

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
path: '.'
pattern: '*.sh'
exclude: './vendor/*'

unit-tests:
name: unit tests
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14.7

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: verify license
run: make license-check

- name: verify dependencies
run: make deps

- name: verify tests
run: make test

e2e-tests:
# needs: ['unit-tests']
shubham14bajpai marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kubernetes: [v1.18.6]
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/[email protected]
with:
minikube version: v1.9.2
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}

- name: Set tag
run: |
BRANCH="${GITHUB_REF##*/}"
CI_TAG="ci"
echo "TAG=${CI_TAG}" >> $GITHUB_ENV
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV

- name: Build images locally
run: make image.operator image.plugin || exit 1;

- name: Install tests dependencies
run: make bootstrap

- name: Running tests
run: |
kubectl apply -f https://raw.githubusercontent.com/openebs/openebs/master/k8s/openebs-operator.yaml
kubectl apply -f deploy/operator.yaml
kubectl apply -f deploy/jiva-csi.yaml
./ci/ci.sh
cd ./tests
make tests
105 changes: 105 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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

on:
pull_request:
branches:
# on pull requests to master and release branches
- master
- 'v*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
path: '.'
pattern: '*.sh'
exclude: './vendor/*'

unit-tests:
name: unit tests
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14.7

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: verify license
run: make license-check

- name: verify dependencies
run: make deps

- name: verify tests
run: make test

e2e-tests:
# needs: ['unit-tests']
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kubernetes: [v1.18.6]
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/[email protected]
with:
minikube version: v1.9.2
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}

- name: Set tag
run: |
BRANCH="${GITHUB_REF##*/}"
CI_TAG="ci"
echo "TAG=${CI_TAG}" >> $GITHUB_ENV
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV

- name: Build images locally
run: make image.operator image.plugin || exit 1;

- name: Install tests dependencies
run: make bootstrap

- name: Running tests
run: |
kubectl apply -f https://raw.githubusercontent.com/openebs/openebs/master/k8s/openebs-operator.yaml
kubectl apply -f deploy/operator.yaml
kubectl apply -f deploy/jiva-csi.yaml
./ci/ci.sh
cd ./tests
make tests
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ script:
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
#- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
- make license-check
- make image
- make push
- make image.operator image.plugin
- make push.operator push.plugin
#- ./ci/travis-ci.sh
# If this build is running due to travis release tag, and
# this job indicates to push the release downstream, then
Expand Down
88 changes: 53 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ export XC_ARCH
ARCH:=${XC_OS}_${XC_ARCH}
export ARCH

ifeq (${BASEIMAGE}, )
ifeq ($(ARCH),linux_arm64)
BASEIMAGE:=arm64v8/ubuntu:18.04
else
BASEIMAGE:=ubuntu:16.04
endif
endif
export BASEIMAGE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we not going to support arm builds, or has it been handled elsewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will be building multi-arch builds using docker buildx github action. Will take that in separate PR.

# Specify the docker arg for repository url
ifeq (${DBUILD_REPO_URL}, )
DBUILD_REPO_URL="https://github.com/openebs/jiva-operator"
Expand All @@ -82,13 +73,19 @@ DBUILD_DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
OPERATOR_NAME=jiva-operator
OPERATOR_TAG=ci

# Output plugin name and its image name and tag
PLUGIN_NAME=jiva-csi
PLUGIN_TAG=ci

export DBUILD_ARGS=--build-arg DBUILD_DATE=${DBUILD_DATE} --build-arg DBUILD_REPO_URL=${DBUILD_REPO_URL} --build-arg DBUILD_SITE_URL=${DBUILD_SITE_URL} --build-arg ARCH=${ARCH}

# Tools required for different make targets or for development purposes
EXTERNAL_TOOLS=\
golang.org/x/tools/cmd/cover \
github.com/axw/gocov/gocov \
github.com/ugorji/go/codec/codecgen \
github.com/onsi/ginkgo/ginkgo \
github.com/onsi/gomega/...

# Lint our code. Reference: https://golang.org/cmd/vet/
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods \
Expand All @@ -113,7 +110,7 @@ else
export GIT_TAG
endif

PACKAGES = $(shell go list ./... | grep -v 'vendor')
PACKAGES = $(shell go list ./... | grep -v 'vendor\|tests')

LDFLAGS ?= \
-extldflags "-static" \
Expand All @@ -139,7 +136,8 @@ print-variables:
@echo " GIT_TAG: ${GIT_TAG}"
@echo " COMMIT: ${COMMIT}"
@echo "Testing variables:"
@echo " Produced Image: ${OPERATOR_NAME}:${OPERATOR_TAG}"
@echo " Produced Operator Image: ${OPERATOR_NAME}:${OPERATOR_TAG}"
@echo " Produced CSI-Plugin Image: ${PLUGIN_NAME}:${PLUGIN_TAG}"
@echo " IMAGE_ORG: ${IMAGE_ORG}"


Expand Down Expand Up @@ -172,18 +170,6 @@ vet:
deps: .get
go mod vendor

build: deps test
@echo "--> Build binary $(OPERATOR_NAME) ..."
GOOS=linux go build -a -ldflags '$(LDFLAGS)' -o ./build/_output/bin/${ARCH}/$(OPERATOR_NAME) ./cmd/manager/main.go

.PHONY: Dockerfile.jo
Dockerfile.jo: ./build/Dockerfile
sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@

image: build Dockerfile.jo
@echo "--> Build image $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) ..."
docker build -f Dockerfile.jo -t $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(OPERATOR_TAG) $(DBUILD_ARGS) .

generate:
@echo "--> Generate CR ..."
operator-sdk generate k8s --verbose
Expand All @@ -192,21 +178,53 @@ operator:
@echo "--> Build using operator-sdk ..."
operator-sdk build $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) --verbose

push-image: image
@echo "--> Push image $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(OPERATOR_TAG) ..."
docker push $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(OPERATOR_TAG)
build.operator: deps
@echo "--> Build binary $(OPERATOR_NAME) ..."
GOOS=linux go build -a -ldflags '$(LDFLAGS)' -o ./build/bin/$(OPERATOR_NAME) ./cmd/manager/main.go

image.operator: build.operator
@echo "--> Build image $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) ..."
docker build -f ./build/operator/Dockerfile -t $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) $(DBUILD_ARGS) .

push-image.operator: image.operator
@echo "--> Push image $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) ..."
docker push $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG)

push.operator:
@echo "--> Push image $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) ..."
@DIMAGE=$(IMAGE_ORG)/$(OPERATOR_NAME) ./build/push

tag.operator:
@echo "--> Tag image $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) to $(IMAGE_ORG)/$(OPERATOR_NAME):$(GIT_TAG) ..."
docker tag $(IMAGE_ORG)/$(OPERATOR_NAME):$(OPERATOR_TAG) $(IMAGE_ORG)/$(OPERATOR_NAME)-$(ARCH):$(GIT_TAG)

push-tag.operator: tag.operator push.operator
@echo "--> Push image $(IMAGE_ORG)/$(OPERATOR_NAME):$(GIT_TAG) ..."
docker push $(IMAGE_ORG)/$(OPERATOR_NAME):$(GIT_TAG)

build.plugin: deps
@echo "--> Build binary $(PLUGIN_NAME) ..."
GOOS=linux go build -a -ldflags '$(LDFLAGS)' -o ./build/bin/$(PLUGIN_NAME) ./cmd/csi/main.go

image.plugin: build.plugin
@echo "--> Build image $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG) ..."
docker build -f ./build/plugin/Dockerfile -t $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG) $(DBUILD_ARGS) .

push-image.plugin: image.plugin
@echo "--> Push image $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG) ..."
docker push $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG)

push:
@echo "--> Push image $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(OPERATOR_TAG) ..."
@DIMAGE=$(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH) ./build/push
push.plugin:
@echo "--> Push image $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG) ..."
@DIMAGE=$(IMAGE_ORG)/$(PLUGIN_NAME) ./build/push

tag:
@echo "--> Tag image $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(OPERATOR_TAG) to $(IMAGE_ORG)/$(OPERATOR_NAME):$(GIT_TAG) ..."
docker tag $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(OPERATOR_TAG) $(IMAGE_ORG)/$(OPERATOR_NAME)-$(ARCH):$(GIT_TAG)
tag.plugin:
@echo "--> Tag image $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG) to $(IMAGE_ORG)/$(PLUGIN_NAME):$(GIT_TAG) ..."
docker tag $(IMAGE_ORG)/$(PLUGIN_NAME):$(PLUGIN_TAG) $(IMAGE_ORG)/$(PLUGIN_NAME):$(GIT_TAG)

push-tag: tag push
@echo "--> Push image $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(GIT_TAG) ..."
docker push $(IMAGE_ORG)/$(OPERATOR_NAME)-$(XC_ARCH):$(GIT_TAG)
push-tag.plugin: tag.plugin push.plugin
@echo "--> Push image $(IMAGE_ORG)/$(PLUGIN_NAME):$(GIT_TAG) ..."
docker push $(IMAGE_ORG)/$(PLUGIN_NAME):$(GIT_TAG)

clean:
rm -rf ./build/_output/bin/
Expand Down
Binary file added build/bin/jiva-csi
Binary file not shown.
Binary file added build/bin/jiva-operator
Binary file not shown.
8 changes: 4 additions & 4 deletions build/Dockerfile → build/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM @BASEIMAGE@
FROM ubuntu:18.04

ENV OPERATOR=/usr/local/bin/jiva-operator \
USER_UID=1001 \
Expand All @@ -24,14 +24,14 @@ ARG DBUILD_SITE_URL
ARG ARCH

# install operator binary
ADD build/_output/bin/${ARCH}/jiva-operator ${OPERATOR}
ADD build/bin/jiva-operator ${OPERATOR}

COPY build/bin /usr/local/bin
RUN /usr/local/bin/user_setup

LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="jiva-csi"
LABEL org.label-schema.description="OpenEBS Jiva CSI Plugin"
LABEL org.label-schema.name="jiva-operator"
LABEL org.label-schema.description="OpenEBS Jiva Operator"
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL
Expand Down
Loading