Skip to content

Commit

Permalink
Test installers (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Nov 8, 2019
1 parent 63a8396 commit 1980a77
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 19 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -40,3 +40,43 @@ jobs:
run: |
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
make push
- name: Create Kubernetes cluster
id: kind
uses: engineerd/setup-kind@v0.1.0
with:
config: hack/kubernetes/kind.yaml

- name: Prepare cluster for testing
id: local-path
env:
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
REGISTRY_SECRET: regcred
run: |
export KUBECONFIG="$(kind get kubeconfig-path)"
echo
echo "waiting for nodes to be ready ..."
kubectl wait --for=condition=Ready nodes --all --timeout=5m
kubectl get nodes
echo
echo "installing local-path provisioner ..."
kubectl delete storageclass --all
kubectl apply -f https://github.com/rancher/local-path-provisioner/raw/v0.0.11/deploy/local-path-storage.yaml
kubectl wait --for=condition=Ready pods -n local-path-storage --all --timeout=5m
kubectl apply -f hack/kubernetes/storageclass/standard.yaml
echo
echo "create docker-registry secret"
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
- name: Install CRDs
run: |
export KUBECONFIG="$(kind get kubeconfig-path)"
kubectl apply -f https://github.com/stashed/stash/raw/master/api/crds/stash.appscode.com_functions.yaml
kubectl apply -f https://github.com/stashed/stash/raw/master/api/crds/stash.appscode.com_tasks.yaml
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
- name: Test charts
run: |
export KUBECONFIG="$(kind get kubeconfig-path)"
make ct
27 changes: 27 additions & 0 deletions Makefile
Expand Up @@ -73,6 +73,7 @@ TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)

GO_VERSION ?= 1.12.12
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)-stretch
CHART_TEST_IMAGE ?= quay.io/helmpack/chart-testing:v2.4.0

OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
ifeq ($(OS),windows)
Expand Down Expand Up @@ -265,6 +266,32 @@ unit-tests: $(BUILD_DIRS)
./hack/test.sh $(SRC_DIRS) \
"

.PHONY: ct
ct: $(BUILD_DIRS)
@docker run \
-i \
--rm \
-v $$(pwd):/src \
-w /src \
--net=host \
-v $(HOME)/.kube:/.kube \
-v $(HOME)/.minikube:$(HOME)/.minikube \
-v $(HOME)/.credentials:$(HOME)/.credentials \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
-v $$(pwd)/.go/cache:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
--env KUBECONFIG=$(subst $(HOME),,$(KUBECONFIG)) \
$(CHART_TEST_IMAGE) \
/bin/sh -c " \
kubectl -n kube-system create sa tiller; \
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller; \
helm init --service-account tiller; \
kubectl wait --for=condition=Ready pods -n kube-system --all --timeout=5m; \
ct lint-and-install --all; \
"

ADDTL_LINTERS := goconst,gofmt,goimports,unparam

.PHONY: lint
Expand Down
File renamed without changes.
@@ -1,8 +1,8 @@
apiVersion: v1
description: 'stash-elasticsearch - Elasticsearch database backup and restore plugin for Stash by AppsCode'
name: stash-elasticsearch
version: 5.6.4
appVersion: 5.6.4
version: "5.6.4"
appVersion: "5.6.4"
home: https://github.com/stashed/elasticsearch
icon: https://cdn.appscode.com/images/icon/stash.png
sources:
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions hack/build.sh
Expand Up @@ -35,8 +35,8 @@ export GOOS="${OS}"
export GO111MODULE=on
export GOFLAGS="-mod=vendor"

go install \
-installsuffix "static" \
go install \
-installsuffix "static" \
-ldflags " \
-X main.Version=${VERSION} \
-X main.VersionStrategy=${version_strategy:-} \
Expand All @@ -47,5 +47,5 @@ go install \
-X main.GoVersion=$(go version | cut -d " " -f 3) \
-X main.Compiler=$(go env CC) \
-X main.Platform=${OS}/${ARCH} \
" \
" \
./...
5 changes: 3 additions & 2 deletions hack/e2e.sh
Expand Up @@ -16,7 +16,7 @@

set -eou pipefail

export CGO_ENABLED=1
export CGO_ENABLED=0
export GO111MODULE=on
export GOFLAGS="-mod=vendor"

Expand All @@ -26,4 +26,5 @@ DOCKER_REGISTRY=${DOCKER_REGISTRY:-}

echo "Running e2e tests:"
cmd="ginkgo -r --v -race --progress --trace --noisyPendings=false ${GINKGO_ARGS} test -- --docker-registry=${DOCKER_REGISTRY} ${TEST_ARGS}"
echo $cmd; $cmd
echo "$cmd"
$cmd
32 changes: 21 additions & 11 deletions hack/fmt.sh
Expand Up @@ -22,17 +22,27 @@ export GOFLAGS="-mod=vendor"

TARGETS="$@"

echo "Running reimport.py"
cmd="reimport3.py ${REPO_PKG} ${TARGETS}"
$cmd
echo
if [ -n "$TARGETS" ]; then
echo "Running reimport.py"
cmd="reimport3.py ${REPO_PKG} ${TARGETS}"
$cmd
echo

echo "Running goimports:"
cmd="goimports -w ${TARGETS}"
echo $cmd; $cmd
echo
echo "Running goimports:"
cmd="goimports -w ${TARGETS}"
echo "$cmd"
$cmd
echo

echo "Running gofmt:"
cmd="gofmt -s -w ${TARGETS}"
echo "$cmd"
$cmd
echo
fi

echo "Running gofmt:"
cmd="gofmt -s -w ${TARGETS}"
echo $cmd; $cmd
echo "Running shfmt:"
cmd="find . -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \;"
echo "$cmd"
eval "$cmd" # xref: https://stackoverflow.com/a/5615748/244009
echo
19 changes: 19 additions & 0 deletions hack/kubernetes/kind.yaml
@@ -0,0 +1,19 @@
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
# the control plane node
- role: control-plane
extraMounts:
- containerPath: /opt/local-path-provisioner
hostPath: /mnt
readOnly: false
- role: worker
extraMounts:
- containerPath: /opt/local-path-provisioner
hostPath: /mnt
readOnly: false
- role: worker
extraMounts:
- containerPath: /opt/local-path-provisioner
hostPath: /mnt
readOnly: false
9 changes: 9 additions & 0 deletions hack/kubernetes/storageclass/standard.yaml
@@ -0,0 +1,9 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: standard
annotations:
storageclass.beta.kubernetes.io/is-default-class: "true"
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
1 change: 0 additions & 1 deletion hack/license/makefile.txt
Expand Up @@ -12,4 +12,3 @@
# 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.

0 comments on commit 1980a77

Please sign in to comment.