Skip to content

Commit

Permalink
Rename make-target vendor to go-mod-vendor and define its depende…
Browse files Browse the repository at this point in the history
…ncies;
  • Loading branch information
joergdw committed Sep 29, 2023
1 parent dbfa27c commit 49d4ad4
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bosh-release-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 26 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions ci/autoscaler/scripts/deploy-autoscaler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -163,4 +163,4 @@ pushd "${autoscaler_dir}" > /dev/null
find_or_upload_stemcell
find_or_upload_release
deploy
popd > /dev/null
popd > /dev/null
17 changes: 17 additions & 0 deletions src/acceptance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
25 changes: 17 additions & 8 deletions src/autoscaler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} &&\
Expand All @@ -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"
Expand All @@ -117,3 +125,4 @@ clean:
@go clean -cache -testcache
@rm --force --recursive 'build'
@rm --force --recursive 'fakes'
@rm --force --recursive 'vendor'
4 changes: 3 additions & 1 deletion src/changelog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
4 changes: 3 additions & 1 deletion src/changeloglockcleaner/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down

0 comments on commit 49d4ad4

Please sign in to comment.