-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2145 from cloudfoundry/test-app.go-mod-tidy
Adds workflow that helps the bots with intermediate files.
- Loading branch information
Showing
14 changed files
with
395 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
.github/workflows/dependency-update.go-mod-tidy_and_make-package-specs.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: "renovate-/ospo-bot: go mod tidy and make package-specs" | ||
on: | ||
push: | ||
branches: | ||
- "renovate/**" | ||
- "dependabot/**" | ||
paths: | ||
- ".github/workflows/dependency-update-go-mod-tidy.yaml" | ||
- "./src/**/go.mod" | ||
- "./src/**/go.sum" | ||
jobs: | ||
go-mod-tidy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
# We potentially want to add at the end a commit by the author of the most recent | ||
# commit in this branch. However github has some protection which prevents workflows | ||
# to run in case a commit has been pushed with the default job-specific github-token. | ||
# For this case we need to use another one here. | ||
# | ||
# For more information, see: | ||
# <https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow> | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
token: ${{ secrets.APP_AUTOSCALER_CI_TOKEN }} # With push token that can trigger new PR jobs | ||
- name: Configure git | ||
shell: bash | ||
run: | | ||
#! /usr/bin/env bash | ||
set -eu -o pipefail | ||
declare -r commit_author_name="${{github.event.head_commit.author.name}}" | ||
declare -r commit_author_email="${{github.event.head_commit.author.email}}" | ||
git config --global --add safe.directory "${GITHUB_WORKSPACE}" | ||
git config user.name "${commit_author_name}" | ||
git config user.email "${commit_author_email}" | ||
- name: go-mod-tidy and make package-specs | ||
shell: bash | ||
run: | | ||
#! /usr/bin/env bash | ||
set -eu -o pipefail | ||
# We need the subsequent standard-message to determine if the last commit | ||
# has already cleaned up everything. In this case this workflow should not | ||
# change anything and we exit early. | ||
# An alternative would be to use a tag for this. But this does affect the whole | ||
# PR instead of just the latest commit. | ||
declare -r tidy_message='🤖🦾🛠️ go mod tidy & make package-specs' | ||
declare -r commit_author_name="${{github.event.head_commit.author.name}}" | ||
declare -r commit_message="${{github.event.head_commit.message}}" | ||
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 | ||
# requires go-modules to be tidied up. So we need to generate the files | ||
# before changing `go.mod` and `go.sum`. | ||
declare -r current_branch="$(git branch --show-current)" | ||
git checkout 'HEAD~1' | ||
make --directory='./src/acceptance/assets/app/go_app' generate-fakes | ||
make --directory='./src/autoscaler' generate-fakes | ||
git checkout "${current_branch}" | ||
# ⚠️ For this workflow to be successful, the subsequent line must not | ||
# trigger again the creation of the generated files. | ||
make package-specs | ||
declare -i -r changed_files=$(git status --porcelain | wc --lines) | ||
if ((changed_files >= 0)) | ||
then | ||
git add . | ||
git commit --message="${tidy_message}" | ||
git push | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.