Skip to content

Commit 4140c6e

Browse files
authored
Merge pull request #533 from snyk/chore/publish_operator_to_operatorhubio
chore: push snyk operator to operatorhub.io
2 parents ad39924 + 7357a9c commit 4140c6e

24 files changed

+585
-106
lines changed

.circleci/config.yml

Lines changed: 124 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,34 @@ jobs:
199199
- store_artifacts:
200200
path: /tmp/logs/test/integration/kind-helm
201201
working_directory: ~/kubernetes-monitor
202+
integration_tests_operator_on_k8s:
203+
machine:
204+
docker_layer_caching: true
205+
enabled: true
206+
steps:
207+
- checkout
208+
- setup_node12
209+
- install_python_requests
210+
- run:
211+
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
212+
name: Create temporary directory for logs
213+
- run:
214+
command: |
215+
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
216+
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
217+
name: Operator integration tests on plain k8s
218+
- run:
219+
command: |
220+
./scripts/operator/delete-operator-from-quay.sh
221+
name: Delete Operator from Quay
222+
- run:
223+
command: |
224+
./scripts/slack/notify_failure_on_branch.py "staging-integration-tests-operator-on-k8s-${CIRCLE_SHA1}"
225+
name: Notify Slack on failure
226+
when: on_fail
227+
- store_artifacts:
228+
path: /tmp/logs/test/integration/kind-olm-operator
229+
working_directory: ~/kubernetes-monitor
202230
integration_tests_proxy:
203231
machine:
204232
docker_layer_caching: true
@@ -214,7 +242,7 @@ jobs:
214242
command: |
215243
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
216244
npm run test:integration:kind:proxy
217-
name: Integration tests with Helm deployment
245+
name: Integration tests with proxy
218246
- run:
219247
command: |
220248
./scripts/slack/notify_failure_on_branch.py "staging-integration-proxy-tests-${CIRCLE_SHA1}"
@@ -570,7 +598,7 @@ jobs:
570598
- 06:c3:d4:10:0d:ef:37:6c:ec:b9:fb:6e:ed:09:e7:40
571599
- run:
572600
command: |
573-
python -m pip install requests pyyaml
601+
python -m pip install requests pyyaml PyGithub
574602
name: Install required packages
575603
- install_python_requests
576604
- run:
@@ -599,42 +627,85 @@ jobs:
599627
name: Package Operator
600628
- run:
601629
command: |
602-
set -xeo pipefail
603-
604630
CURRENT_DIRECTORY=$(pwd)
605-
COMMUNITY_OPERATORS_UPSTREAM_LOCATION="${CURRENT_DIRECTORY}/community-operators"
606-
DEPLOY_LOCATION="${COMMUNITY_OPERATORS_UPSTREAM_LOCATION}/community-operators"
607-
OPERATOR_LOCATION="${CURRENT_DIRECTORY}/snyk-operator/deploy/olm-catalog/snyk-operator"
608-
609-
# Configure git user and gpg key
610-
echo "${OPENSHIFT_OPERATOR_SIGNING_KEY_BASE64}" | base64 -d | gpg --import
611-
git config --global commit.gpgsign true
612-
git config --global user.signingkey "${OPENSHIFT_OPERATOR_SIGNING_KEY_ID}"
613-
git config --global user.email "${OPENSHIFT_OPERATOR_GITHUB_EMAIL}"
614-
git config --global user.name "${OPENSHIFT_OPERATOR_GITHUB_NAME}"
615-
616-
# Clone Community Operators repo from Snyk
617-
git clone https://github.com/snyk/community-operators.git $COMMUNITY_OPERATORS_UPSTREAM_LOCATION
618-
cd "${COMMUNITY_OPERATORS_UPSTREAM_LOCATION}"
619-
git checkout -b snyk/snyk-operator-v${NEW_OPERATOR_VERSION}
620-
621-
# Copy new release to branch
622-
cp -r "${OPERATOR_LOCATION}/${NEW_OPERATOR_VERSION}" "${DEPLOY_LOCATION}/snyk-operator/."
623-
cp "${OPERATOR_LOCATION}/snyk-operator.package.yaml" "${DEPLOY_LOCATION}/snyk-operator/."
624-
625-
# Create the signed commit and push
626-
git add "${DEPLOY_LOCATION}/snyk-operator/*"
627-
git commit -s -m "Upgrade snyk-operator to version ${NEW_OPERATOR_VERSION}"
628-
git push --set-upstream origin --force snyk/snyk-operator-v${NEW_OPERATOR_VERSION}
631+
COMMUNITY_FOLDER_LOCATION="community-operators"
632+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
629633
name: Push new Operator to the fork of the community-operators repository
630634
- run:
631635
command: |
632-
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}"
636+
COMMUNITY_FOLDER_LOCATION="community-operators"
637+
python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}"
638+
name: Open a Pull Request to the operator-framework/community-operators repository for community-operators
639+
- run:
640+
command: |
641+
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}"
633642
name: Notify Slack on new branch in snyk/community-operators
634643
- run:
635644
command: |
636645
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
637-
./scripts/slack/notify_failure.py "push-new-operator"
646+
./scripts/slack/notify_failure.py "push-new-operator on community-operators"
647+
fi
648+
name: Notify Slack on failure
649+
when: on_fail
650+
working_directory: ~/kubernetes-monitor
651+
push_operator_to_upstream_community_operators:
652+
description: |
653+
Packages a new Operator and pushes it to Snyk's fork of
654+
the OpenShift upstream-community-operators.
655+
executor: redhat-openshift/default
656+
steps:
657+
- checkout
658+
- add_ssh_keys:
659+
fingerprints:
660+
- 06:c3:d4:10:0d:ef:37:6c:ec:b9:fb:6e:ed:09:e7:40
661+
- run:
662+
command: |
663+
python -m pip install requests pyyaml PyGithub
664+
name: Install required packages
665+
- install_python_requests
666+
- run:
667+
command: |
668+
set -xeo pipefail
669+
LAST_OPERATOR_VERSION=$(python ./scripts/operator/get_last_published_operator_version.py)
670+
echo "export LAST_OPERATOR_VERSION=${LAST_OPERATOR_VERSION}" >> $BASH_ENV
671+
name: Get last released Operator version
672+
- run:
673+
command: |
674+
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
675+
LATEST_TAG=${LATEST_TAG_WITH_V:1}
676+
NEW_OPERATOR_VERSION=${LATEST_TAG}
677+
echo "export NEW_OPERATOR_VERSION=${NEW_OPERATOR_VERSION}" >> $BASH_ENV
678+
name: Get new Operator version
679+
- run:
680+
command: |
681+
if [[ "${NEW_OPERATOR_VERSION}" == "${LAST_OPERATOR_VERSION}" ]]; then
682+
echo "export NOTHING_TO_TEST=true" >> $BASH_ENV
683+
exit 1
684+
fi
685+
name: End tests early if no new Operator is to be released
686+
- run:
687+
command: |
688+
./scripts/operator/package-operator.sh "${NEW_OPERATOR_VERSION}" "${NEW_OPERATOR_VERSION}" "${NEW_OPERATOR_VERSION}" "${LAST_OPERATOR_VERSION}"
689+
name: Package Operator
690+
- run:
691+
command: |
692+
CURRENT_DIRECTORY=$(pwd)
693+
COMMUNITY_FOLDER_LOCATION="upstream-community-operators"
694+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
695+
name: Push new Operator to the fork of the upstream-community-operators repository
696+
- run:
697+
command: |
698+
COMMUNITY_FOLDER_LOCATION="upstream-community-operators"
699+
python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}"
700+
name: Open a Pull Request to the operator-framework/community-operators repository for upstream-community-operators
701+
- run:
702+
command: |
703+
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}"
704+
name: Notify Slack on new branch in snyk/upstream-community-operators
705+
- run:
706+
command: |
707+
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
708+
./scripts/slack/notify_failure.py "push-new-operator on upstream-community-operators"
638709
fi
639710
name: Notify Slack on failure
640711
when: on_fail
@@ -819,6 +890,15 @@ workflows:
819890
- staging
820891
requires:
821892
- build_image
893+
- integration_tests_operator_on_k8s:
894+
filters:
895+
branches:
896+
only:
897+
- staging
898+
requires:
899+
- build_image
900+
- build_operator
901+
- upload_operator
822902
- openshift4_integration_tests:
823903
filters:
824904
branches:
@@ -848,12 +928,25 @@ workflows:
848928
- staging
849929
requires:
850930
- tag_and_push
851-
NIGHTLY:
931+
MONTHLY:
852932
jobs:
853933
- operator_upgrade_tests
854934
- push_operator_to_community_operators:
855935
requires:
856936
- operator_upgrade_tests
937+
- push_operator_to_upstream_community_operators:
938+
requires:
939+
- operator_upgrade_tests
940+
triggers:
941+
- schedule:
942+
cron: 0 1 1 * *
943+
filters:
944+
branches:
945+
only:
946+
- master
947+
NIGHTLY:
948+
jobs:
949+
- operator_upgrade_tests
857950
triggers:
858951
- schedule:
859952
cron: 0 1 * * *

