From dcb78617b10eff52fc6f293efeaa19f0461de5b1 Mon Sep 17 00:00:00 2001 From: Weiwei Yang Date: Thu, 14 May 2020 11:20:57 +1000 Subject: [PATCH] [YUNIKORN-143] Travis CI integration (#110) Replace github workflow with Travis-CI. Add pushing docker images to the apache docker repo. This includes a name change for the docker images. Fixes: #110 --- .github/workflows/main.yml | 26 ------------------- .travis.yml | 52 ++++++++++++++++++++++++++++++++++++++ Makefile | 19 +++++++++----- README.md | 6 +++++ 4 files changed, 71 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 6f9079e66..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Precommit check - -on: - pull_request: - branches: - - master - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Set up Go 1.12 - uses: actions/setup-go@v1 - with: - go-version: 1.12 - - - name: Checkout source code - uses: actions/checkout@v2 - - - name: Check license - run: make common-check-license - - - name: unit test - run: make test diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..b37ed00e6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,52 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +language: go + +os: + - linux + +go: + - "1.12" + +git: + depth: 1 + +services: + - 'docker' + +env: + - GO111MODULE=on + +install: true + +jobs: + include: + - stage: pre-commit checks + script: + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.22.2 + - make license-check + - make test + - make lint + after_success: bash <(curl -s https://codecov.io/bash) + - stage: publish docker image + deploy: + provider: script + script: make push + on: + branch: master + #condition: $TRAVIS_EVENT_TYPE = cron diff --git a/Makefile b/Makefile index 148842765..79f593ea3 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ endif # Image build parameters # This tag of the image must be changed when pushed to a public repository. ifeq ($(REGISTRY),) -REGISTRY := yunikorn +REGISTRY := apache endif # Force Go modules even when checked out inside GOPATH @@ -71,8 +71,8 @@ lint: fi ; \ $${lintBin} run --new -.PHONY: common-check-license -common-check-license: +.PHONY: license-check +license-check: @echo "checking license header" @licRes=$$(grep -Lr --include=*.{go,sh} "Licensed to the Apache Software Foundation" .) ; \ if [ -n "$${licRes}" ]; then \ @@ -124,7 +124,7 @@ sched_image: scheduler @coreSHA=$$(go list -m "github.com/apache/incubator-yunikorn-core" | cut -d "-" -f5) ; \ siSHA=$$(go list -m "github.com/apache/incubator-yunikorn-scheduler-interface" | cut -d "-" -f6) ; \ shimSHA=$$(git rev-parse --short=12 HEAD) ; \ - docker build ./deployments/image/configmap -t ${REGISTRY}/yunikorn-scheduler-k8s:${VERSION} \ + docker build ./deployments/image/configmap -t ${REGISTRY}/yunikorn:scheduler-${VERSION} \ --label "yunikorn-core-revision=$${coreSHA}" \ --label "yunikorn-scheduler-interface-revision=$${siSHA}" \ --label "yunikorn-k8shim-revision=$${shimSHA}" \ @@ -149,18 +149,25 @@ admission: init adm_image: admission @echo "building admission controller docker images" @cp ${ADMISSION_CONTROLLER_BIN_DIR}/${POD_ADMISSION_CONTROLLER_BINARY} ./deployments/image/admission - docker build ./deployments/image/admission -t ${REGISTRY}/yunikorn-scheduler-admission-controller:${VERSION} + docker build ./deployments/image/admission -t ${REGISTRY}/yunikorn:admission-${VERSION} @rm -f ./deployments/image/admission/${POD_ADMISSION_CONTROLLER_BINARY} # Build all images based on the production ready version .PHONY: image image: sched_image adm_image +.PHONY: push +push: image + @echo "push docker images" + echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + docker push ${REGISTRY}/yunikorn:scheduler-${VERSION} + docker push ${REGISTRY}/yunikorn:admission-${VERSION} + # Run the tests after building .PHONY: test test: @echo "running unit tests" - go test ./... -cover -race -tags deadlock + go test ./... -race -tags deadlock -coverprofile=coverage.txt -covermode=atomic go vet $(REPO)... # Simple clean of generated files only (no local cleanup). diff --git a/README.md b/README.md index 629ffe044..6b9f3e2c1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # YuniKorn Scheduler for Kubernetes (yunikorn-k8shim) +[![Build Status](https://travis-ci.org/apache/incubator-yunikorn-k8shim.svg?branch=master)](https://travis-ci.org/apache/incubator-yunikorn-k8shim) +[![codecov](https://codecov.io/gh/apache/incubator-yunikorn-k8shim/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/incubator-yunikorn-k8shim) +[![Go Report Card](https://goreportcard.com/badge/github.com/apache/incubator-yunikorn-k8shim)](https://goreportcard.com/report/github.com/apache/incubator-yunikorn-k8shim) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![Repo Size](https://img.shields.io/github/repo-size/apache/incubator-yunikorn-k8shim)](https://img.shields.io/github/repo-size/apache/incubator-yunikorn-k8shim) + YuniKorn scheduler shim for kubernetes is a customized k8s scheduler, it can be deployed in a K8s cluster and work as the scheduler. This project contains the k8s shim layer code for k8s, it depends on `yunikorn-core` which encapsulates all the actual scheduling logic. By default, it handles all pods scheduling if pod's spec has field `schedulerName: yunikorn`.