diff --git a/.github/workflows/bosh-release-checks.yaml b/.github/workflows/bosh-release-checks.yaml index 02fe1445c7..c30957fe4a 100644 --- a/.github/workflows/bosh-release-checks.yaml +++ b/.github/workflows/bosh-release-checks.yaml @@ -55,7 +55,7 @@ jobs: make --directory='./src/autoscaler' generate-fakes export PATH="${PATH}:/usr/local/maven/bin" - make go-mod-tidy vendor db scheduler + make go-mod-tidy go-mod-vendor db scheduler - name: Build Dev Release id: build diff --git a/Makefile b/Makefile index 1d8c5026ef..900bb8d807 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ clean-vendor: @echo " - cleaning vendored go" @find . -depth -name "vendor" -type d -exec rm -rf {} \; clean-autoscaler: - @make -C src/autoscaler clean + @make --directory='./src/autoscaler' clean clean-scheduler: @echo " - cleaning scheduler test resources" @rm -rf src/scheduler/src/test/resources/certs @@ -96,14 +96,14 @@ scheduler: @echo "# building $@" @cd src && mvn --no-transfer-progress package -pl scheduler ${MVN_OPTS} && cd .. autoscaler: - @make -C src/autoscaler build + @make --directory='./src/autoscaler' build changeloglockcleaner: - @make -C src/changeloglockcleaner build + @make --directory='./src/changeloglockcleaner' build changelog: - @make -C src/changelog build + @make --directory='./src/changelog' build $(addprefix test_,$(go_modules)): @echo "# Compiling '$(patsubst test_%,%,$@)' tests" - @make -C src/$(patsubst test_%,%,$@) build_tests + @make --directory='./src/$(patsubst test_%,%,$@)' build_tests .PHONY: test-certs @@ -120,20 +120,20 @@ target/scheduler_test_certs: test: test-autoscaler test-scheduler test-changelog test-changeloglockcleaner test-acceptance-unit test-autoscaler: check-db_type init-db test-certs @echo " - using DBURL=${DBURL} OPTS=${OPTS}" - @make -C src/autoscaler test DBURL="${DBURL}" OPTS="${OPTS}" + @make --directory='./src/autoscaler' test DBURL="${DBURL}" OPTS="${OPTS}" test-autoscaler-suite: check-db_type init-db test-certs @echo " - using DBURL=${DBURL} TEST=${TEST} OPTS=${OPTS}" - @make -C src/autoscaler testsuite TEST=${TEST} DBURL="${DBURL}" OPTS="${OPTS}" + @make --directory='./src/autoscaler' testsuite TEST=${TEST} DBURL="${DBURL}" OPTS="${OPTS}" test-scheduler: check-db_type init-db test-certs @export DB_HOST=${DB_HOST}; \ cd src && mvn test --no-transfer-progress -Dspring.profiles.include=${db_type} && cd .. test-changelog: - @make -C src/changelog test + @make --directory='./src/changelog' test test-changeloglockcleaner: init-db test-certs - @make -C src/changeloglockcleaner test DBURL="${DBURL}" + @make --directory='./src/changeloglockcleaner' test DBURL="${DBURL}" test-acceptance-unit: - @make -C src/acceptance test-unit - @make -C src/acceptance/assets/app/go_app test + @make --directory='./src/acceptance' test-unit + @make --directory='./src/acceptance/assets/app/go_app' test .PHONY: start-db @@ -291,16 +291,20 @@ mod-download: cd $${folder}; echo " - go mod download '$${folder}'"; go mod download; cd - >/dev/null;\ done -.PHONY: vendor -vendor: - @for folder in $$(find . -maxdepth 3 -name "go.mod" -exec dirname {} \;);\ - do\ - cd $${folder}; echo " - go mod vendor '$${folder}'"; go mod vendor; cd - >/dev/null;\ - done +.PHONY: vendor acceptance.go-mod-vendor autoscaler.go-mod-vendor changelog.go-mod-vendor \ + changeloglockcleander.go-mod-vendor +go-mod-vendor: acceptance.go-mod-vendor autoscaler.go-mod-vendor changelog.go-mod-vendor \ + changeloglockcleander.go-mod-vendor +acceptance.go-mod-vendor: + make --directory='${go-acceptance-dir}' go-mod-vendor +autoscaler.go-mod-vendor: + make --directory='${go-autoscaler-dir}' go-mod-vendor +changelog.go-mod-vendor: + make --directory='${go-changelog-dir}' go-mod-vendor +changeloglockcleander.go-mod-vendor: + make --directory='${go-changeloglockcleander-dir}' go-mod-vendor + -.PHONY: fakes -fakes: - @make -C src/autoscaler fakes # https://github.com/golang/tools/blob/master/gopls/doc/workspace.md .PHONY: workspace @@ -317,7 +321,7 @@ markdownlint-cli: which markdownlint || npm install -g --omit=dev markdownlint-cli .PHONY: deploy-autoscaler deploy-register-cf deploy-autoscaler-bosh deploy-cleanup -deploy-autoscaler: vendor uaac db scheduler deploy-autoscaler-bosh deploy-register-cf +deploy-autoscaler: go-mod-vendor uaac db scheduler deploy-autoscaler-bosh deploy-register-cf deploy-register-cf: echo " - registering broker with cf" [ "$${BUILDIN_MODE}" == "false" ] && { ${CI_DIR}/autoscaler/scripts/register-broker.sh; } || echo " - Not registering broker due to buildin mode enabled" @@ -354,7 +358,7 @@ deploy-prometheus: ${prometheus-bosh-release-path}/manifests .PHONY: build-test-app build-test-app: - @make -C src/acceptance/assets/app/go_app build + @make --directory='./src/acceptance/assets/app/go_app' build .PHONY: acceptance-tests acceptance-tests: build-test-app diff --git a/ci/autoscaler/scripts/deploy-autoscaler.sh b/ci/autoscaler/scripts/deploy-autoscaler.sh index 4ebe7528b3..595c9b16d0 100755 --- a/ci/autoscaler/scripts/deploy-autoscaler.sh +++ b/ci/autoscaler/scripts/deploy-autoscaler.sh @@ -9,19 +9,19 @@ bosh_deploy_opts="${BOSH_DEPLOY_OPTS:-""}" bosh_upload_release_opts="${BOSH_UPLOAD_RELEASE_OPTS:-""}" bosh_upload_stemcell_opts="${BOSH_UPLOAD_STEMCELL_OPTS:-""}" ops_files=${OPS_FILES:-"${autoscaler_dir}/operations/add-releases.yml\ - ${autoscaler_dir}/operations/instance-identity-cert-from-cf.yml\ - ${autoscaler_dir}/operations/add-postgres-variables.yml\ - ${autoscaler_dir}/operations/connect_to_postgres_with_certs.yml\ - ${autoscaler_dir}/operations/enable-nats-tls.yml\ - ${autoscaler_dir}/operations/loggregator-certs-from-cf.yml\ - ${autoscaler_dir}/operations/add-extra-plan.yml\ - ${autoscaler_dir}/operations/set-release-version.yml\ - ${autoscaler_dir}/operations/enable-log-cache.yml\ - ${autoscaler_dir}/operations/log-cache-syslog-server.yml\ - ${autoscaler_dir}/operations/remove-metricsserver.yml\ - ${autoscaler_dir}/operations/remove-metricsgateway.yml\ - ${autoscaler_dir}/operations/enable-log-cache-via-uaa.yml\ - ${autoscaler_dir}/operations/enable-scheduler-logging.yml"} + ${autoscaler_dir}/operations/instance-identity-cert-from-cf.yml\ + ${autoscaler_dir}/operations/add-postgres-variables.yml\ + ${autoscaler_dir}/operations/connect_to_postgres_with_certs.yml\ + ${autoscaler_dir}/operations/enable-nats-tls.yml\ + ${autoscaler_dir}/operations/loggregator-certs-from-cf.yml\ + ${autoscaler_dir}/operations/add-extra-plan.yml\ + ${autoscaler_dir}/operations/set-release-version.yml\ + ${autoscaler_dir}/operations/enable-log-cache.yml\ + ${autoscaler_dir}/operations/log-cache-syslog-server.yml\ + ${autoscaler_dir}/operations/remove-metricsserver.yml\ + ${autoscaler_dir}/operations/remove-metricsgateway.yml\ + ${autoscaler_dir}/operations/enable-log-cache-via-uaa.yml\ + ${autoscaler_dir}/operations/enable-scheduler-logging.yml"} if [[ "${buildin_mode}" == "true" ]]; then ops_files+=" ${autoscaler_dir}/operations/use_buildin_mode.yml"; fi; @@ -38,7 +38,7 @@ function setup_autoscaler_uaac(){ local autoscaler_secret="autoscaler_client_secret" local uaa_client_secret=$(credhub get -n /bosh-autoscaler/cf/uaa_admin_client_secret --quiet) uaac target "https://uaa.${system_domain}" --skip-ssl-validation > /dev/null - uaac token client get admin -s "$uaa_client_secret" > /dev/null + uaac token client get admin -s "${uaa_client_secret}" > /dev/null if uaac client get autoscaler_client_id >/dev/null; then step "updating autoscaler uaac client" @@ -127,7 +127,7 @@ function find_or_upload_stemcell() { if ! bosh stemcells | grep "${stemcell_name}" >/dev/null; then URL="https://bosh.io/d/stemcells/${stemcell_name}" if [ "${stemcell_version}" != "latest" ]; then - URL="${URL}?v=${stemcell_version}" + URL="${URL}?v=${stemcell_version}" fi wget "${URL}" -O stemcell.tgz bosh -n upload-stemcell $bosh_upload_stemcell_opts stemcell.tgz @@ -163,4 +163,4 @@ pushd "${autoscaler_dir}" > /dev/null find_or_upload_stemcell find_or_upload_release deploy -popd > /dev/null \ No newline at end of file +popd > /dev/null diff --git a/src/acceptance/Makefile b/src/acceptance/Makefile index cf287d533f..16802fbe15 100644 --- a/src/acceptance/Makefile +++ b/src/acceptance/Makefile @@ -19,12 +19,29 @@ GOLANGCI_LINT_VERSION = v$(shell cat '../../.tool-versions' | grep --regexp='gol | cut --delimiter=' ' --fields='2' ) + +.PHONY: clean +clean: + rm --recursive --force './vendor' + + .PHONY: go-mod-tidy go-mod-tidy: go mod tidy +go-vendoring-folder := ./vendor +go-vendored-files = $(shell find '${go-vendoring-folder}' -type f -name '*.go' 2> '/dev/null') +## This does not work: go-vendored-files = $(wildcard ${go-vendoring-folder}/**/*.go) + +.PHONY: go-mod-vendor +go-mod-vendor: ${go-vendoring-folder} ${go-vendored-files} +${go-vendoring-folder} ${go-vendored-files} &: + go mod vendor + + + test_dirs = $(shell find . -name "*_test.go" -exec dirname {} \; | cut --delimiter='/' --fields='2' \ | sort | uniq) build_tests: $(addprefix build_test-,$(test_dirs)) diff --git a/src/autoscaler/Makefile b/src/autoscaler/Makefile index 057ec2de6d..d9e6bac902 100644 --- a/src/autoscaler/Makefile +++ b/src/autoscaler/Makefile @@ -60,6 +60,17 @@ go-mod-tidy: ./go.mod ./go.sum ${go_deps_without_fakes} +go-vendoring-folder := ./vendor +go-vendored-files = $(shell find '${go-vendoring-folder}' -type f -name '*.go' 2> '/dev/null') +## This does not work: go-vendored-files = $(wildcard ${go-vendoring-folder}/**/*.go) + +.PHONY: go-mod-vendor +go-mod-vendor: ${go-vendoring-folder} ${go-vendored-files} +${go-vendoring-folder} ${go-vendored-files} &: ${app-fakes-dir} ${app-fakes-files} + go mod vendor + + + build-%: @echo "# building $*" @CGO_ENABLED=$(CGO_ENABLED) go build $(BUILDTAGS) $(BUILDFLAGS) -o build/$* $*/cmd/$*/main.go @@ -69,7 +80,7 @@ build: $(addprefix build-,$(binaries)) build_tests: $(addprefix build_test-,$(test_dirs)) -build_test-%: generate +build_test-%: generate-fakes @echo " - building '$*' tests" @export build_folder=${PWD}/build/tests/$* &&\ mkdir -p $${build_folder} &&\ @@ -83,22 +94,19 @@ build_test-%: generate check: fmt lint build test -test: generate +test: generate-fakes @echo "Running tests" @APP_AUTOSCALER_TEST_RUN=true go run github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION} -p ${GINKGO_OPTS} --skip-package=integration -testsuite: generate +testsuite: generate-fakes APP_AUTOSCALER_TEST_RUN=true go run github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION} -p ${GINKGO_OPTS} ${TEST} .PHONY: integration -integration: generate +integration: generate-fakes @echo "# Running integration tests" APP_AUTOSCALER_TEST_RUN=true go run github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION} ${GINKGO_OPTS} integration -.PHONY: generate -generate: - @echo "# Generating counterfeits" - @COUNTERFEITER_NO_GENERATE_WARNING=true go generate ./... + importfmt: @echo "# Formatting the imports" @@ -117,3 +125,4 @@ clean: @go clean -cache -testcache @rm --force --recursive 'build' @rm --force --recursive 'fakes' + @rm --force --recursive 'vendor' diff --git a/src/changelog/Makefile b/src/changelog/Makefile index 3f6cc342aa..6ecb51efa3 100644 --- a/src/changelog/Makefile +++ b/src/changelog/Makefile @@ -20,9 +20,11 @@ GOLANGCI_LINT_VERSION = v$(shell cat '../../.tool-versions' | grep --regexp='gol | cut --delimiter=' ' --fields='2' ) -.PHONY: go-mod-tidy +.PHONY: go-mod-tidy go-mod-vendor go-mod-tidy: go mod tidy +go-mod-vendor: + go mod vendor diff --git a/src/changeloglockcleaner/Makefile b/src/changeloglockcleaner/Makefile index 1a4a060222..8239c61d69 100644 --- a/src/changeloglockcleaner/Makefile +++ b/src/changeloglockcleaner/Makefile @@ -20,9 +20,11 @@ GOLANGCI_LINT_VERSION = v$(shell cat '../../.tool-versions' | grep --regexp='gol | cut --delimiter=' ' --fields='2' ) -.PHONY: go-mod-tidy +.PHONY: go-mod-tidy go-mod-vendor go-mod-tidy: go mod tidy +go-mod-vendor: + go mod vendor