Add gate, check jobs for zuul
Add gate and check jobs for zuul, which requires building in a container that has the appropriate version of golang installed. This code is based on similar code in the airshipctl repository. Change-Id: I77fd18335b68f1de81e0227eb2a7c77a1a392640
This commit is contained in:
parent
252c00c780
commit
6d9d20e3d5
16
.zuul.yaml
16
.zuul.yaml
|
@ -13,14 +13,20 @@
|
|||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- noop
|
||||
- airship-airshipui-lint-unit
|
||||
gate:
|
||||
jobs:
|
||||
- noop
|
||||
- airship-airshipui-lint-unit
|
||||
post:
|
||||
jobs:
|
||||
- airshipui-upload-git-mirror
|
||||
|
||||
- job:
|
||||
name: airship-airshipui-lint-unit
|
||||
pre-run: playbooks/airship-airshipui-deploy-docker.yaml
|
||||
run: playbooks/airship-airshipui-lint-unit.yaml
|
||||
nodeset: airship-airshipui-single-node
|
||||
|
||||
- job:
|
||||
name: airshipui-upload-git-mirror
|
||||
parent: upload-git-mirror
|
||||
|
@ -79,3 +85,9 @@
|
|||
/tp/MjZpSzeWVBeshm3rFSEKUSIh6Ny09pT6//Cb0mhaitr+q7hHo0OdCiiovuoE/05Q9
|
||||
4zLKXC0a6/DRvnpq1jZL5cssNrf5sjrspIPe2yf/gy+NDG+eN/2zyAYhHgaA5rDOPwpjo
|
||||
bpCTetrKmxTJbwMjPML5oRLef5GJU1zGLOmNA68AOGlt5RFC1lSUPe+ZTW8QTM=
|
||||
|
||||
- nodeset:
|
||||
name: airship-airshipui-single-node
|
||||
nodes:
|
||||
- name: primary
|
||||
label: ubuntu-bionic
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
ARG GO_IMAGE=docker.io/golang:1.13.1-stretch
|
||||
ARG RELEASE_IMAGE=scratch
|
||||
FROM ${GO_IMAGE} as builder
|
||||
|
||||
SHELL [ "/bin/bash", "-cex" ]
|
||||
WORKDIR /usr/src/airshipui
|
||||
|
||||
# Take advantage of caching for dependency acquisition
|
||||
COPY go.mod go.sum /usr/src/airshipui/
|
||||
RUN go mod download
|
||||
|
||||
COPY . /usr/src/airshipui/
|
||||
ARG MAKE_TARGET=build
|
||||
RUN make ${MAKE_TARGET}
|
||||
|
||||
FROM ${RELEASE_IMAGE} as release
|
||||
COPY --from=builder /usr/src/airshipui/bin/airshipui /usr/local/bin/airshipui
|
||||
USER 65534
|
||||
ENTRYPOINT [ "/usr/local/bin/airshipui" ]
|
47
Makefile
47
Makefile
|
@ -9,12 +9,25 @@ TOOLBINDIR := tools/bin
|
|||
LINTER := $(TOOLBINDIR)/golangci-lint
|
||||
LINTER_CONFIG := .golangci.yaml
|
||||
|
||||
# build target when calling make in a docker container
|
||||
DOCKER_MAKE_TARGET := build
|
||||
|
||||
# docker image options
|
||||
DOCKER_REGISTRY ?= quay.io
|
||||
DOCKER_IMAGE_NAME ?= airshipui
|
||||
DOCKER_IMAGE_PREFIX ?= airshipit
|
||||
DOCKER_IMAGE_TAG ?= dev
|
||||
DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
|
||||
DOCKER_TARGET_STAGE ?= release
|
||||
|
||||
TESTFLAGS ?=
|
||||
|
||||
# Override the value of the version variable in main.go
|
||||
LD_FLAGS= '-X main.version=$(GIT_VERSION)'
|
||||
GO_FLAGS= -ldflags=$(LD_FLAGS)
|
||||
PLUGINS:= $(shell ls cmd)
|
||||
LD_FLAGS := '-X main.version=$(GIT_VERSION)'
|
||||
GO_FLAGS := -ldflags=$(LD_FLAGS)
|
||||
|
||||
BUILD_DIR := bin
|
||||
PLUGINS := $(addprefix $(BUILD_DIR)/, $(shell ls cmd))
|
||||
|
||||
ifdef XDG_CONFIG_HOME
|
||||
OCTANT_PLUGINSTUB_DIR ?= ${XDG_CONFIG_HOME}/octant/plugins
|
||||
|
@ -28,11 +41,15 @@ endif
|
|||
DIRS = internal
|
||||
RECURSIVE_DIRS = $(addprefix ./, $(addsuffix /..., $(DIRS)))
|
||||
|
||||
.PHONY: build
|
||||
build: $(PLUGINS)
|
||||
$(PLUGINS):
|
||||
go build -o $@ $(GO_FLAGS) opendev.org/airship/airshipui/cmd/$(@F)
|
||||
|
||||
.PHONY: install-plugins
|
||||
install-plugins: $(PLUGINS)
|
||||
$(PLUGINS):
|
||||
mkdir -p $(OCTANT_PLUGINSTUB_DIR)
|
||||
go build -o $(OCTANT_PLUGINSTUB_DIR)/$@-plugin $(GO_FLAGS) opendev.org/airship/airshipui/cmd/$@
|
||||
cp $? $(OCTANT_PLUGINSTUB_DIR)
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
|
@ -47,9 +64,6 @@ cover: test
|
|||
clean:
|
||||
git clean -dx $(DIRS)
|
||||
|
||||
.PHONY: ci
|
||||
ci: test lint
|
||||
|
||||
# The golang-unit zuul job calls the env target, so create one
|
||||
.PHONY: env
|
||||
|
||||
|
@ -60,3 +74,20 @@ lint: $(LINTER)
|
|||
$(LINTER):
|
||||
mkdir -p $(TOOLBINDIR)
|
||||
./tools/install_linter
|
||||
|
||||
# Configuration for building and testing in a docker image, which is necessary for
|
||||
# go-related projects in zuul
|
||||
.PHONY: docker-image
|
||||
docker-image:
|
||||
@docker build . --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) --tag $(DOCKER_IMAGE) --target $(DOCKER_TARGET_STAGE)
|
||||
|
||||
.PHONY: docker-image-lint
|
||||
docker-image-lint: DOCKER_MAKE_TARGET = lint
|
||||
docker-image-lint: DOCKER_TARGET_STAGE = builder
|
||||
docker-image-lint: docker-image
|
||||
|
||||
.PHONY: docker-image-unit-tests
|
||||
docker-image-unit-tests: DOCKER_MAKE_TARGET = test
|
||||
docker-image-unit-tests: DOCKER_TARGET_STAGE = builder
|
||||
docker-image-unit-tests: docker-image
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# 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.
|
||||
|
||||
- hosts: all
|
||||
roles:
|
||||
- install-docker
|
|
@ -0,0 +1,27 @@
|
|||
# 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.
|
||||
|
||||
- hosts: primary
|
||||
tasks:
|
||||
- name: Run Linter
|
||||
block:
|
||||
- name: "make docker-image-lint"
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
target: docker-image-lint
|
||||
|
||||
- name: Run Unit Tests
|
||||
block:
|
||||
- name: "make docker-image-unit-tests"
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
target: docker-image-unit-tests
|
Loading…
Reference in New Issue