Skip to content

Commit

Permalink
Implement N-1 support policy for Go versions (#4655)
Browse files Browse the repository at this point in the history
## 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](https://github.com/jaegertracing/jaeger/assets/140232061/bb4d9e18-22b5-4fcc-9c2b-d374bec0bc4a)

![Screenshot_20230813_121021](https://github.com/jaegertracing/jaeger/assets/140232061/602074bc-7285-48ee-97bf-ea5f0e21a586)

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Harish Shan <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2023
1 parent 730584f commit fb8eb7d
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ lint:
@[ ! -s "$(FMT_LOG)" -a ! -s "$(IMPORT_LOG)" ] || (echo "License check or import ordering failures, run 'make fmt'" | cat - $(FMT_LOG) $(IMPORT_LOG) && false)
./scripts/check-semconv-version.sh

./scripts/check-go-version.sh

.PHONY: build-examples
build-examples:
$(GOBUILD) -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ For example, consider a scenario where v1.28.0 is released on 01-Jun-2021 contai
This flag will remain in a deprecated state until the later of 01-Sep-2021 or v1.30.0 where it _can_ be removed on or after either of those events.
It may remain deprecated for longer than the aforementioned grace period.

## Go Version Compatibility Guarantees

The Jaeger project attempts to track the currently supported versions of Go, as [defined by the Go team](https://go.dev/doc/devel/release#policy).
Removing support for an unsupported Go version is not considered a breaking change.

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 and version `N-1` will become the minimum required version.

## Related Repositories

### Documentation
Expand Down
91 changes: 91 additions & 0 deletions scripts/check-go-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

version_regex='[0-9]\.[0-9][0-9]'
update=false
verbose=false

while getopts "uvd" opt; do
case $opt in
u) update=true ;;
v) verbose=true ;;
x) set -x ;;
*) echo "Usage: $0 [-u] [-v] [-d]" >&2
exit 1
;;
esac
done

# Fetch latest go release version
go_latest_version=$(curl -s https://go.dev/dl/?mode=json | jq -r '.[0].version' | awk -F'.' '{gsub("go", ""); print $1"."$2}')
go_previous_version="${go_latest_version%.*}.$((10#${go_latest_version#*.} - 1))"

files_to_update=0

function update() {
local file=$1
local pattern=$2
local current=$3
local target=$4

newfile=$(mktemp)
old_IFS=$IFS
IFS=''
while read -r line; do
match=$(echo $line | grep -e "$pattern")
if [[ "$match" != "" ]]; then
line=$(echo "$line" | sed "s/${current}/${target}/g")
fi
echo $line >> $newfile
done < $file
IFS=$old_IFS

if [ $verbose = true ]; then
diff $file $newfile
fi

mv $newfile $file
}

function check() {
local file=$1
local pattern=$2
local target=$3

go_version=$(grep -e "$pattern" $file | head -1 | sed "s/^.*\($version_regex\).*$/\1/")

if [ "$go_version" = "$target" ]; then
mismatch=''
else
mismatch='*** needs update ***'
files_to_update=$((files_to_update+1))
fi

if [[ $update = true && "$mismatch" != "" ]]; then
update "$file" "$pattern" "$go_version" "$target"
mismatch="*** => $target ***"
fi

printf "%-50s Go version: %s %s\n" "$file" "$go_version" "$mismatch"
}

check go.mod "^go\s\+$version_regex" $go_previous_version

check docker/Makefile "^.*golang:$version_regex" $go_latest_version

gha_workflows=$(grep -rl go-version .github)
for gha_workflow in ${gha_workflows[@]}; do
check $gha_workflow "^\s*go-version:\s\+$version_regex" $go_latest_version
done

check .golangci.yml "go:\s\+\"$version_regex\"" $go_previous_version

if [ $files_to_update -eq 0 ]; then
echo "All files are up to date."
else
if [[ $update = true ]]; then
echo "$files_to_update file(s) updated."
else
echo "$files_to_update file(s) must be updated. Rerun this script with -u argument."
exit 1
fi
fi

0 comments on commit fb8eb7d

Please sign in to comment.