-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance unit testing and overall project structures (#16)
Signed-off-by: Mike Ng <[email protected]>
- Loading branch information
Showing
73 changed files
with
1,656 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
multicloud-operators-channel | ||
multicluster-operators-channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
latest | ||
2.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed 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. | ||
|
||
-include /opt/build-harness/Makefile.prow | ||
|
||
LOCAL_OS := $(shell uname) | ||
ifeq ($(LOCAL_OS),Linux) | ||
TARGET_OS ?= linux | ||
XARGS_FLAGS="-r" | ||
else ifeq ($(LOCAL_OS),Darwin) | ||
TARGET_OS ?= darwin | ||
XARGS_FLAGS= | ||
else | ||
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported") | ||
endif | ||
|
||
FINDFILES=find . \( -path ./.git -o -path ./.github \) -prune -o -type f | ||
XARGS = xargs -0 ${XARGS_FLAGS} | ||
CLEANXARGS = xargs ${XARGS_FLAGS} | ||
|
||
IMG ?= $(shell cat COMPONENT_NAME 2> /dev/null) | ||
REGISTRY = quay.io/open-cluster-management | ||
VERSION ?= $(shell cat COMPONENT_VERSION 2> /dev/null) | ||
IMAGE_NAME_AND_VERSION ?= $(REGISTRY)/$(IMG):$(VERSION) | ||
export GOPACKAGES = $(shell go list ./... | grep -v /manager | grep -v /bindata | grep -v /vendor | grep -v /internal | grep -v /build | grep -v /test | grep -v /e2e ) | ||
|
||
.PHONY: build | ||
|
||
build: | ||
@common/scripts/gobuild.sh build/_output/bin/$(IMG) ./cmd/manager | ||
|
||
.PHONY: build-images | ||
|
||
build-images: build | ||
@docker build -t ${IMAGE_NAME_AND_VERSION} -f build/Dockerfile . | ||
@docker tag ${IMAGE_NAME_AND_VERSION} $(REGISTRY)/$(IMG):latest | ||
|
||
.PHONY: lint | ||
|
||
lint: | ||
@build/run-code-lint.sh | ||
|
||
.PHONY: lint-all | ||
|
||
lint-all: lint-yaml lint-go | ||
|
||
.PHONY: lint-yaml | ||
|
||
lint-yaml: | ||
@${FINDFILES} \( -name '*.yml' -o -name '*.yaml' \) -print0 | ${XARGS} grep -L -e "{{" | ${CLEANXARGS} yamllint -c ./common/config/.yamllint.yml | ||
|
||
.PHONY: lint-go | ||
|
||
lint-go: | ||
@${FINDFILES} -name '*.go' \( ! \( -name '*.gen.go' -o -name '*.pb.go' \) \) -print0 | ${XARGS} common/scripts/lint_go.sh | ||
|
||
.PHONY: test | ||
|
||
test: | ||
@build/setup-tests.sh | ||
@build/run-unit-tests.sh | ||
|
||
.PHONY: e2e | ||
|
||
export CONTAINER_NAME=e2e | ||
e2e: build build-images | ||
build/run-e2e-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM registry.ci.openshift.org/open-cluster-management/builder:go1.16-linux AS builder | ||
|
||
WORKDIR /go/src/github.com/open-cluster-management/multicluster-operators-channel | ||
COPY . . | ||
RUN make -f Makefile.prow build | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
||
RUN microdnf update && \ | ||
microdnf clean all | ||
|
||
ENV OPERATOR=/usr/local/bin/multicluster-operators-channel \ | ||
USER_UID=1001 \ | ||
USER_NAME=multicluster-operators-channel | ||
|
||
# install operator binary | ||
COPY --from=builder /go/src/github.com/open-cluster-management/multicluster-operators-channel/build/_output/bin/multicluster-operators-channel ${OPERATOR} | ||
|
||
COPY build/bin /usr/local/bin | ||
RUN /usr/local/bin/user_setup | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint"] | ||
|
||
USER ${USER_UID} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed 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. | ||
|
||
|
||
echo "BUILD GOES HERE!" | ||
|
||
echo "<repo>/<component>:<tag> : $1" | ||
|
||
# Run our build target and set IMAGE_NAME_AND_VERSION | ||
export IMAGE_NAME_AND_VERSION=${1} | ||
make build | ||
make build-images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed 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. | ||
|
||
echo "DEPLOY TO CLUSTER GOES HERE! IT SHOULD DO NOTHING RIGHT NOW!" | ||
|
||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed 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. | ||
|
||
echo "INSTALL DEPENDENCIES GOES HERE!" | ||
|
||
_OPERATOR_SDK_VERSION=v0.12.0 | ||
|
||
if ! [ -x "$(command -v operator-sdk)" ]; then | ||
if [[ "$OSTYPE" == "linux-gnu" ]]; then | ||
curl -L https://github.com/operator-framework/operator-sdk/releases/download/${_OPERATOR_SDK_VERSION}/operator-sdk-${_OPERATOR_SDK_VERSION}-x86_64-linux-gnu -o operator-sdk | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
curl -L https://github.com/operator-framework/operator-sdk/releases/download/${_OPERATOR_SDK_VERSION}/operator-sdk-${_OPERATOR_SDK_VERSION}-x86_64-apple-darwin -o operator-sdk | ||
fi | ||
chmod +x operator-sdk | ||
sudo mv operator-sdk /usr/local/bin/operator-sdk | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed 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. | ||
|
||
set -o errexi | ||
set -o nounset | ||
set -o pipefail | ||
set -o xtrace | ||
|
||
# Prepare lint tools | ||
# Install hadolint | ||
HADOLINT_PATH="${HOME}"/hadolint | ||
mkdir -p "${HADOLINT_PATH}" | ||
wget -P "${HADOLINT_PATH}" https://github.com/hadolint/hadolint/releases/download/v1.17.5/hadolint-Linux-x86_64 | ||
mv "${HADOLINT_PATH}"/hadolint-Linux-x86_64 "${HADOLINT_PATH}"/hadolint | ||
chmod +x "${HADOLINT_PATH}"/hadolint | ||
export PATH="${HADOLINT_PATH}":"${PATH}" | ||
|
||
# Install yamllint | ||
pip install --user yamllint | ||
|
||
# Install markdown lint | ||
gem install mdl | ||
gem install awesome_bot | ||
|
||
# Install golangci-lint | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)"/bin v1.24.0 | ||
|
||
# Start lint task | ||
make -f Makefile.prow lint-all |
Oops, something went wrong.