Skip to content

Commit 809e536

Browse files
authored
Merge pull request #496 from snyk/chore/dont-upgrade-operator-if-no-new-release
chore: skip Operator upgrade tests if no new version can be published
2 parents d00785a + d0c5d57 commit 809e536

File tree

3 files changed

+64
-11
lines changed

3 files changed

+64
-11
lines changed

.circleci/config.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ jobs:
317317
echo "Currently released version is: ${OPERATOR_VERSION}"
318318
echo "export OPERATOR_VERSION=${OPERATOR_VERSION}" >> $BASH_ENV
319319
name: Get last released Operator version
320+
- run:
321+
command: |
322+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
323+
LATEST_TAG=${LATEST_TAG_WITH_V:1}
324+
echo "export LATEST_TAG=${LATEST_TAG}" >> $BASH_ENV
325+
description: |
326+
This tag is used to identify the Operator version we are going to upgrade to.
327+
name: Get latest snyk-monitor tag
328+
- run:
329+
command: |
330+
if [[ "${LATEST_TAG}" == "${OPERATOR_VERSION}" ]]; then
331+
echo "export NOTHING_TO_TEST=true" >> $BASH_ENV
332+
exit 1
333+
fi
334+
name: End tests early if no new Operator is to be released
320335
- run:
321336
command: |
322337
set -xeo pipefail
@@ -415,9 +430,6 @@ jobs:
415430
command: |
416431
set -eo pipefail
417432
418-
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
419-
LATEST_TAG=${LATEST_TAG_WITH_V:1}
420-
421433
REPLACES_VERSION=${OPERATOR_VERSION}
422434
423435
CSV_LOCATION="./snyk-operator/deploy/olm-catalog/snyk-operator"
@@ -489,7 +501,10 @@ jobs:
489501
name: Cleanup
490502
when: always
491503
- run:
492-
command: ./scripts/slack/notify_failure.py "nightly-operator-upgrade-tests"
504+
command: |
505+
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
506+
./scripts/slack/notify_failure.py "nightly-operator-upgrade-tests"
507+
fi
493508
name: Notify Slack on failure
494509
when: on_fail
495510
working_directory: ~/kubernetes-monitor
@@ -574,6 +589,13 @@ jobs:
574589
NEW_OPERATOR_VERSION=${LATEST_TAG}
575590
echo "export NEW_OPERATOR_VERSION=${NEW_OPERATOR_VERSION}" >> $BASH_ENV
576591
name: Get new Operator version
592+
- run:
593+
command: |
594+
if [[ "${NEW_OPERATOR_VERSION}" == "${LAST_OPERATOR_VERSION}" ]]; then
595+
echo "export NOTHING_TO_TEST=true" >> $BASH_ENV
596+
exit 1
597+
fi
598+
name: End tests early if no new Operator is to be released
577599
- run:
578600
command: |
579601
./scripts/operator/package-operator.sh "${NEW_OPERATOR_VERSION}" "${NEW_OPERATOR_VERSION}" "${NEW_OPERATOR_VERSION}" "${LAST_OPERATOR_VERSION}"
@@ -613,7 +635,10 @@ jobs:
613635
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}"
614636
name: Notify Slack on new branch in snyk/community-operators
615637
- run:
616-
command: ./scripts/slack/notify_failure.py "push-new-operator"
638+
command: |
639+
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
640+
./scripts/slack/notify_failure.py "push-new-operator"
641+
fi
617642
name: Notify Slack on failure
618643
when: on_fail
619644
working_directory: ~/kubernetes-monitor

.circleci/config/jobs/operator_upgrade_tests.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ steps:
1717
sudo apt install -y uuid-runtime
1818
python -m pip install requests pyyaml
1919
python -m pip install operator-courier
20-
20+
2121
- install_python_requests
2222

2323
- run:
@@ -45,6 +45,23 @@ steps:
4545
echo "Currently released version is: ${OPERATOR_VERSION}"
4646
echo "export OPERATOR_VERSION=${OPERATOR_VERSION}" >> $BASH_ENV
4747
48+
- run:
49+
name: Get latest snyk-monitor tag
50+
description: |
51+
This tag is used to identify the Operator version we are going to upgrade to.
52+
command: |
53+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
54+
LATEST_TAG=${LATEST_TAG_WITH_V:1}
55+
echo "export LATEST_TAG=${LATEST_TAG}" >> $BASH_ENV
56+
57+
- run:
58+
name: End tests early if no new Operator is to be released
59+
command: |
60+
if [[ "${LATEST_TAG}" == "${OPERATOR_VERSION}" ]]; then
61+
echo "export NOTHING_TO_TEST=true" >> $BASH_ENV
62+
exit 1
63+
fi
64+
4865
- run:
4966
name: Package and deploy last released Operator
5067
description: |
@@ -150,9 +167,6 @@ steps:
150167
command: |
151168
set -eo pipefail
152169
153-
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
154-
LATEST_TAG=${LATEST_TAG_WITH_V:1}
155-
156170
REPLACES_VERSION=${OPERATOR_VERSION}
157171
158172
CSV_LOCATION="./snyk-operator/deploy/olm-catalog/snyk-operator"
@@ -228,5 +242,8 @@ steps:
228242

229243
- run:
230244
name: Notify Slack on failure
231-
command: ./scripts/slack/notify_failure.py "nightly-operator-upgrade-tests"
245+
command: |
246+
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
247+
./scripts/slack/notify_failure.py "nightly-operator-upgrade-tests"
248+
fi
232249
when: on_fail

.circleci/config/jobs/push_operator_to_community_operators.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ steps:
3535
NEW_OPERATOR_VERSION=${LATEST_TAG}
3636
echo "export NEW_OPERATOR_VERSION=${NEW_OPERATOR_VERSION}" >> $BASH_ENV
3737
38+
- run:
39+
name: End tests early if no new Operator is to be released
40+
command: |
41+
if [[ "${NEW_OPERATOR_VERSION}" == "${LAST_OPERATOR_VERSION}" ]]; then
42+
echo "export NOTHING_TO_TEST=true" >> $BASH_ENV
43+
exit 1
44+
fi
45+
3846
- run:
3947
name: Package Operator
4048
command: |
@@ -78,5 +86,8 @@ steps:
7886
7987
- run:
8088
name: Notify Slack on failure
81-
command: ./scripts/slack/notify_failure.py "push-new-operator"
89+
command: |
90+
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
91+
./scripts/slack/notify_failure.py "push-new-operator"
92+
fi
8293
when: on_fail

0 commit comments

Comments
 (0)