Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement N-1 support policy for Go versions #4655

Merged
merged 9 commits into from
Sep 4, 2023
Merged

Implement N-1 support policy for Go versions #4655

merged 9 commits into from
Sep 4, 2023

Conversation

perhapsmaple
Copy link
Contributor

Which problem is this PR solving?

Resolves #4653

Description of the changes

  • Current files tracked are go.mod, all yml files in ./github/workflows/ and ./docker/Makefile. If there are any more build scripts to track, I would be happy to update the PR.
  • Added scripts/check-go-version.sh to verify that all our build scripts are using the same Go version N, but go.mod is N-1 and fail if not, with an error message and the source files along with their respective versions.
  • Added scripts/update-go-version.sh to update those scripts to latest version, to make these upgrades easier in the future. Also bumps go.mod to version N-1.
  • Updated README explaining the support policy.

How was this change tested?

  • I have tested the changes locally by modifying go versions
    Screenshot_20230813_120937
    Screenshot_20230813_121021

Checklist

- Fixes #4653. Implements linter check for go versions.
- Current files checked are all yml files in ./github/workflows/ and ./docker/Makefile.

Signed-off-by: Harish Shan <[email protected]>
…olicy

- Fixes #4653. Implements convenience script to update references of go version.
- Current files checked are all yml files in ./github/workflows/ and ./docker/Makefile.

Signed-off-by: Harish Shan <[email protected]>
Signed-off-by: Harish Shan <[email protected]>
@perhapsmaple perhapsmaple requested a review from a team as a code owner August 13, 2023 16:16
@perhapsmaple perhapsmaple changed the title Check go version Implement N-1 support policy for Go versions Aug 13, 2023
README.md Outdated

Starting with the release of Go 1.21, support for Go versions will be updated as follows:

1. The first release after the release of a new Go minor version `N` will add build and tests steps for the new Go minor version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to promise that such changes will be precisely in the "next release after Go release". Let's change to a bit more flexible phrasing like "soon after Go release"

go_mod_version=$(grep -oP "go\s+\K$version_regex+" $go_mod_path)

# Ensure go.mod uses go_latest_version - 1
if [ "${go_mod_version%.*}" != "${go_latest_version%.*}" ] || [ $((10#${go_latest_version#*.} - 10#${go_mod_version#*.})) != 1 ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is what we want. With this check the CI will start failing immediately after Go release, which is unfair to PR authors. My intention was that the script checks that all other build scripts are on some version N and the go.mod is on N-1, but N does not have to be latest. Latest can be printed, but not enforced. It should only be used in the update script.

@@ -0,0 +1,42 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has a large overlap with the check script, they need to be in sync regarding all the places they check. It would make sense to combine them into one and have an optional "update" behavior. Eg check script can take -u flag, and update script simply calls 'check -u'

- Moved all logic into ./scripts/check-go-version.sh with optional update flag
- check-go-version.sh does not enforce version N to be latest now
- Update script now calls ./scripts/check-go-version.sh -u
- Updated README

Signed-off-by: Harish Shan <[email protected]>
@perhapsmaple
Copy link
Contributor Author

Hi @yurishkuro , I have updated the scripts according. I'm wondering if the update script is required, since it just calls the check-go-version script with a flag.

README.md Outdated
Starting with the release of Go 1.21, support for Go versions will be updated as follows:

1. Soon after the release of a new Go minor version `N`, updates will be made to the build and tests steps to accommodate the latest Go minor version.
2. Soon after the release of a new Go minor version `N`, support for Go version `N-2` will be removed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Soon after the release of a new Go minor version `N`, support for Go version `N-2` will be removed.
2. Soon after the release of a new Go minor version `N`, support for Go version `N-2` will be removed and version `N-1` will become the minimum required version.


# If update, set go.mod version as latest version - 1 (N-1)
if [ "$update" = true ]; then
go_mod_updated="${go_latest_version%.*}.$((10#${go_latest_version#*.} - 1))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why double parentheses in the 2nd part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go_mod_updated is odd name, perhaps go_mod_desired

go_mod_path="./go.mod"
go_mod_version=$(grep -oP "go\s+\K$version_regex+" $go_mod_path)

# If update, set go.mod version as latest version - 1 (N-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a parameter so that the version can be specified in the command line instead of always being inferred from the latest?

if [ "$update" = true ]; then
if [ "${version_string##*: }" != "$go_latest_version" ]; then
updated_version="${version_string%%:*}: ${go_latest_version}"
sed -i "s/$version_string/$updated_version/g" "$build_script"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you know this will not update some other part of the file? E.g. some GH actions are included via hash, which could in theory match the string you're substituting

if [ "${go_alpine_version##*:}" != "$go_latest_version" ]; then
sed -i "s/${go_alpine_version}/golang:${go_latest_version}/" "$alpine_makefile_path"
{
printf "Build script: %-60s | Previous Go Version: %s | Updated Go Version: %s\n" "$alpine_makefile_path" "${go_alpine_version##*:}" "${go_latest_version}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make a function for this?

fi

# Ensure N-1 support policy
if [ "$update" != true ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not really making the code shorter, you still have completely independent code paths

@@ -0,0 +1,3 @@
#!/bin/bash

./scripts/check-go-version.sh -u
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine to drop this script

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Patch has no changes to coverable lines.

❗ Current head b26467e differs from pull request most recent head 14f368d. Consider uploading reports for the commit 14f368d to get more accurate results

📢 Thoughts on this report? Let us know!.

Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro yurishkuro merged commit fb8eb7d into jaegertracing:main Sep 4, 2023
27 of 28 checks passed
@yurishkuro
Copy link
Member

This did not fully resolve the ticket because there is no linter check, but let's first start with manual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement N-1 support policy for Go versions
2 participants