forked from NVIDIA/k8s-device-plugin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
101 lines (83 loc) · 2.22 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
stages:
- tests
- build
- release
.tests-setup: &tests-setup
image: golang:1.14.4
rules:
- when: always
variables:
GITHUB_ROOT: "github.com/NVIDIA"
PROJECT_GOPATH: "${GITHUB_ROOT}/k8s-device-plugin"
before_script:
- mkdir -p ${GOPATH}/src/${GITHUB_ROOT}
- ln -s ${CI_PROJECT_DIR} ${GOPATH}/src/${PROJECT_GOPATH}
.build-and-release-setup: &build-and-release-setup
image: docker:stable
services:
- docker:stable-dind
before_script:
- apk add make
# Run a series of sanity-check tests over the code
lint:
<<: *tests-setup
stage: tests
script:
- go get -u golang.org/x/lint/golint
- go mod vendor
- golint -set_exit_status ${PROJECT_GOPATH}
vet:
<<: *tests-setup
stage: tests
script:
- go vet ${PROJECT_GOPATH}
unit_test:
<<: *tests-setup
stage: tests
script:
- go test ${PROJECT_GOPATH}
fmt:
<<: *tests-setup
stage: tests
script:
- res=$(gofmt -l *.go)
- echo "$res"
- test -z "$res"
ineffassign:
<<: *tests-setup
stage: tests
script:
- go get -u github.com/gordonklaus/ineffassign
- go mod vendor
- ineffassign *.go
misspell:
<<: *tests-setup
stage: tests
script:
- go get -u github.com/client9/misspell/cmd/misspell
- go mod vendor
- misspell *.go
# Build pushes to the local gitlab registry
build:device-plugin:
<<: *build-and-release-setup
stage: build
rules:
- when: always
script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- make REGISTRY="${CI_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_SHA}" all
- make REGISTRY="${CI_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_SHA}" push
- make REGISTRY="${CI_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_SHA}" push-short
- make REGISTRY="${CI_REGISTRY_IMAGE}" VERSION="${CI_COMMIT_SHA}" push-latest
# Release pushes to dockerhub
release:device-plugin:
<<: *build-and-release-setup
stage: release
only:
- tags
script:
- docker login -u "${REGISTRY_USER}" -p "${REGISTRY_TOKEN}"
- make VERSION="${CI_COMMIT_TAG}" all
- make VERSION="${CI_COMMIT_TAG}" push
- make VERSION="${CI_COMMIT_TAG}" push-short
- make VERSION="${CI_COMMIT_TAG}" push-latest