-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
72 lines (66 loc) · 1.46 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
stages:
- lint
- build
- test
- release
# LINT ##
go_lint:
stage: lint
image: golang:1.14
only:
- merge_requests
artifacts:
untracked: true
before_script:
- cd $GOPATH/src
- mkdir -p gitlab.com/$CI_PROJECT_NAMESPACE
- cd gitlab.com/$CI_PROJECT_NAMESPACE
- ln -s $CI_PROJECT_DIR
- cd $CI_PROJECT_NAME
script:
- go mod download
- go get -u golang.org/x/lint/golint
- golint ./...
- go vet ./...
## BUILD ##
build_executable:
stage: build
only:
- merge_requests
artifacts:
untracked: true
dependencies:
- go_lint
image: golang:1.14
script:
- go build -o probr cmd/probr-cli/*.go
# TEST ##
unit_tests:
stage: test
image: citihub/build:latest
only:
- merge_requests
dependencies:
- go_lint
before_script:
- export TEST_KUBE_CONFIG=/tmp/test-config
- echo ${kube_config} | base64 -id > $TEST_KUBE_CONFIG
- export KUBE_CONFIG=$TEST_KUBE_CONFIG
- export LOGLEVEL=INFO
script:
- cd $CI_PROJECT_DIR/internal/test/unit
- go test -v ./...
test_run:
stage: test
image: node
dependencies:
- build_executable
only:
- merge_requests
before_script:
- export TEST_KUBE_CONFIG=/tmp/test-config
- echo ${kube_config} | base64 -id > $TEST_KUBE_CONFIG
- export KUBE_CONFIG=$TEST_KUBE_CONFIG
- export LOGLEVEL=INFO
script:
- ./probr -tags="@CIS-5.2.1,@CIS-6.1.3,@CIS-6.10" || if [ $? -lt 2 ]; then echo "success"; else exit 1; fi