mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-03-22 22:06:56 +00:00
Run CI checks in development image
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
a7f3398a68
commit
22ee5eb64f
91
.common-ci.yml
Normal file
91
.common-ci.yml
Normal file
@ -0,0 +1,91 @@
|
||||
# Copyright (c) 2021, NVIDIA CORPORATION. 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.
|
||||
default:
|
||||
image: docker:stable
|
||||
services:
|
||||
- name: docker:stable-dind
|
||||
command: ["--experimental"]
|
||||
|
||||
variables:
|
||||
IMAGE: "${CI_REGISTRY_IMAGE}"
|
||||
IMAGE_TAG: "${CI_COMMIT_REF_SLUG}"
|
||||
|
||||
build-dev-image:
|
||||
stage: image
|
||||
before_script:
|
||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
||||
script:
|
||||
- apk --no-cache add make bash
|
||||
- make .build-image
|
||||
- make .push-build-image
|
||||
|
||||
.requires-build-image:
|
||||
variables:
|
||||
SKIP_IMAGE_BUILD: "yes"
|
||||
before_script:
|
||||
- apk --no-cache add make bash
|
||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
||||
- make .pull-build-image
|
||||
|
||||
.go-check:
|
||||
extends:
|
||||
- .requires-build-image
|
||||
stage: go-checks
|
||||
|
||||
fmt:
|
||||
extends:
|
||||
- .go-check
|
||||
script:
|
||||
- make docker-assert-fmt
|
||||
|
||||
vet:
|
||||
extends:
|
||||
- .go-check
|
||||
script:
|
||||
- make docker-vet
|
||||
|
||||
lint:
|
||||
extends:
|
||||
- .go-check
|
||||
script:
|
||||
- make docker-lint
|
||||
allow_failure: true
|
||||
|
||||
ineffassign:
|
||||
extends:
|
||||
- .go-check
|
||||
script:
|
||||
- make docker-ineffassign
|
||||
allow_failure: true
|
||||
|
||||
misspell:
|
||||
extends:
|
||||
- .go-check
|
||||
script:
|
||||
- make docker-misspell
|
||||
|
||||
go-build:
|
||||
extends:
|
||||
- .requires-build-image
|
||||
stage: go-build
|
||||
script:
|
||||
- make docker-build
|
||||
|
||||
unit-tests:
|
||||
extends:
|
||||
- .requires-build-image
|
||||
stage: unit-tests
|
||||
script:
|
||||
- make docker-coverage
|
||||
|
@ -12,86 +12,27 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Build packages for all supported OS / ARCH combinations
|
||||
include:
|
||||
- .common-ci.yml
|
||||
|
||||
stages:
|
||||
- tests
|
||||
- image
|
||||
- go-checks
|
||||
- go-build
|
||||
- unit-tests
|
||||
- test
|
||||
- scan
|
||||
- release
|
||||
- build-one
|
||||
- build-all
|
||||
|
||||
.tests-setup: &tests-setup
|
||||
image: golang:1.14.4
|
||||
|
||||
rules:
|
||||
- when: always
|
||||
|
||||
variables:
|
||||
GITHUB_ROOT: "github.com/NVIDIA"
|
||||
PROJECT_GOPATH: "${GITHUB_ROOT}/nvidia-container-toolkit"
|
||||
|
||||
before_script:
|
||||
- mkdir -p ${GOPATH}/src/${GITHUB_ROOT}
|
||||
- ln -s ${CI_PROJECT_DIR} ${GOPATH}/src/${PROJECT_GOPATH}
|
||||
|
||||
.build-setup: &build-setup
|
||||
image: docker:19.03.8
|
||||
|
||||
services:
|
||||
- name: docker:19.03.8-dind
|
||||
command: ["--experimental"]
|
||||
|
||||
before_script:
|
||||
- apk update
|
||||
- apk upgrade
|
||||
- apk add coreutils build-base sed git bash make
|
||||
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes
|
||||
|
||||
# Run a series of sanity-check tests over the code
|
||||
lint:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- GO111MODULE=off go get -u golang.org/x/lint/golint
|
||||
- make lint
|
||||
|
||||
vet:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- make vet
|
||||
|
||||
unit_test:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- make test
|
||||
|
||||
coverage:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- make coverage
|
||||
|
||||
fmt:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- make assert-fmt
|
||||
|
||||
ineffassign:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- GO111MODULE=off go get -u github.com/gordonklaus/ineffassign
|
||||
- make ineffassign
|
||||
|
||||
misspell:
|
||||
<<: *tests-setup
|
||||
stage: tests
|
||||
script:
|
||||
- GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
|
||||
- make misspell
|
||||
|
||||
# build-one jobs build packages for a single OS / ARCH combination.
|
||||
#
|
||||
# They are run during the first stage of the pipeline as a smoke test to ensure
|
||||
|
3
Makefile
3
Makefile
@ -37,7 +37,8 @@ BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel
|
||||
EXAMPLES := $(patsubst ./examples/%/,%,$(sort $(dir $(wildcard ./examples/*/))))
|
||||
EXAMPLE_TARGETS := $(patsubst %,example-%, $(EXAMPLES))
|
||||
|
||||
MAKE_TARGETS := binary build all check fmt assert-fmt lint lint-internal vet test examples coverage generate
|
||||
CHECK_TARGETS := assert-fmt vet lint ineffassign misspell
|
||||
MAKE_TARGETS := binary build all check fmt lint-internal test examples coverage generate $(CHECK_TARGETS)
|
||||
|
||||
TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS)
|
||||
|
||||
|
@ -16,3 +16,5 @@ FROM golang:${GOLANG_VERSION}
|
||||
|
||||
RUN go get -u golang.org/x/lint/golint
|
||||
RUN go get -u github.com/matryer/moq
|
||||
RUN go get -u github.com/gordonklaus/ineffassign
|
||||
RUN go get -u github.com/client9/misspell/cmd/misspell
|
Loading…
Reference in New Issue
Block a user