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
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
Loading