Skip to content

Commit afa8cf0

Browse files
author
Amir Moualem
authored
Merge pull request #128 from snyk/chore/circle_ci
Chore/circle ci
2 parents 93f1bb9 + d843f47 commit afa8cf0

File tree

9 files changed

+155
-83
lines changed

9 files changed

+155
-83
lines changed

.circleci/config.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
version: 2
2+
jobs:
3+
4+
######################## PR TO STAGING ########################
5+
test_discardable:
6+
machine:
7+
enabled: true
8+
docker_layer_caching: true
9+
working_directory: ~/kubernetes-monitor
10+
steps:
11+
- checkout
12+
- run:
13+
name: TEST DISCARDABLE
14+
command: |
15+
export NVM_DIR="/opt/circleci/.nvm" &&
16+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
17+
nvm install v10 &&
18+
npm install &&
19+
npm test
20+
21+
######################## MERGE TO STAGING ########################
22+
test_and_build:
23+
machine:
24+
enabled: true
25+
docker_layer_caching: true
26+
working_directory: ~/kubernetes-monitor
27+
steps:
28+
- checkout
29+
- run:
30+
name: TEST AND BUILD
31+
command: |
32+
export NVM_DIR="/opt/circleci/.nvm" &&
33+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
34+
nvm install v10 &&
35+
npm install &&
36+
npm run lint &&
37+
npm run build &&
38+
npm run test:unit &&
39+
docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD} &&
40+
IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:staging-candidate-${CIRCLE_SHA1} &&
41+
./scripts/build-image.sh ${IMAGE_NAME_CANDIDATE} &&
42+
docker push ${IMAGE_NAME_CANDIDATE} &&
43+
./scripts/slack-notify-push.sh ${IMAGE_NAME_CANDIDATE} &&
44+
KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=${IMAGE_NAME_CANDIDATE} npm run test:integration ||
45+
( ./scripts/slack-notify-failure.sh "staging-test" && false )
46+
tag_and_push:
47+
working_directory: ~/kubernetes-monitor
48+
docker:
49+
- image: circleci/node:10
50+
steps:
51+
- checkout
52+
- setup_remote_docker
53+
- run:
54+
name: TAG AND PUSH
55+
command: |
56+
npm install &&
57+
docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD} &&
58+
npx semantic-release &&
59+
NEW_VERSION=`cat ./package.json | jq -r '.version'` &&
60+
./scripts/approve-image.sh $NEW_VERSION ||
61+
( ./scripts/slack-notify-failure.sh "staging-release" && false )
62+
63+
######################## PR TO MASTER ########################
64+
prepublish:
65+
working_directory: ~/kubernetes-monitor
66+
docker:
67+
- image: circleci/node:10
68+
steps:
69+
- checkout
70+
- run:
71+
name: PREPUBLISH
72+
command: |
73+
./scripts/slack-notify-pr.sh
74+
75+
######################## MERGE TO MASTER ########################
76+
publish:
77+
working_directory: ~/kubernetes-monitor
78+
docker:
79+
- image: circleci/node:10
80+
steps:
81+
- checkout
82+
- setup_remote_docker
83+
- run:
84+
name: PUBLISH
85+
command: |
86+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}` &&
87+
LATEST_TAG=${LATEST_TAG_WITH_V:1} &&
88+
IMAGE_NAME_APPROVED=snyk/kubernetes-monitor:${LATEST_TAG}-approved &&
89+
IMAGE_NAME_PUBLISHED=snyk/kubernetes-monitor:${LATEST_TAG} &&
90+
docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD} &&
91+
docker pull ${IMAGE_NAME_APPROVED} &&
92+
docker tag ${IMAGE_NAME_APPROVED} ${IMAGE_NAME_PUBLISHED} &&
93+
docker push ${IMAGE_NAME_PUBLISHED} &&
94+
./scripts/slack-notify-push.sh ${IMAGE_NAME_PUBLISHED} &&
95+
docker tag ${IMAGE_NAME_APPROVED} snyk/kubernetes-monitor:latest &&
96+
docker push snyk/kubernetes-monitor:latest &&
97+
./scripts/slack-notify-push.sh snyk/kubernetes-monitor:latest &&
98+
./scripts/publish-gh-pages.sh ${LATEST_TAG} ||
99+
( ./scripts/slack-notify-failure.sh master && false )
100+
101+
#######################################################################
102+
103+
workflows:
104+
version: 2
105+
PR_TO_STAGING:
106+
jobs:
107+
- test_discardable:
108+
filters:
109+
branches:
110+
ignore:
111+
- staging
112+
- master
113+
MERGE_TO_STAGING:
114+
jobs:
115+
- test_and_build:
116+
filters:
117+
branches:
118+
only:
119+
- staging
120+
- tag_and_push:
121+
requires:
122+
- test_and_build
123+
filters:
124+
branches:
125+
only:
126+
- staging
127+
128+
# reserved for the "pre publish "
129+
# PR_TO_MASTER:
130+
# jobs:
131+
# - prepublish:
132+
# filters:
133+
# branches:
134+
# only:
135+
# - master
136+
137+
MERGE_TO_MASTER:
138+
jobs:
139+
- publish:
140+
filters:
141+
branches:
142+
only:
143+
- master
144+
145+
general:
146+
branches:
147+
ignore:
148+
- gh-pages

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node_modules/
1010
coverage/
1111
.nyc_output/
1212
.idea/
13+
.circleci/
1314
npm-debug.log
1415
newrelic_agent.log
1516

.travis.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

scripts/approve-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ $1 == "null" ]; then
88
echo Semantic-Release did not create a new version, not pushing a new approved image
99
./scripts/slack-notify-success-no-release.sh
1010
else
11-
IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:staging-candidate
11+
IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:staging-candidate-${CIRCLE_SHA1}
1212
IMAGE_NAME_APPROVED=snyk/kubernetes-monitor:${1}-approved
1313

1414
docker pull ${IMAGE_NAME_CANDIDATE}

scripts/slack-notify-failure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": ":warning: Kubernetes-Monitor Merge Failure :warning:", "text": ":egg_broken_1: Kubernetes-Monitor broken branch: `'$1'` :egg_broken_1:"}]}' $SLACK_WEBHOOK
2+
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: '$CIRCLE_BUILD_URL'", "title": ":warning: Kubernetes-Monitor Merge Failure :warning:", "text": ":egg_broken_1: Kubernetes-Monitor broken branch: `'$1'` :egg_broken_1:"}]}' $SLACK_WEBHOOK

scripts/slack-notify-pr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg: A new version is about to be published! :egg:\nhttps://github.com/'$TRAVIS_PULL_REQUEST_SLUG'/pull/'$TRAVIS_PULL_REQUEST'\nbranch of origin is `'$TRAVIS_PULL_REQUEST_BRANCH'`"}]}' $SLACK_WEBHOOK
2+
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: '$CIRCLE_BUILD_URL'", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg: A new version is about to be published! :egg:\n'$CIRCLE_PULL_REQUEST'\nbranch of origin is `TODO`"}]}' $SLACK_WEBHOOK

scripts/slack-notify-push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Published Kubernetes-Monitor: `'$1'` :egg_fancy:"}]}' $SLACK_WEBHOOK
2+
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: '$CIRCLE_BUILD_URL'", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Published Kubernetes-Monitor: `'$1'` :egg_fancy:"}]}' $SLACK_WEBHOOK
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Successful `master` merge, but no `gh-pages` release occurring :egg_fancy:"}]}' $SLACK_WEBHOOK
2+
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: '$CIRCLE_BUILD_URL'", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Successful `master` merge, but no `gh-pages` release occurring :egg_fancy:"}]}' $SLACK_WEBHOOK
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Successful `staging` merge, but no semantic-release occurring :egg_fancy:"}]}' $SLACK_WEBHOOK
2+
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: '$CIRCLE_BUILD_URL'", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Successful `staging` merge, but no semantic-release occurring :egg_fancy:"}]}' $SLACK_WEBHOOK

0 commit comments

Comments
 (0)