.circleci/config/@config.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ workflows:
7373
requires:
7474
- build_image
7575
<<: *staging_branch_only_filter
76+
- integration_tests_operator_on_k8s:
77+
requires:
78+
- build_image
79+
- build_operator
80+
- upload_operator
81+
<<: *staging_branch_only_filter
7682
- openshift4_integration_tests:
7783
requires:
7884
- build_image
@@ -113,6 +119,20 @@ workflows:
113119
- master
114120
jobs:
115121
- operator_upgrade_tests
122+
123+
MONTHLY:
124+
triggers:
125+
- schedule:
126+
cron: "0 1 1 * *"
127+
filters:
128+
branches:
129+
only:
130+
- master
131+
jobs:
132+
- operator_upgrade_tests
116133
- push_operator_to_community_operators:
117134
requires:
118135
- operator_upgrade_tests
136+
- push_operator_to_upstream_community_operators:
137+
requires:
138+
- operator_upgrade_tests

.circleci/config/jobs/@jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ integration_tests_proxy:
187187
name: Create temporary directory for logs
188188
command: mkdir -p /tmp/logs/test/integration/proxy
189189
- run:
190-
name: Integration tests with Helm deployment
190+
name: Integration tests with proxy
191191
command: |
192192
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
193193
npm run test:integration:kind:proxy
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
machine:
2+
docker_layer_caching: true
3+
enabled: true
4+
steps:
5+
- checkout
6+
- setup_node12
7+
- install_python_requests
8+
- run:
9+
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
10+
name: Create temporary directory for logs
11+
- run:
12+
command: |
13+
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
14+
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
15+
name: Operator integration tests on plain k8s
16+
- run:
17+
name: Delete Operator from Quay
18+
command: |
19+
./scripts/operator/delete-operator-from-quay.sh
20+
- run:
21+
command: |
22+
./scripts/slack/notify_failure_on_branch.py "staging-integration-tests-operator-on-k8s-${CIRCLE_SHA1}"
23+
name: Notify Slack on failure
24+
when: on_fail
25+
- store_artifacts:
26+
path: /tmp/logs/test/integration/kind-olm-operator
27+
working_directory: ~/kubernetes-monitor

