Skip to content

Commit

Permalink
Merge pull request #2340 from cloudfoundry/fix_automation
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
joergdw authored Nov 9, 2023
2 parents 47d7597 + df31314 commit 260dc7b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ jobs:
declare -r commit_author_name="${{github.event.head_commit.author.name}}"
declare -r commit_message="${{github.event.head_commit.message}}"
## 👷🏼🚧 To-do: Un-comment me again
# if [[ ! "${commit_author_name}" =~ ('dependabot'|'renovate')'[bot]' ]] \
# || [[ "${commit_message}" == "${tidy_message}" ]]
# then
# echo 'This commit was not by a known bot or already an automatic `go mod tidy`! Exiting …'
# exit 0
# fi
echo '👷🏼🚧 Position 1' # To-do: remove
if [[ ! "${commit_author_name}" =~ ('dependabot'|'renovate')'[bot]' ]] \
|| [[ "${commit_message}" == "${tidy_message}" ]]
then
echo 'This commit was not by a known bot or already an automatic `go mod tidy`! Exiting …'
exit 0
fi
# Generated files are needed for `go mod tidy` which is a dependency of the
# target `package-specs`. However the generation of them itself already
Expand All @@ -89,16 +86,12 @@ jobs:
make generate-openapi-generated-clients-and-servers
git checkout "${current_branch}"
echo '👷🏼🚧 Position 2' # To-do: remove
# ⚠️ For this workflow to be successful, the subsequent line must not
# trigger again the creation of the generated files.
make package-specs
echo '👷🏼🚧 Position 3' # To-do: remove
declare -i -r num_changed_files=$(git status --porcelain | wc --lines)
if ((num_changed_files >= 0))
declare -i -r num_changed_files="$(git status --porcelain | wc --lines)"
if ((num_changed_files > 0))
then
echo 'Changes to some files were necessary!'
git add .
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ mod-download:
cd $${folder}; echo " - go mod download '$${folder}'"; go mod download; cd - >/dev/null;\
done

.PHONY: vendor acceptance.go-mod-vendor autoscaler.go-mod-vendor changelog.go-mod-vendor \
.PHONY: 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
Expand Down Expand Up @@ -405,7 +405,8 @@ run-performance:
run-act:
${AUTOSCALER_DIR}/scripts/run_act.sh;\

package-specs: go-mod-tidy vendor

package-specs: go-mod-tidy go-mod-vendor
@echo " - Updating the package specs"
@./scripts/sync-package-specs

Expand Down
29 changes: 15 additions & 14 deletions scripts/sync-package-specs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#!/bin/bash
set -euo pipefail
#! /usr/bin/env bash
set -eu -o pipefail

function sync_package() {
bosh_pkg=${1}
golang_pkg=${2}
local -r bosh_pkg="${1}"
local -r golang_pkg="${2}"

shift
shift

(
spec_dir=$PWD/packages/${bosh_pkg}
echo "Syncing ${bosh_pkg}..."
cd $PWD/src/autoscaler/${golang_pkg}
local -r spec_dir="${PWD}/packages/${bosh_pkg}"
echo "Syncing ${bosh_pkg}"
cd "${PWD}/src/autoscaler/${golang_pkg}"
{
cat "${spec_dir}/spec" | grep -v '# gosub'
go run github.com/loggregator/gosub@2819a49a12756cab02592b5ee9f17f02148b0617 list "$@" | grep autoscaler | \
sed -e 's|code.cloudfoundry.org/app-autoscaler/src/\(.*\)|- \1/* # gosub|g'
go run github.com/loggregator/gosub@2819a49a12756cab02592b5ee9f17f02148b0617 list "$@" | grep -v autoscaler | \
sed -e 's|\(.*\)|- autoscaler/vendor/\1/* # gosub|g'
cat "${spec_dir}/spec" | grep --invert-match '# gosub'
go run github.com/loggregator/gosub@2819a49a12756cab02592b5ee9f17f02148b0617 list "$@" \
| grep 'autoscaler' \
| sed --expression='s|code.cloudfoundry.org/app-autoscaler/src/\(.*\)|- \1/* # gosub|g'
go run github.com/loggregator/gosub@2819a49a12756cab02592b5ee9f17f02148b0617 list "$@" \
| grep --invert-match 'autoscaler' \
| sed --expression='s|\(.*\)|- autoscaler/vendor/\1/* # gosub|g'
} > "${spec_dir}/spec.new"

mv "${spec_dir}/spec.new" "${spec_dir}/spec"
Expand All @@ -30,5 +32,4 @@ sync_package metricsforwarder metricsforwarder -app ./...
sync_package metricsgateway metricsgateway -app ./...
sync_package metricsserver metricsserver -app ./...
sync_package operator operator -app ./...
sync_package scalingengine scalingengine -app ./...

sync_package scalingengine scalingengine -app ./...
3 changes: 2 additions & 1 deletion src/autoscaler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ ${app-fakes-dir} ${app-fakes-files} &: ./go.mod ./go.sum ./generate-fakes.go


go_deps_without_generated_sources = $(shell find . -type f -name '*.go' \
| grep --invert-match --regexp='${app-fakes-dir}|${openapi-generated-clients-and-servers-dir}')
| grep --invert-match --extended-regexp \
--regexp='${app-fakes-dir}|${openapi-generated-clients-and-servers-dir}')

# This target should depend additionally on `${app-fakes-dir}` and on `${app-fakes-files}`. However
# this is not defined here. The reason is, that for `go-mod-tidy` the generated fakes need to be
Expand Down

0 comments on commit 260dc7b

Please sign in to comment.