diff --git a/.github/workflows/operator_bundle_tests.yml b/.github/workflows/operator_bundle_tests.yml new file mode 100644 index 000000000..75871d9e7 --- /dev/null +++ b/.github/workflows/operator_bundle_tests.yml @@ -0,0 +1,39 @@ +name: Tests Operator Bundle + +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 + with: + go-version: 1.17.1 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + 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: | + 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 + - 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/Makefile b/Makefile index 6794a0e70..f0b213676 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 ## Run the Operator Hub test suite + ./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 diff --git a/scripts/release/operatorhub.sh b/scripts/release/operatorhub.sh index ac07c93c4..deb91b7c5 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}"} @@ -87,17 +87,26 @@ 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" cd "${TMP_DIR}" - bash <(curl -sL https://cutt.ly/WhkV76k) \ + ## 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}" + "${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