diff --git a/.github/workflows/dependency-update.go-mod-tidy_and_make-package-specs.yaml b/.github/workflows/dependency-update.go-mod-tidy_and_make-package-specs.yaml index 726024a230..703492c9b4 100644 --- a/.github/workflows/dependency-update.go-mod-tidy_and_make-package-specs.yaml +++ b/.github/workflows/dependency-update.go-mod-tidy_and_make-package-specs.yaml @@ -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 @@ -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 . diff --git a/Makefile b/Makefile index eef5a23fe9..6ab6f294e5 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/scripts/sync-package-specs b/scripts/sync-package-specs index 845f9488f6..c5bfb9089f 100755 --- a/scripts/sync-package-specs +++ b/scripts/sync-package-specs @@ -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" @@ -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 ./... \ No newline at end of file diff --git a/src/autoscaler/Makefile b/src/autoscaler/Makefile index 0d45e3d19f..b7b70d7545 100644 --- a/src/autoscaler/Makefile +++ b/src/autoscaler/Makefile @@ -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