Allow tests to run in IntelliJ & GoLand (#460)

Users will just need to run "make idea" first.
diff --git a/.run/Template Ginkgo.run.xml b/.run/Template Ginkgo.run.xml
new file mode 100644
index 0000000..39a5cc0
--- /dev/null
+++ b/.run/Template Ginkgo.run.xml
@@ -0,0 +1,13 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="true" type="GinkgoRunConfigurationType">
+    <ginkgo-executable value="$PROJECT_DIR$/hack/idea/ginkgo-run.sh" />
+    <working-dir value="$PROJECT_DIR$" />
+    <envs>
+      <env name="PROJ_DIR" value="$PROJECT_DIR$" />
+    </envs>
+    <ginkgo-scope value="ALL" />
+    <focus-expression value="" />
+    <package-name />
+    <method v="2" />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 98fd833..7f503cb 100644
--- a/Makefile
+++ b/Makefile
@@ -23,8 +23,8 @@
 REPOSITORY ?= $(or $(NAMESPACE:%/=%), apache)
 IMG = $(REPOSITORY)/$(NAME)
 # Default tag from info in version/version.go
-VERSION_SUFFIX = $(shell cat version/version.go | grep -E 'VersionSuffix([[:space:]]+)=' | grep -o '["''].*["'']' | xargs)
-TMP_VERSION = $(shell cat version/version.go | grep -E 'Version([[:space:]]+)=' | grep -o '["''].*["'']' | xargs)
+VERSION_SUFFIX = $(shell cat version/version.go | grep -E 'VersionSuffix([[:space:]]+)=' | sed 's/.*["'']\(.*\)["'']/\1/g')
+TMP_VERSION = $(shell cat version/version.go | grep -E 'Version([[:space:]]+)=' | sed 's/.*["'"'"']\(.*\)["'"'"']/\1/g')
 ifneq (,$(VERSION_SUFFIX))
 VERSION = $(TMP_VERSION)-$(VERSION_SUFFIX)
 else
@@ -38,6 +38,7 @@
 KUSTOMIZE_VERSION=v4.5.2
 CONTROLLER_GEN_VERSION=v0.5.0
 GO_LICENSES_VERSION=v1.0.0
+GINKGO_VERSION = $(shell cat go.mod | grep 'github.com/onsi/ginkgo' | sed 's/.*\(v.*\)$$/\1/g')
 
 GO111MODULE ?= on
 
@@ -115,6 +116,9 @@
 build-release-artifacts: clean prepare docker-build ## Build all release artifacts for the Solr Operator
 	./hack/release/artifacts/create_artifacts.sh -d $(or $(ARTIFACTS_DIR),release-artifacts) -v $(VERSION)
 
+idea: ginkgo ## Setup the project so to be able to run tests via IntelliJ/GoLand
+	cat hack/idea/idea-setup.txt
+
 ##@ Build
 
 build: generate ## Build manager binary.
@@ -255,6 +259,10 @@
 go-licenses: ## Download go-licenses locally if necessary.
 	$(call go-get-tool,$(GO_LICENSES),github.com/google/go-licenses@$(GO_LICENSES_VERSION))
 
+GINKGO = $(PROJECT_DIR)/bin/ginkgo
+ginkgo: ## Download go-licenses locally if necessary.
+	$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/ginkgo@${GINKGO_VERSION})
+
 # go-get-tool will 'go get' any package $2 and install it to $1.
 PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
 define go-get-tool
diff --git a/README.md b/README.md
index 07a9765..334f960 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,8 @@
 Before submitting a PR, please be sure to run `make prepare` before committing.
 Otherwise the GitHub checks are likely to fail.
 
+If you are trying to run tests locally in IntelliJ/GoLand, refer to [the IDEA tests docs](dev-docs/idea-tests.md).
+
 ## License
 
 Please read the [LICENSE](LICENSE) file here.
diff --git a/dev-docs/idea-tests.md b/dev-docs/idea-tests.md
new file mode 100644
index 0000000..ccf18dd
--- /dev/null
+++ b/dev-docs/idea-tests.md
@@ -0,0 +1,15 @@
+# Running tests in IDEA
+
+The Solr Operator tests cannot be run by default in IntelliJ or GoLand,
+however the project is setup to make this as easy as possible for developers to enable it.
+
+Steps:
+1. Install the [GinkGo IDEA Plugin](https://plugins.jetbrains.com/plugin/17554-ginkgo)
+2. Run `make idea`
+
+At this point you should be able to run individual tests via IntelliJ/GoLand.
+If you need to reset these values, you could close the project, delete the `.idea` folder, then open the project again.
+IntelliJ/GoLand should then load in the Testing configuration saved under `.run/`.
+
+The Testing Configuration is saved in the repo under `.run/`.
+This is not specific to any installation, so please do not commit any changes to these files.
diff --git a/hack/idea/ginkgo-run.sh b/hack/idea/ginkgo-run.sh
new file mode 100755
index 0000000..afb574d
--- /dev/null
+++ b/hack/idea/ginkgo-run.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# exit immediately when a command fails
+set -e
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
+# error on unset variables
+set -u
+
+ENVTEST_ASSETS_DIR="${PROJ_DIR}/testbin"
+mkdir -p "${ENVTEST_ASSETS_DIR}"
+test -f "${ENVTEST_ASSETS_DIR}/setup-envtest.sh" || curl -sSLo "${ENVTEST_ASSETS_DIR}/setup-envtest.sh" https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
+source "${ENVTEST_ASSETS_DIR}/setup-envtest.sh"
+fetch_envtest_tools "${ENVTEST_ASSETS_DIR}"
+setup_envtest_env "${ENVTEST_ASSETS_DIR}"
+echo "${KUBEBUILDER_ASSETS}"
+GINKGO_EDITOR_INTEGRATION=true "${PROJ_DIR}/bin/ginkgo" "$@"
diff --git a/hack/idea/idea-setup.txt b/hack/idea/idea-setup.txt
new file mode 100644
index 0000000..97dc9f6
--- /dev/null
+++ b/hack/idea/idea-setup.txt
@@ -0,0 +1,12 @@
+
+In order to easily run the Solr Operator tests via IDEA (IntelliJ or GoLand), you must install the GinkGo IntelliJ Plugin,
+as the test framework is not supported by default in IntelliJ or GoLand.
+
+The plugin can be found here: https://plugins.jetbrains.com/plugin/17554-ginkgo
+
+There is no need to install Ginkgo yourself, as the plugin documentation tells you.
+The "make idea" command does this for you.
+
+The templating of the testing configuration is included in the repo under .run/.
+Please do not make changes to this file.
+
diff --git a/hack/release/artifacts/bundle_source.sh b/hack/release/artifacts/bundle_source.sh
index 18ca762..0800c60 100755
--- a/hack/release/artifacts/bundle_source.sh
+++ b/hack/release/artifacts/bundle_source.sh
@@ -79,5 +79,6 @@
 COPYFILE_DISABLE=true "${TAR}" --exclude-vcs --exclude-vcs-ignores \
   --exclude .asf.yaml \
   --exclude .github \
+  --exclude .run \
   --transform "s,^,solr-operator-${VERSION}/," \
   -czf "${ARTIFACTS_DIR}/solr-operator-${VERSION}.tgz" .