-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Wałach
authored
Jun 9, 2020
1 parent
d1fe462
commit fb98a37
Showing
7 changed files
with
718 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
APP_NAME = image-syncer | ||
IMG = $(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/$(APP_NAME) | ||
TAG = $(DOCKER_TAG) | ||
|
||
.PHONY: validate | ||
validate: | ||
./before-commit.sh ci | ||
|
||
.PHONY: ci-pr | ||
ci-pr: validate | ||
|
||
.PHONY: ci-master | ||
ci-master: validate | ||
|
||
.PHONY: ci-release | ||
ci-release: validate | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(APP_NAME) | ||
rm -f logs-printer | ||
.PHONY: dry-run | ||
dry-run: | ||
go run main.go --dry-run=true --images-file external-images.yaml --target-key-file="${GOOGLE_APPLICATION_CREDENTIALS}" | ||
|
||
.PHONY: run | ||
run: | ||
go run main.go --dry-run=false --images-file external-images.yaml --target-key-file="${GOOGLE_APPLICATION_CREDENTIALS}" |
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,117 @@ | ||
#!/usr/bin/env bash | ||
|
||
readonly CI_FLAG=ci | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
INVERTED='\033[7m' | ||
NC='\033[0m' # No Color | ||
|
||
echo -e "${INVERTED}" | ||
echo "USER: ${USER}" | ||
echo "PATH: ${PATH}" | ||
echo "GOPATH: ${GOPATH}" | ||
echo -e "${NC}" | ||
|
||
## | ||
# GO MOD VERIFY | ||
## | ||
go mod verify | ||
ensureResult=$? | ||
if [ ${ensureResult} != 0 ]; then | ||
echo -e "${RED}✗ go mod verify${NC}\n$ensureResult${NC}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}√ go mod verify${NC}" | ||
fi | ||
|
||
goFilesToCheck=$(find . -type f -name "*.go" | egrep -v "\/vendor\/|_*/automock/|_*/testdata/|/pkg\/|_*export_test.go") | ||
|
||
## | ||
# GO BUILD | ||
## | ||
binaries=("image-syncer") | ||
buildEnv="" | ||
if [ "$1" == "$CI_FLAG" ]; then | ||
# build binary statically | ||
buildEnv="env CGO_ENABLED=0" | ||
fi | ||
|
||
for binary in "${binaries[@]}"; do | ||
${buildEnv} go build -o "${binary}" . | ||
goBuildResult=$? | ||
if [ ${goBuildResult} != 0 ]; then | ||
echo -e "${RED}✗ go build ${binary} ${NC}\n $goBuildResult${NC}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}√ go build ${binary} ${NC}" | ||
fi | ||
done | ||
|
||
## | ||
# GO LINT | ||
## | ||
go get golang.org/x/lint/golint | ||
buildLintResult=$? | ||
if [ ${buildLintResult} != 0 ]; then | ||
echo -e "${RED}✗ go get golint${NC}\n$buildLintResult${NC}" | ||
exit 1 | ||
fi | ||
|
||
golintResult=$(echo "${goFilesToCheck}" | xargs -L1 "${GOPATH}"/bin/golint) | ||
|
||
if [ "${#golintResult}" != 0 ]; then | ||
echo -e "${RED}✗ golint\n$golintResult${NC}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}√ golint${NC}" | ||
fi | ||
|
||
## | ||
# GO IMPORTS & FMT | ||
## | ||
go get golang.org/x/tools/cmd/goimports | ||
buildGoImportResult=$? | ||
if [ ${buildGoImportResult} != 0 ]; then | ||
echo -e "${RED}✗ go build goimports${NC}\n$buildGoImportResult${NC}" | ||
exit 1 | ||
fi | ||
|
||
goImportsResult=$(echo "${goFilesToCheck}" | xargs -L1 "${GOPATH}"/bin/goimports -w -l) | ||
|
||
if [ "${#goImportsResult}" != 0 ]; then | ||
echo -e "${RED}✗ goimports and fmt ${NC}\n$goImportsResult${NC}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}√ goimports and fmt ${NC}" | ||
fi | ||
|
||
## | ||
# GO VET | ||
## | ||
packagesToVet=("./...") | ||
|
||
for vPackage in "${packagesToVet[@]}"; do | ||
vetResult=$(go vet "${vPackage}") | ||
if [ "${#vetResult}" != 0 ]; then | ||
echo -e "${RED}✗ go vet ${vPackage} ${NC}\n$vetResult${NC}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}√ go vet ${vPackage} ${NC}" | ||
fi | ||
done | ||
|
||
## | ||
# GO TEST | ||
## | ||
echo "? go test" | ||
go test ./... | ||
# Check if tests passed | ||
if [ $? != 0 ]; then | ||
echo -e "${RED}✗ go test\n${NC}" | ||
exit 1 | ||
else | ||
echo -e "${GREEN}√ go test${NC}" | ||
fi | ||
|
||
go mod tidy |
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,5 @@ | ||
targetRepoPrefix: "eu.gcr.io/kyma-project/external/" | ||
images: | ||
- source: "quay.io/prometheus/prometheus:v2.17.1" | ||
- source: "grafana/grafana:7.0.1" | ||
- source: "grafana/loki:v1.3.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,30 @@ | ||
module github.com/kyma-project/test-infra/development/image-syncer | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect | ||
github.com/Microsoft/go-winio v0.4.14 // indirect | ||
github.com/containerd/containerd v1.3.4 // indirect | ||
github.com/docker/distribution v2.7.1+incompatible // indirect | ||
github.com/docker/docker v17.12.0-ce-rc1.0.20200528182317-b47e74255811+incompatible | ||
github.com/docker/go-connections v0.4.0 // indirect | ||
github.com/docker/go-units v0.4.0 // indirect | ||
github.com/gogo/protobuf v1.3.1 // indirect | ||
github.com/google/go-cmp v0.3.0 // indirect | ||
github.com/gorilla/mux v1.7.4 // indirect | ||
github.com/jamiealquiza/envy v1.1.0 | ||
github.com/morikuni/aec v1.0.0 // indirect | ||
github.com/novln/docker-parser v1.0.0 | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/opencontainers/image-spec v1.0.1 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/sirupsen/logrus v1.6.0 | ||
github.com/spf13/cobra v1.0.0 | ||
golang.org/x/net v0.0.0-20200528225125-3c3fba18258b // indirect | ||
golang.org/x/text v0.3.2 // indirect | ||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect | ||
google.golang.org/grpc v1.29.1 // indirect | ||
gopkg.in/yaml.v2 v2.3.0 | ||
gotest.tools v2.2.0+incompatible // indirect | ||
) |
Oops, something went wrong.