From 8952afe29e40dd77c1b68b2a76601cea3f5c8aa7 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 16 Sep 2021 15:05:38 +0200 Subject: [PATCH 1/8] fix(operatorhub): uses ansible test scripts from new repo --- scripts/release/operatorhub.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/release/operatorhub.sh b/scripts/release/operatorhub.sh index ac07c93c4..52d4eb6b7 100755 --- a/scripts/release/operatorhub.sh +++ b/scripts/release/operatorhub.sh @@ -64,7 +64,7 @@ FORK="${FORK:-maistra}" FORK_REPO_URL="${FORK_REPO_URL:-https://${GIT_USER}:${GITHUB_TOKEN}@github.com/${FORK}/community-operators.git}" OPERATOR_NAME=istio-workspace-operator -OPERATOR_VERSION=${OPERATOR_VERSION:-0.0.5} +OPERATOR_VERSION=${OPERATOR_VERSION:-0.3.0} OPERATOR_HUB=${OPERATOR_HUB:-community-operators} BRANCH=${BRANCH:-"${OPERATOR_HUB}/${OPERATOR_NAME}-${OPERATOR_VERSION}"} @@ -94,8 +94,8 @@ if [[ $runTests -ne 0 ]]; then echo "Running tests: $tests" cd "${TMP_DIR}" - - bash <(curl -sL https://cutt.ly/WhkV76k) \ + export OP_TEST_ANSIBLE_PULL_REPO="https://github.com/redhat-openshift-ecosystem/operator-test-playbooks" ## can be removed after https://github.com/redhat-openshift-ecosystem/operator-test-playbooks/pull/244 is merged + bash <(curl -sL https://cutt.ly/AEeucaw) \ "$tests" \ "${OPERATOR_HUB}/${OPERATOR_NAME}/${OPERATOR_VERSION}" fi From eb25892248919cde0a2b8e38f0dd04a47c3003f9 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 16 Sep 2021 15:06:38 +0200 Subject: [PATCH 2/8] feat(make): introduces bundle-test target to invoke ansible tests --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 6794a0e70..f6abd7e8d 100644 --- a/Makefile +++ b/Makefile @@ -421,6 +421,10 @@ bundle-run-all: ## Run the bundle image in AllNamespace(OPERATOR_NAMESPACE) ins bundle-clean: ## Clean the bundle image operator-sdk cleanup istio-workspace-operator -n $(OPERATOR_NAMESPACE) +.PHONY: bundle-test +bundle-test: bundle ## Open up a PR to the Operator Hub community catalog + ./scripts/release/operatorhub.sh --dry-run --test + .PHONY: bundle-publish bundle-publish: ## Open up a PR to the Operator Hub community catalog ./scripts/release/operatorhub.sh From bed4e16caa316555d09abbe9292c4044539a7873 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 16 Sep 2021 15:26:56 +0200 Subject: [PATCH 3/8] feat(gh-action): tests operator bundle on each PR --- .github/workflows/operator_bundle_tests.yml | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/operator_bundle_tests.yml diff --git a/.github/workflows/operator_bundle_tests.yml b/.github/workflows/operator_bundle_tests.yml new file mode 100644 index 000000000..415fe363b --- /dev/null +++ b/.github/workflows/operator_bundle_tests.yml @@ -0,0 +1,29 @@ +name: Tests Operator Bundle + +on: pull_request + +jobs: + operatorhub-test: + runs-on: ubuntu-latest + steps: + - name: Set up Go env + uses: actions/setup-go@v2 + with: + go-version: 1.17.1 + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: go/src/github.com/${{ env.REPOSITORY }} + - name: Set $GOPATH + run: | + echo "GOPATH=${{ github.workspace }}/go" >> $GITHUB_ENV + echo "${{ github.workspace }}/go/bin" >> $GITHUB_PATH + shell: bash + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Tests bundle + run: | + cd go/src/github.com/${{ env.REPOSITORY }} + make lint-prepare bundle-test + shell: bash From 1673cdef8971914ad3867ea9952822dfb495dfe2 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 16 Sep 2021 16:05:19 +0200 Subject: [PATCH 4/8] fix: clones repo and sets git credentials --- .github/workflows/operator_bundle_tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/operator_bundle_tests.yml b/.github/workflows/operator_bundle_tests.yml index 415fe363b..fbf008911 100644 --- a/.github/workflows/operator_bundle_tests.yml +++ b/.github/workflows/operator_bundle_tests.yml @@ -12,7 +12,7 @@ jobs: go-version: 1.17.1 - uses: actions/checkout@v2 with: - fetch-depth: 1 + fetch-depth: 0 path: go/src/github.com/${{ env.REPOSITORY }} - name: Set $GOPATH run: | @@ -24,6 +24,7 @@ jobs: python-version: 3.7 - name: Tests bundle run: | + git config --global user.name "GitHub Actions" && git config --global user.email "actions@users.noreply.github.com" cd go/src/github.com/${{ env.REPOSITORY }} make lint-prepare bundle-test shell: bash From 421fee07f6c7e095596d3ff58bae6b1b0ef610e0 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 16 Sep 2021 16:29:53 +0200 Subject: [PATCH 5/8] fix(operatorhub): skips commit in dry run --- scripts/release/operatorhub.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release/operatorhub.sh b/scripts/release/operatorhub.sh index 52d4eb6b7..1cd343023 100755 --- a/scripts/release/operatorhub.sh +++ b/scripts/release/operatorhub.sh @@ -87,8 +87,8 @@ git checkout -b "${BRANCH}" mkdir -p "${OPERATOR_HUB}/${OPERATOR_NAME}/${OPERATOR_VERSION}"/ cp -a "${CUR_DIR}"/../../bundle/. "${OPERATOR_HUB}/${OPERATOR_NAME}/${OPERATOR_VERSION}"/ -git add . -git commit -s -S -m"${TITLE}" +skipInDryRun git add . +skipInDryRun git commit -s -S -m"${TITLE}" if [[ $runTests -ne 0 ]]; then echo "Running tests: $tests" From 14e32bb1c4470520bbd351bbe165e6ec01242815 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 16 Sep 2021 16:39:32 +0200 Subject: [PATCH 6/8] fix(tests): enables docker stdin redirect --- .github/workflows/operator_bundle_tests.yml | 2 ++ scripts/release/operatorhub.sh | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/operator_bundle_tests.yml b/.github/workflows/operator_bundle_tests.yml index fbf008911..346898b79 100644 --- a/.github/workflows/operator_bundle_tests.yml +++ b/.github/workflows/operator_bundle_tests.yml @@ -5,6 +5,8 @@ on: pull_request jobs: operatorhub-test: runs-on: ubuntu-latest + env: + OP_TEST_CONTAINER_OPT: "-i" steps: - name: Set up Go env uses: actions/setup-go@v2 diff --git a/scripts/release/operatorhub.sh b/scripts/release/operatorhub.sh index 1cd343023..269eb89ec 100755 --- a/scripts/release/operatorhub.sh +++ b/scripts/release/operatorhub.sh @@ -98,6 +98,7 @@ if [[ $runTests -ne 0 ]]; then bash <(curl -sL https://cutt.ly/AEeucaw) \ "$tests" \ "${OPERATOR_HUB}/${OPERATOR_NAME}/${OPERATOR_VERSION}" + echo $? fi if [[ ! $dryRun && -z $GITHUB_TOKEN ]]; then From b08c74a94b7dc323ea000dffb3affb688959ea96 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Fri, 17 Sep 2021 12:04:52 +0200 Subject: [PATCH 7/8] feat(gh-action): prints logs on failure --- .github/workflows/operator_bundle_tests.yml | 7 +++++++ scripts/release/operatorhub.sh | 14 +++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/operator_bundle_tests.yml b/.github/workflows/operator_bundle_tests.yml index 346898b79..75871d9e7 100644 --- a/.github/workflows/operator_bundle_tests.yml +++ b/.github/workflows/operator_bundle_tests.yml @@ -30,3 +30,10 @@ jobs: cd go/src/github.com/${{ env.REPOSITORY }} make lint-prepare bundle-test shell: bash + - name: Print test logs on failure + if: ${{ failure() }} + run: | + cat /tmp/test.out + echo -e "\n--------------------------------------------------------------------------\n" + cat /tmp/op-test/log.out + shell: bash diff --git a/scripts/release/operatorhub.sh b/scripts/release/operatorhub.sh index 269eb89ec..deb91b7c5 100755 --- a/scripts/release/operatorhub.sh +++ b/scripts/release/operatorhub.sh @@ -94,11 +94,19 @@ if [[ $runTests -ne 0 ]]; then echo "Running tests: $tests" cd "${TMP_DIR}" - export OP_TEST_ANSIBLE_PULL_REPO="https://github.com/redhat-openshift-ecosystem/operator-test-playbooks" ## can be removed after https://github.com/redhat-openshift-ecosystem/operator-test-playbooks/pull/244 is merged + + ## can be removed after https://github.com/redhat-openshift-ecosystem/operator-test-playbooks/pull/244 is merged + export OP_TEST_ANSIBLE_PULL_REPO="https://github.com/redhat-openshift-ecosystem/operator-test-playbooks" + bash <(curl -sL https://cutt.ly/AEeucaw) \ "$tests" \ - "${OPERATOR_HUB}/${OPERATOR_NAME}/${OPERATOR_VERSION}" - echo $? + "${OPERATOR_HUB}/${OPERATOR_NAME}/${OPERATOR_VERSION}" > /tmp/test.out + + ## Until the script is fixed https://github.com/redhat-openshift-ecosystem/operator-test-playbooks/pull/247 + if tail -n 4 /tmp/test.out | grep "Failed with rc"; + then + exit 1; + fi # "Failed" was found in the logs fi if [[ ! $dryRun && -z $GITHUB_TOKEN ]]; then From 1d85272e44c31e3361b55d02ce822107019e681c Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Mon, 20 Sep 2021 10:10:52 +0200 Subject: [PATCH 8/8] fix: copy-paste description :) Co-authored-by: Aslak Knutsen --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f6abd7e8d..f0b213676 100644 --- a/Makefile +++ b/Makefile @@ -422,7 +422,7 @@ bundle-clean: ## Clean the bundle image operator-sdk cleanup istio-workspace-operator -n $(OPERATOR_NAMESPACE) .PHONY: bundle-test -bundle-test: bundle ## Open up a PR to the Operator Hub community catalog +bundle-test: bundle ## Run the Operator Hub test suite ./scripts/release/operatorhub.sh --dry-run --test .PHONY: bundle-publish