Skip to content

Commit

Permalink
enable go version upgrade workflow (#4929)
Browse files Browse the repository at this point in the history
* enable go version upgrade workflow

Signed-off-by: deepthi <deepthi@planetscale.com>

* fix code owners

Signed-off-by: deepthi <deepthi@planetscale.com>

* fix code owner errors

Signed-off-by: deepthi <deepthi@planetscale.com>

* configure private repo access

Signed-off-by: deepthi <deepthi@planetscale.com>

* revert changes to upstream file and create private-only version

Signed-off-by: deepthi <deepthi@planetscale.com>

* fix code owner errors

Signed-off-by: deepthi <deepthi@planetscale.com>

---------

Signed-off-by: deepthi <deepthi@planetscale.com>
  • Loading branch information
deepthi authored Apr 10, 2024
1 parent f7a3646 commit 57a554b
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 29 deletions.
48 changes: 24 additions & 24 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
* @planetscale/eng-vitess
bootstrap.sh @deepthi
/.github/actions @Sinjo @dctrwatson @Verolop
/.github/actions @Sinjo @dctrwatson
/.github/ISSUE_TEMPLATE/ @frouioui
/.github/workflows/ @frouioui
/.github/workflows/_planetscale* @Sinjo @dctrwatson @Verolop
/.github/workflows/_planetscale* @Sinjo @dctrwatson @dbussink
/config/mycnf/ @deepthi @shlomi-noach @mattlord
/doc/ @deepthi @frouioui @GuptaManan100
/docker/ @deepthi @mattlord @GuptaManan100 @frouioui
Expand All @@ -14,14 +14,14 @@ bootstrap.sh @deepthi
/examples/region_sharding @deepthi
/java/ @harshit-gangal
/go/cache @vmg
/go/cmd @ajm188
/go/cmd/vtadmin @ajm188 @notfelineit
/go/cmd/vtctldclient @ajm188 @mattlord
/go/cmd @deepthi @rohit-nayak-ps
/go/cmd/vtadmin @notfelineit
/go/cmd/vtctldclient @mattlord
/go/cmd/vtctldclient/command/vreplication @mattlord @rohit-nayak-ps
/go/internal/flag @ajm188 @rohit-nayak-ps
/go/internal/flag @rohit-nayak-ps
/go/mysql @harshit-gangal @systay @mattlord
/go/pools @harshit-gangal
/go/protoutil @ajm188
/go/protoutil @deepthi @vmg
/go/sqltypes @harshit-gangal
/go/test/endtoend/onlineddl @shlomi-noach
/go/test/endtoend/messaging @mattlord @rohit-nayak-ps
Expand All @@ -34,49 +34,49 @@ bootstrap.sh @deepthi
/go/vt/discovery/*tablet_picker* @rohit-nayak-ps @mattlord
/go/vt/mysqlctl @deepthi @mattlord
/go/vt/proto @deepthi @harshit-gangal @mattlord
/go/vt/proto/vtadmin @ajm188 @notfelineit
/go/vt/proto/vtadmin @notfelineit
/go/vt/schema @shlomi-noach
/go/vt/servenv @deepthi @ajm188
/go/vt/servenv @deepthi @dbussink
/go/vt/sqlparser @harshit-gangal @systay @GuptaManan100
/go/vt/srvtopo @mattlord
/go/vt/sysvars @harshit-gangal @systay
/go/vt/topo @deepthi @mattlord
/go/vt/topotools @deepthi @mattlord
/go/vt/vitessdriver @harshit-gangal
/go/vt/vtadmin @ajm188 @notfelineit @rohit-nayak-ps
/go/vt/vtctl @deepthi
/go/vt/vtctl/vtctl.go @ajm188 @notfelineit
/go/vt/vtctl/grpcvtctldclient @ajm188 @notfelineit
/go/vt/vtctl/grpcvtctldserver @ajm188 @notfelineit
/go/vt/vtctl/reparentutil @ajm188 @GuptaManan100 @deepthi
/go/vt/vtctl/vtctldclient @ajm188 @notfelineit
/go/vt/vtctld @ajm188 @deepthi @notfelineit @rohit-nayak-ps
/go/vt/vtadmin @notfelineit @rohit-nayak-ps
/go/vt/vtctl @deepthi @rohit-nayak-ps @mattlord
/go/vt/vtctl/vtctl.go @notfelineit
/go/vt/vtctl/grpcvtctldclient @notfelineit
/go/vt/vtctl/grpcvtctldserver @notfelineit
/go/vt/vtctl/reparentutil @GuptaManan100
/go/vt/vtctl/vtctldclient @notfelineit
/go/vt/vtctld @deepthi @notfelineit @rohit-nayak-ps @mattlord
/go/vt/vterrors @harshit-gangal @systay
/go/vt/vtexplain @systay @harshit-gangal
/go/vt/vtgate @harshit-gangal @systay @frouioui @GuptaManan100
/go/vt/vtgate/insights* @piki @rafer
/go/vt/vtgate/endtoend/*vstream* @rohit-nayak-ps @mattlord
/go/vt/vtgate/planbuilder @harshit-gangal @systay @frouioui @GuptaManan100 @arthurschreiber
/go/vt/vtgate/planbuilder @harshit-gangal @systay @frouioui @GuptaManan100
/go/vt/vtgate/*vstream* @rohit-nayak-ps @mattlord
/go/vt/vtorc @deepthi @shlomi-noach @GuptaManan100
/go/vt/vttablet/*conn* @harshit-gangal @systay
/go/vt/vttablet/endtoend @harshit-gangal @mattlord @rohit-nayak-ps @systay
/go/vt/vttablet/grpc* @ajm188 @rohit-nayak-ps @shlomi-noach @harshit-gangal
/go/vt/vttablet/grpc* @rohit-nayak-ps @shlomi-noach @harshit-gangal
/go/vt/vttablet/onlineddl @mattlord @rohit-nayak-ps @shlomi-noach
/go/vt/vttablet/queryservice @harshit-gangal @systay
/go/vt/vttablet/tabletmanager @deepthi @GuptaManan100 @rohit-nayak-ps @shlomi-noach
/go/vt/vttablet/tabletmanager/vreplication @rohit-nayak-ps @mattlord
/go/vt/vttablet/tabletmanager/vstreamer @rohit-nayak-ps @mattlord
/go/vt/vttablet/tabletserver* @harshit-gangal @systay @shlomi-noach @rohit-nayak-ps
/go/vt/vttablet/tabletserver/messager @mattlord @rohit-nayak-ps
/go/vt/vttablet/*tmclient* @ajm188 @GuptaManan100 @rohit-nayak-ps @shlomi-noach
/go/vt/vttablet/*tmclient* @GuptaManan100 @rohit-nayak-ps @shlomi-noach
/go/vt/vttablet/vexec @mattlord @rohit-nayak-ps @shlomi-noach
/go/vt/wrangler @deepthi @mattlord @rohit-nayak-ps
/go/vt/workflow @mattlord @rohit-nayak-ps
/proto/ @deepthi @harshit-gangal
/proto/vtadmin.proto @ajm188 @notfelineit
/proto/vtctldata.proto @ajm188 @notfelineit
/proto/vtctlservice.proto @ajm188 @notfelineit
/proto/vtadmin.proto @notfelineit
/proto/vtctldata.proto @notfelineit @mattlord @rohit-nayak-ps
/proto/vtctlservice.proto @notfelineit @mattlord @rohit-nayak-ps
/test/ @GuptaManan100 @frouioui @rohit-nayak-ps
/tools/ @frouioui @rohit-nayak-ps
/web/vtadmin @ajm188 @notfelineit
/web/vtadmin @notfelineit @rohit-nayak-ps
94 changes: 94 additions & 0 deletions .github/workflows/update_golang_version_private.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Update Golang Version

on:
schedule:
- cron: "0 0 * * *" # Runs every day at midnight UTC
workflow_dispatch:

permissions: read-all

jobs:
update_golang_version:
if: github.repository == 'planetscale/vitess-private'
permissions:
contents: write
pull-requests: write
strategy:
matrix:
branch: [ upstream, latest-19.0, latest-18.0, latest-17.0, latest-16.0 ]
name: Update Golang Version
runs-on: ubuntu-latest
steps:
- name: Configure git private repo access
env:
GITHUB_TOKEN: ${{"{{"}} secrets.PLANETSCALE_ACTIONS_BOT_TOKEN {{"}}"}}
run: |
git config --global --add url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.2

- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: Detect new version and update codebase
env:
GH_TOKEN: ${{ secrets.PLANETSCALE_ACTIONS_BOT_TOKEN }}
id: detect-and-update
run: |
old_go_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get go-version)
echo "old-go-version=${old_go_version}" >> $GITHUB_OUTPUT
if [ ${{ matrix.branch }} == "main" ]; then
go run ./go/tools/go-upgrade/go-upgrade.go upgrade --workflow-update=false --main --allow-major-upgrade
else
go run ./go/tools/go-upgrade/go-upgrade.go upgrade --workflow-update=false
fi
output=$(git status -s)
if [ -z "${output}" ]; then
exit 0
fi
go_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get go-version)
bootstrap_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get bootstrap-version)
echo "go-version=${go_version}" >> $GITHUB_OUTPUT
echo "bootstrap-version=${bootstrap_version}" >> $GITHUB_OUTPUT
# Check if the PR already exists, if it does then do not create new PR.
gh pr list -S "is:open [${{ matrix.branch }}] Upgrade the Golang version to go${go_version}" > out.txt 2>&1 | true
if [ -s out.txt ]; then
rm -f out.txt
exit 0
fi
rm -f out.txt
echo "create-pr=true" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.detect-and-update.outputs.create-pr == 'true'
uses: peter-evans/create-pull-request@v4
with:
branch: "upgrade-go-to-${{steps.detect-and-update.outputs.go-version}}-on-${{ matrix.branch }}"
commit-message: "bump go version to go${{steps.detect-and-update.outputs.go-version}}"
signoff: true
delete-branch: true
title: "[${{ matrix.branch }}] Upgrade the Golang version to `go${{steps.detect-and-update.outputs.go-version}}`"
body: |
This Pull Request bumps the Golang version to `go${{steps.detect-and-update.outputs.go-version}}` and the bootstrap version to `${{steps.detect-and-update.outputs.bootstrap-version}}`.
> Do not trust the bot blindly. A thorough code review must be done to ensure all the files have been correctly modified.
There are a few manual steps remaining:
- [ ] Make sure you update the Golang version used in the previous and next release branches for the Upgrade/Downgrade tests.
- [ ] Update the `./.github/workflows/*.yml` files with the newer Golang version, the bot cannot handle that due to permissions.
- To accomplish this, run the following: `go run ./go/tools/go-upgrade/go-upgrade.go upgrade workflows --go-to=${{steps.detect-and-update.outputs.go-version}}`
base: ${{ matrix.branch }}
labels: |
Skip CI
go
Component: General
Type: CI/Build
Empty file added docker/CHANGELOG.md
Empty file.
7 changes: 2 additions & 5 deletions go/tools/go-upgrade/go-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func replaceGoVersionInCodebase(old, new *version.Version, workflowUpdate bool)
explore := []string{
"./test/templates",
"./build.env",
"./docker/bootstrap/Dockerfile.common",
"./docker/lite/Dockerfile.private",
}
if workflowUpdate {
explore = append(explore, "./.github/workflows")
Expand Down Expand Up @@ -433,8 +433,6 @@ func updateBootstrapVersionInCodebase(old, new string, newGoVersion *version.Ver
}
files, err := getListOfFilesInPaths([]string{
"./docker/lite",
"./docker/local",
"./docker/vttestserver",
"./Makefile",
"./test/templates",
})
Expand Down Expand Up @@ -472,12 +470,11 @@ func updateBootstrapVersionInCodebase(old, new string, newGoVersion *version.Ver
if err != nil {
return err
}

return nil
}

func updateBootstrapChangelog(new string, goVersion *version.Version) error {
file, err := os.OpenFile("./docker/bootstrap/CHANGELOG.md", os.O_RDWR, 0600)
file, err := os.OpenFile("./docker/CHANGELOG.md", os.O_RDWR, 0600)
if err != nil {
return err
}
Expand Down

0 comments on commit 57a554b

Please sign in to comment.