File tree Expand file tree Collapse file tree 2 files changed +85
-1
lines changed Expand file tree Collapse file tree 2 files changed +85
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ jobs:
188188 export IMAGE_TAG=$([[ "$CIRCLE_BRANCH" == "staging" ]] && echo "staging-candidate" || echo "discardable") &&
189189 export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=snyk/kubernetes-monitor:${IMAGE_TAG}-${CIRCLE_SHA1} &&
190190 docker pull ${KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG} &&
191- npm run test:integration:eks
191+ .circleci/do-exclusively --branch staging npm run test:integration:eks
192192 - run :
193193 name : Notify Slack on failure
194194 command : |
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # copied from https://github.com/bellkev/circle-lock-test
4+
5+ # sets $branch, $tag, $rest
6+ parse_args () {
7+ while [[ $# -gt 0 ]]; do
8+ case $1 in
9+ -b|--branch) branch=" $2 " ;;
10+ -t|--tag) tag=" $2 " ;;
11+ * ) break ;;
12+ esac
13+ shift 2
14+ done
15+ rest=(" $@ " )
16+ }
17+
18+ # reads $branch, $tag, $commit_message
19+ should_skip () {
20+ if [[ " $branch " && " $CIRCLE_BRANCH " != " $branch " ]]; then
21+ echo " Not on branch $branch . Skipping..."
22+ return 0
23+ fi
24+
25+ if [[ " $tag " && " $commit_message " != * \[ $tag \] * ]]; then
26+ echo " No [$tag ] commit tag found. Skipping..."
27+ return 0
28+ fi
29+
30+ return 1
31+ }
32+
33+ # reads $branch, $tag
34+ # sets $jq_prog
35+ make_jq_prog () {
36+ local jq_filters=" "
37+
38+ if [[ $branch ]]; then
39+ jq_filters+=" and .branch == \" $branch \" "
40+ fi
41+
42+ if [[ $tag ]]; then
43+ jq_filters+=" and (.subject | contains(\" [$tag ]\" ))"
44+ fi
45+
46+ jq_prog=" .[] | select(.build_num < $CIRCLE_BUILD_NUM and (.status | test(\" running|pending|queued\" )) $jq_filters ) | .build_num"
47+ }
48+
49+
50+ if [[ " $0 " != * bats* ]]; then
51+ set -e
52+ set -u
53+ set -o pipefail
54+
55+ branch=" "
56+ tag=" "
57+ rest=()
58+ api_url=" https://circleci.com/api/v1/project/$CIRCLE_PROJECT_USERNAME /$CIRCLE_PROJECT_REPONAME ?circle-token=$CIRCLE_TOKEN &limit=100"
59+
60+ parse_args " $@ "
61+ commit_message=$( git log -1 --pretty=%B)
62+ if should_skip; then exit 0; fi
63+ make_jq_prog
64+
65+ echo " Checking for running builds..."
66+
67+ while true ; do
68+ builds=$( curl -s -H " Accept: application/json" " $api_url " | jq " $jq_prog " )
69+ if [[ $builds ]]; then
70+ echo " Waiting on builds:"
71+ echo " $builds "
72+ else
73+ break
74+ fi
75+ echo " Retrying in 5 seconds..."
76+ sleep 5
77+ done
78+
79+ echo " Acquired lock"
80+
81+ if [[ " ${# rest[@]} " -ne 0 ]]; then
82+ " ${rest[@]} "
83+ fi
84+ fi
You can’t perform that action at this time.
0 commit comments