Skip to content

Commit

Permalink
Migrate to open cluster (#18) (#19)
Browse files Browse the repository at this point in the history
* Migrate to open cluster (#18)

* change import path

* changing generated code for k8s

* adding cicd logic

* moving e2e test to ibm api group

* adding sample and readme for channel repo

* using ibm-deployable as temp solution

* fix the operator-sdk generate name vilation issue

* tunning readme

* small

* update dpl dependency

* fix makefiles

* adding new dpl yaml

* fix the lint

* fix the lint

* travis

* fix makefile

* fix makefile

* make sure the harness include is correct link

* Update Makefile

* Migrate to open cluster (#20)

migrate

* fix make file

* disable sonar scan

* make sure unit test runs before build
  • Loading branch information
ianzhang366 authored Feb 24, 2020
1 parent a2f214d commit 3dbfcb2
Show file tree
Hide file tree
Showing 69 changed files with 965 additions and 216 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Temporary Build Files
build/_output
build/_test
.build-harness-bootstrap
# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
### Emacs ###
# -*- mode: gitignore; -*-
Expand Down
87 changes: 87 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

os:
- linux

language: go
go:
- "1.13"

services:
- docker

branches:
only:
- master
- dev
- /^[0-9]+\..*$/
- /^v[0-9]+\..*$/
- /^release-[0-9]+\..*$/

addons:
sonarcloud:
organization: "open-cluster-management"
token:
secure: "pIAub2t855Ji06TCRnxZdijQmnEhA8De4Jvoq6XH7xtUW/26Pn3nKg3yhA2dQp49dnfBlwQfwb0UOWZhY5FTAb/j4DpAXCpXoemXnKgxzknNfWLMr070MZQ/MomsSlArx13lXLHi3WkJv6oyCyyGwDYtRqDYYXK7ZHNuaSnqKLvSpoJ8nZYCmKigM5kSYepYIh+wg2P7Oz/6TjhK9Lv6rvCxzNhUAizGV+W5ddY01OTjwfut0zO6PvIJqPkpcWqUNTi8GKVY2/gjr8mPCf6ZuNc4laNV+r9rvhf9cUls1zpPpCvOCGVqIA1cYQ7Agq8fEf0k+CpaJeA3IbqJEv+REasPrK9VvOaY/pg55w2tU237RiK96BQnkvQFVkpozL7Bt0Q6nCk7bNxbMY8eYYHJ8ZoTHgIw1lXH4C+ADcaMeENG+zqhvBr/Mfk3M+ZFgCkKSA2LrSL9wDoYLmZL236rJxMBPAUCvjxAd+hUlHo1PXc1aoIR8hwWbGwq2T24Telvl3z6DOXFOLd2fzF5H50imGcSd7UugAJKFLqrVuCrE9nzVhPdZS1EBMxLMnBWG0LFEGUNSLasSaMI1oG6pZJALZBz+A251rSi+EBEP9DVv101a8JYzM99ynwnhpc6AYUw0p0q6YhuTZNkX1PxWvmMfXFdjASODbsnW2z04lcc5B0="

env:
global:
# Required
- OS=linux

# Component Specific
- COMPONENT_INIT_COMMAND=${TRAVIS_BUILD_DIR}/build/install-dependencies.sh
- COMPONENT_DEPLOY_COMMAND=${TRAVIS_BUILD_DIR}/build/deploy-to-cluster.sh
- COMPONENT_BUILD_COMMAND=${TRAVIS_BUILD_DIR}/build/build.sh
- COMPONENT_UNIT_TEST_COMMAND=${TRAVIS_BUILD_DIR}/build/run-unit-tests.sh
- COMPONENT_E2E_TEST_COMMAND=${TRAVIS_BUILD_DIR}/build/run-e2e-tests.sh

# define stages
stages:
- lint
- unit-test
- build
- test-e2e
- publish

jobs:
include:
- stage: lint
name: "Run code lint"
if: type = pull_request
script: bash ${TRAVIS_BUILD_DIR}/build/run-code-lint.sh
- stage: unit-test
name: "Run unit test"
if: type = pull_request
script:
# Set the image tag differently for PRs
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export COMPONENT_TAG_EXTENSION="-PR${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}"; fi;
# Bootstrap the build harness, pull test image, and run unit tests.
- |
make
make component/test/unit
# make sonar/go
- stage: build
name: "Build the image and run unit tests"
script:
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export COMPONENT_TAG_EXTENSION="-PR${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}"; fi;
- |
make
make component/build
make component/push
- stage: test-e2e
name: "Deploy the image to a cluster and run e2e tests"
if: type = pull_request
script:
#Check out a clusterpool, set up oc, deploy, run e2e tests, and return clusterpool cluster
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export COMPONENT_TAG_EXTENSION="-PR${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}"; fi;
- |
make
make component/pull
make component/test/e2e
- stage: publish
name: "Publish the image to quay with an official version/sha tag and publish entry to integration pipeline stage"
if: type = push AND branch =~ /^release-[0-9]+\..*$/
script:
- |
make
make pipeline-manifest/update PIPELINE_MANIFEST_COMPONENT_SHA256=${TRAVIS_COMMIT} PIPELINE_MANIFEST_COMPONENT_REPO=${TRAVIS_REPO_SLUG} PIPELINE_MANIFEST_BRANCH=${TRAVIS_BRANCH}
2 changes: 2 additions & 0 deletions COMPONENT_NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
multicloud-operators-channel

1 change: 1 addition & 0 deletions COMPONENT_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.5.0
56 changes: 28 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This repo is build locally for dev/test by default;
# Override this variable in CI env.
BUILD_LOCALLY ?= 1
# This repo is build in Travis-ci by default;
# Override this variable in local env.
TRAVIS_BUILD ?= 1

# Image URL to use all building/pushing image targets;
# Use your own docker registry and image name for dev/test by overridding the IMG and REGISTRY environment variable.
IMG ?= multicloud-operators-channel
REGISTRY ?= quay.io/multicloudlab
IMG ?= $(shell cat COMPONENT_NAME 2> /dev/null)
REGISTRY ?= quay.io/open-cluster-management

# Github host to use for checking the source tree;
# Override this variable ue with your own value if you're working on forked repo.
GIT_HOST ?= github.com/IBM
GIT_HOST ?= github.com/open-cluster-management

PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
Expand All @@ -36,8 +36,8 @@ export GOBIN ?= $(GOBIN_DEFAULT)
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
DEST := $(GOPATH)/src/$(GIT_HOST)/$(BASE_DIR)
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
VERSION ?= $(shell cat COMPONENT_VERSION 2> /dev/null)
IMAGE_NAME_AND_VERSION ?= $(REGISTRY)/$(IMG)

LOCAL_OS := $(shell uname)
ifeq ($(LOCAL_OS),Linux)
Expand All @@ -50,12 +50,24 @@ else
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported")
endif

all: fmt check test coverage build images
.PHONY: fmt lint test coverage build build-images

ifneq ("$(realpath $(DEST))", "$(realpath $(PWD))")
$(error Please run 'make' from $(DEST). Current directory is $(PWD))
endif


# GITHUB_USER containing '@' char must be escaped with '%40'
GITHUB_USER := $(shell echo $(GITHUB_USER) | sed 's/@/%40/g')
GITHUB_TOKEN ?=

ifeq ($(TRAVIS_BUILD),1)
-include $(shell curl -H 'Authorization: token ${GITHUB_TOKEN}' -H 'Accept: application/vnd.github.v4.raw' -L https://api.github.com/repos/open-cluster-management/build-harness-extensions/contents/templates/Makefile.build-harness-bootstrap -o .build-harness-bootstrap; echo .build-harness-bootstrap)
endif

default::
@echo "Build Harness Bootstrapped"

include common/Makefile.common.mk

############################################################
Expand Down Expand Up @@ -101,39 +113,27 @@ test:
coverage:
@common/scripts/codecov.sh

############################################################
# install operator sdk section
############################################################

install-operator-sdk:
@operator-sdk version 2> /dev/null ; if [ $$? -ne 0 ]; then ./common/scripts/install-operator-sdk.sh; fi

############################################################
# build section
############################################################

build:
@common/scripts/gobuild.sh build/_output/bin/$(IMG) ./cmd/manager

local:
@GOOS=darwin common/scripts/gobuild.sh build/_output/bin/$(IMG) ./cmd/manager

############################################################
# images section
############################################################

images: build build-push-images
build-images:
@operator-sdk build ${IMAGE_NAME_AND_VERSION}
@docker tag ${IMAGE_NAME_AND_VERSION} $(REGISTRY)/$(IMG):latest

ifeq ($(BUILD_LOCALLY),0)
export CONFIG_DOCKER_TARGET = config-docker
endif

build-push-images: install-operator-sdk $(CONFIG_DOCKER_TARGET)
@operator-sdk build $(REGISTRY)/$(IMG):$(VERSION)
@docker tag $(REGISTRY)/$(IMG):$(VERSION) $(REGISTRY)/$(IMG)
@if [ $(BUILD_LOCALLY) -ne 1 ]; then docker push $(REGISTRY)/$(IMG):$(VERSION); docker push $(REGISTRY)/$(IMG); fi

############################################################
# clean section
############################################################
clean:
clean::
rm -f build/_output/bin/$(IMG)

.PHONY: all build check lint test coverage images
2 changes: 1 addition & 1 deletion OWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
approvers:
- kuanf
- jnpacker
- ianzhang366
reviewers:
Expand All @@ -8,3 +7,4 @@ reviewers:
- sahare
- itdove
- rwellon
- kuanf
Loading

0 comments on commit 3dbfcb2

Please sign in to comment.