-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.yml
102 lines (97 loc) · 2.86 KB
/
config.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
102
version: 2.1
orbs:
nightfall_code_scanner: nightfall/nightfall_code_scanner@2.2.0
jobs:
build:
docker:
- image: deliveroo/circleci:0.2.8
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: false
- run:
name: build docker
command: ci build
- run:
name: test docker
command: ci run --rm nightfall_code_scanner_build make test
- run:
name: Clean up reusable Docker
command: clean_up_reusable_docker
lint:
docker:
- image: deliveroo/circleci:0.2.8
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: false
- run:
name: build docker
command: ci build
- run:
name: lint code
command: |
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
CHECK_LEVEL="github-check"
else
CHECK_LEVEL="github-pr-check"
fi
ci run --no-deps \
-e CIRCLE_BRANCH=$CIRCLE_BRANCH \
-e CIRCLE_PROJECT_REPONAME=$CIRCLE_PROJECT_REPONAME \
-e CIRCLE_PROJECT_USERNAME=$CIRCLE_PROJECT_USERNAME \
-e CIRCLE_PR_NUMBER=$CIRCLE_PR_NUMBER \
-e CIRCLE_PULL_REQUEST=$CIRCLE_PULL_REQUEST \
-e CIRCLE_SHA1=$CIRCLE_SHA1 \
-e REVIEWDOG_TOKEN=$REVIEWDOG_TOKEN \
--rm nightfall_code_scanner_build \
sh -c '$(go env GOPATH)/bin/golangci-lint run \
| $(go env GOPATH)/bin/reviewdog -f=golangci-lint -name=golangci -reporter='"$CHECK_LEVEL"' -level=error'
- run:
name: Clean up reusable Docker
command: clean_up_reusable_docker
push-to-dockerhub:
docker:
- image: deliveroo/circleci:0.2.8
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: false
- run:
name: build
command: ci build
- run:
name: Push image to docker hub
command: |
docker tag nightfallai/$CONTAINER_NAME:latest nightfallai/$CONTAINER_NAME:$CIRCLE_TAG
push_image_to_docker_hub \
nightfallai/$CONTAINER_NAME:$CIRCLE_TAG \
nightfallai/$CONTAINER_NAME:latest
environment:
CONTAINER_NAME: nightfall_code_scanner
workflows:
version: 2
build_and_test:
jobs:
- build:
filters:
tags:
only: /.*/
context: build
- lint:
filters:
tags:
only: /.*/
context: build
- nightfall_code_scanner/scan:
event_before: << pipeline.git.base_revision >>
- push-to-dockerhub:
requires:
- build
- lint
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+/
context: docker-hub