.circleci/config/jobs/push_operator_to_community_operators.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ steps:
1616
- run:
1717
name: Install required packages
1818
command: |
19-
python -m pip install requests pyyaml
19+
python -m pip install requests pyyaml PyGithub
2020
2121
- install_python_requests
2222

@@ -51,43 +51,24 @@ steps:
5151
- run:
5252
name: Push new Operator to the fork of the community-operators repository
5353
command: |
54-
set -xeo pipefail
55-
5654
CURRENT_DIRECTORY=$(pwd)
57-
COMMUNITY_OPERATORS_UPSTREAM_LOCATION="${CURRENT_DIRECTORY}/community-operators"
58-
DEPLOY_LOCATION="${COMMUNITY_OPERATORS_UPSTREAM_LOCATION}/community-operators"
59-
OPERATOR_LOCATION="${CURRENT_DIRECTORY}/snyk-operator/deploy/olm-catalog/snyk-operator"
60-
61-
# Configure git user and gpg key
62-
echo "${OPENSHIFT_OPERATOR_SIGNING_KEY_BASE64}" | base64 -d | gpg --import
63-
git config --global commit.gpgsign true
64-
git config --global user.signingkey "${OPENSHIFT_OPERATOR_SIGNING_KEY_ID}"
65-
git config --global user.email "${OPENSHIFT_OPERATOR_GITHUB_EMAIL}"
66-
git config --global user.name "${OPENSHIFT_OPERATOR_GITHUB_NAME}"
67-
68-
# Clone Community Operators repo from Snyk
69-
git clone https://github.com/snyk/community-operators.git $COMMUNITY_OPERATORS_UPSTREAM_LOCATION
70-
cd "${COMMUNITY_OPERATORS_UPSTREAM_LOCATION}"
71-
git checkout -b snyk/snyk-operator-v${NEW_OPERATOR_VERSION}
72-
73-
# Copy new release to branch
74-
cp -r "${OPERATOR_LOCATION}/${NEW_OPERATOR_VERSION}" "${DEPLOY_LOCATION}/snyk-operator/."
75-
cp "${OPERATOR_LOCATION}/snyk-operator.package.yaml" "${DEPLOY_LOCATION}/snyk-operator/."
76-
77-
# Create the signed commit and push
78-
git add "${DEPLOY_LOCATION}/snyk-operator/*"
79-
git commit -s -m "Upgrade snyk-operator to version ${NEW_OPERATOR_VERSION}"
80-
git push --set-upstream origin --force snyk/snyk-operator-v${NEW_OPERATOR_VERSION}
81-
55+
COMMUNITY_FOLDER_LOCATION="community-operators"
56+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
57+
- run:
58+
name: Open a Pull Request to the operator-framework/community-operators repository for community-operators
59+
command: |
60+
COMMUNITY_FOLDER_LOCATION="community-operators"
61+
PR_URL=$(python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}")
62+
export SLACK_PR_URL=${PR_URL}
8263
- run:
8364
name: Notify Slack on new branch in snyk/community-operators
8465
command: |
85-
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}"
66+
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}" "${SLACK_PR_URL}"
8667
8768
- run:
8869
name: Notify Slack on failure
8970
command: |
9071
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
91-
./scripts/slack/notify_failure.py "push-new-operator"
72+
./scripts/slack/notify_failure.py "push-new-operator on community-operators"
9273
fi
9374
when: on_fail

0 commit comments

Comments
 (0)