Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaedev committed Mar 29, 2024
1 parent 4ab0c81 commit 1ec5383
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/harbor-multi-arch-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
core) make compile_core ${CTX} ;;
jobservice) make compile_jobservice ${CTX};;
registryctl) make compile_registryctl ${CTX};;
notary*) sudo make compile_notary_migrate_patch ${CTX} ;;
notary*) make compile_notary_migrate_patch ${CTX} ;;
standalone_db_migrator) make compile_standalone_db_migrator ${CTX} ;;
esac;
Expand Down
44 changes: 26 additions & 18 deletions template/harbor/v2.7.4/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Makefile for Harbor project
#
# Targets:
Expand All @@ -9,7 +10,7 @@
# compile_golangimage:
# compile from golang image
# for example: make compile_golangimage -e GOBUILDIMAGE= \
# golang:1.18.5
# golang:1.18.8
# compile_core, compile_jobservice: compile specific binary
#
# build: build Harbor docker images from photon baseimage
Expand Down Expand Up @@ -74,6 +75,8 @@ PORTAL_PATH=$(BUILDPATH)/src/portal
CHECKENVCMD=checkenv.sh

# parameters
# default is true
BUILD_PG96=true
REGISTRYSERVER=
REGISTRYPROJECTNAME=goharbor
DEVFLAG=true
Expand Down Expand Up @@ -109,8 +112,8 @@ PREPARE_VERSION_NAME=versions
REGISTRYVERSION=v2.8.0-patch-redis
NOTARYVERSION=v0.6.1
NOTARYMIGRATEVERSION=v4.11.0
TRIVYVERSION=v0.35.0
TRIVYADAPTERVERSION=v0.30.5
TRIVYVERSION=v0.32.1
TRIVYADAPTERVERSION=v0.30.2

# version of chartmuseum for pulling the source code
CHARTMUSEUM_SRC_TAG=v0.14.0
Expand Down Expand Up @@ -155,7 +158,7 @@ GOINSTALL=$(GOCMD) install
GOTEST=$(GOCMD) test
GODEP=$(GOTEST) -i
GOFMT=gofmt -w
GOBUILDIMAGE=golang:1.19.4
GOBUILDIMAGE=golang:1.18.8
GOBUILDPATHINCONTAINER=/harbor
TARGETARCHS=amd64 arm64

Expand Down Expand Up @@ -356,7 +359,7 @@ gen_apis: lint_apis


MOCKERY_IMAGENAME=$(IMAGENAMESPACE)/mockery
MOCKERY_VERSION=v2.14.0
MOCKERY_VERSION=v2.12.3
MOCKERY=$(RUNCONTAINER) ${MOCKERY_IMAGENAME}:${MOCKERY_VERSION}
MOCKERY_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/mockery/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg MOCKERY_VERSION=${MOCKERY_VERSION} -t ${MOCKERY_IMAGENAME}:$(MOCKERY_VERSION) .

Expand Down Expand Up @@ -449,7 +452,7 @@ build:
-e TRIVY_DOWNLOAD_URL=$(TRIVY_DOWNLOAD_URL) -e TRIVY_ADAPTER_DOWNLOAD_URL=$(TRIVY_ADAPTER_DOWNLOAD_URL) \
-e PULL_BASE_FROM_DOCKERHUB=$(PULL_BASE_FROM_DOCKERHUB) -e BUILD_BASE=$(BUILD_BASE) \
-e REGISTRYUSER=$(REGISTRYUSER) -e REGISTRYPASSWORD=$(REGISTRYPASSWORD) \
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE)
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE) -e BUILD_PG96=$(BUILD_PG96)

build_standalone_db_migrator: compile_standalone_db_migrator
make -f $(MAKEFILEPATH_PHOTON)/Makefile _build_standalone_db_migrator -e BASEIMAGETAG=$(BASEIMAGETAG) -e VERSIONTAG=$(VERSIONTAG)
Expand All @@ -463,12 +466,25 @@ build_base_docker:
@for name in $(BUILDBASETARGET); do \
echo $$name ; \
sleep 30 ; \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
if [ $$name == "db" ]; then \
make _build_base_db ; \
else \
$(DOCKERBUILD) --build-arg BUILD_PG96=$(BUILD_PG96) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
fi ; \
if [ "$(PUSHBASEIMAGE)" != "false" ] ; then \
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) || exit 1; \
fi ; \
done

_build_base_db:
@if [ "$(BUILD_PG96)" = "true" ] ; then \
echo "build pg96 rpm package." ; \
cd $(MAKEFILEPATH_PHOTON)/db && $(MAKEFILEPATH_PHOTON)/db/rpm_builder.sh && cd - ; \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/db/Dockerfile.pg96 -t $(BASEIMAGENAMESPACE)/harbor-db-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
else \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/db/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-db-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
fi

pull_base_docker:
@for name in $(BUILDBASETARGET); do \
echo $$name ; \
Expand Down Expand Up @@ -530,20 +546,12 @@ misspell:
@echo checking misspell...
@find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error

# golangci-lint binary installation or refer to https://golangci-lint.run/usage/install/#local-installation
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
# go get -u github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
lint:
@echo checking lint
@echo $(GOLANGCI_LINT)
@cd ./src/; $(GOLANGCI_LINT) -v run ./... --timeout=10m;

# go install golang.org/x/vuln/cmd/govulncheck@latest
GOVULNCHECK := $(shell go env GOPATH)/bin/govulncheck
govulncheck:
@echo golang vulnerability check
@cd ./src/; $(GOVULNCHECK) ./...;

@cd ./src/; $(GOLANGCI_LINT) -v run ./...;

pushimage:
@echo "pushing harbor images ..."
Expand Down Expand Up @@ -665,4 +673,4 @@ clean:
@echo " make cleandockercomposefile: remove specific version docker-compose"
@echo " make cleanpackage: remove online and offline install package"

all: install
all: install

0 comments on commit 1ec5383

Please sign in to comment.