From c0707a3c9eaab854815062f0d817b97b2b654edd Mon Sep 17 00:00:00 2001 From: Casey Waldren Date: Mon, 19 Aug 2024 09:59:53 -0700 Subject: [PATCH] ci: add support for testing minimum Go version (#165) This PR relaxes the minimum compiler version to 1.18, as the only new feature we were using was the standard library `slices` package. This can be replaced with `x/exp/slices`. To test the minimum version, I've added a new key/value to `go-versions.env`. This version is now tested in CI, and can be easily bumped using `make bump-min-go-version MIN_GO_VERSION=foo`. Finally, I've updated our documentation to clarify our support policy. --- .github/variables/go-versions.env | 1 + .github/workflows/go-versions.yml | 5 ++++- CONTRIBUTING.md | 13 +++++++++++++ Makefile | 10 ++++++++-- README.md | 11 ++++++++--- go.mod | 6 +++--- go.sum | 4 ++++ internal/broadcasters.go | 3 ++- internal/endpoints/configure_endpoints_test.go | 5 +++-- ldotel/go.mod | 2 +- ldotel/tracing_hook_test.go | 2 +- testservice/go.mod | 8 ++++---- testservice/go.sum | 15 ++++++--------- 13 files changed, 58 insertions(+), 27 deletions(-) diff --git a/.github/variables/go-versions.env b/.github/variables/go-versions.env index b985fc94..07573b20 100644 --- a/.github/variables/go-versions.env +++ b/.github/variables/go-versions.env @@ -1,2 +1,3 @@ latest=1.22 penultimate=1.21 +min=1.18 diff --git a/.github/workflows/go-versions.yml b/.github/workflows/go-versions.yml index 7bb5c99f..86090dbd 100644 --- a/.github/workflows/go-versions.yml +++ b/.github/workflows/go-versions.yml @@ -27,6 +27,9 @@ on: penultimate: description: 'The second most recent Go version to test' value: ${{ jobs.go-versions.outputs.penultimate }} + min: + description: 'The minimum Go version to test' + value: ${{ jobs.go-versions.outputs.min }} matrix: description: 'All Go versions to test as a matrix' value: ${{ jobs.go-versions.outputs.all }} @@ -46,4 +49,4 @@ jobs: - name: Set Go Version Matrices id: set-matrix run: | - echo "all=[\"${{ steps.set-env.outputs.latest }}\",\"${{ steps.set-env.outputs.penultimate }}\"]" >> $GITHUB_OUTPUT + echo "all=[\"${{ steps.set-env.outputs.latest }}\",\"${{ steps.set-env.outputs.penultimate }}\",\"${{ steps.set-env.outputs.min }}\"]" >> $GITHUB_OUTPUT diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37c3ccd8..8fba2168 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,19 @@ We encourage pull requests and other contributions from the community. Before su This project should be built against the lowest supported Go version as described in [README.md](./README.md). +### Bumping the Minimum Go Version + +The SDK is tested against three Go versions: the latest, penultimate, and a minimum based on the SDKs usage of Go features. + +Whereas the latest and penultimate are updates on a regular cadence to track upstream Go releases, the minimum version +may be bumped at the discretion of the SDK maintainers to take advantage of new features. + +Invoke the following make command, which will update `go.mod`, `ldotel/go.mod`, `testservice/go.mod`, and +`.github/variables/go-versions.env` (pass the desired Go version): +```shell +make bump-min-go-version MIN_GO_VERSION=1.18 +``` + ### Building To build all modules without running any tests: diff --git a/Makefile b/Makefile index f9a52d31..4ad8c441 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -GOLANGCI_LINT_VERSION=v1.57.1 +GOLANGCI_LINT_VERSION=v1.60.1 LINTER=./bin/golangci-lint LINTER_VERSION_FILE=./bin/.golangci-lint-version-$(GOLANGCI_LINT_VERSION) @@ -33,6 +33,12 @@ all: $(ALL_BUILD_TARGETS) test: $(ALL_TEST_TARGETS) +bump-min-go-version: + go mod edit -go=$(MIN_GO_VERSION) go.mod + cd ldotel && go mod edit -go=$(MIN_GO_VERSION) go.mod + cd testservice && go mod edit -go=$(MIN_GO_VERSION) go.mod + cd ./.github/variables && sed -i.bak "s#min=[^ ]*#min=$(MIN_GO_VERSION)#g" go-versions.env && rm go-versions.env.bak + clean: workspace-clean rm -rf ./bin/ @@ -143,4 +149,4 @@ run-contract-tests: contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests -.PHONY: build-contract-tests start-contract-test-service start-contract-test-service-bg run-contract-tests contract-tests +.PHONY: build-contract-tests start-contract-test-service start-contract-test-service-bg run-contract-tests contract-tests bump-min-go-version diff --git a/README.md b/README.md index 61afcd1f..c641dedc 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,15 @@ ## Supported Go versions -This version of the LaunchDarkly SDK supports Go version 1.21 or higher. +The SDK supports the 'latest' and 'penultimate' Go versions defined in [this file](./.github/variables/go-versions.env). -The policy for this SDK follows that of the official Go [Release Policy](https://go.dev/doc/devel/release): each major Go release is supported until there -are two newer major releases. +LaunchDarkly intends to keep those versions up-to-date with the Go project's latest two releases, which represents a support +period of roughly 1 year. This policy is intended to match Go's official [Release Policy](https://go.dev/doc/devel/release): +each major Go release is supported until there are two newer major releases. + +Additionally, a 'minimum' version is tested in CI but not officially supported. This minimum version is found in [go.mod](./go.mod). +This version may be [bumped](./CONTRIBUTING.md#bumping-the-minimum-go-version) from time to time as new Go features +become available that are useful to the SDK. ## Getting started diff --git a/go.mod b/go.mod index e629a98e..5af46f42 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/launchdarkly/go-server-sdk/v7 -go 1.21 +go 1.18 require ( github.com/fsnotify/fsnotify v1.4.7 @@ -15,8 +15,8 @@ require ( github.com/launchdarkly/go-test-helpers/v3 v3.0.2 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/stretchr/testify v1.7.0 - golang.org/x/exp v0.0.0-20220823124025-807a23277127 - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa + golang.org/x/sync v0.8.0 gopkg.in/ghodss/yaml.v1 v1.0.0 ) diff --git a/go.sum b/go.sum index 353ef967..93336efd 100644 --- a/go.sum +++ b/go.sum @@ -59,9 +59,13 @@ golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20220823124025-807a23277127 h1:S4NrSKDfihhl3+4jSTgwoIevKxX9p7Iv9x++OEIptDo= golang.org/x/exp v0.0.0-20220823124025-807a23277127/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= diff --git a/internal/broadcasters.go b/internal/broadcasters.go index 5b902d12..140ce8de 100644 --- a/internal/broadcasters.go +++ b/internal/broadcasters.go @@ -1,8 +1,9 @@ package internal import ( - "slices" "sync" + + "golang.org/x/exp/slices" ) // This file defines the publish-subscribe model we use for various status/event types in the SDK. diff --git a/internal/endpoints/configure_endpoints_test.go b/internal/endpoints/configure_endpoints_test.go index d0a472fb..58af9564 100644 --- a/internal/endpoints/configure_endpoints_test.go +++ b/internal/endpoints/configure_endpoints_test.go @@ -2,12 +2,13 @@ package endpoints import ( "fmt" + "strings" + "testing" + "github.com/launchdarkly/go-sdk-common/v3/ldlog" "github.com/launchdarkly/go-sdk-common/v3/ldlogtest" "github.com/launchdarkly/go-server-sdk/v7/interfaces" "github.com/stretchr/testify/assert" - "strings" - "testing" ) func TestDefaultURISelectedIfNoCustomURISpecified(t *testing.T) { diff --git a/ldotel/go.mod b/ldotel/go.mod index 50333bc1..e8e56de8 100644 --- a/ldotel/go.mod +++ b/ldotel/go.mod @@ -1,6 +1,6 @@ module github.com/launchdarkly/go-server-sdk/ldotel -go 1.21 +go 1.18 require ( github.com/launchdarkly/go-sdk-common/v3 v3.1.0 diff --git a/ldotel/tracing_hook_test.go b/ldotel/tracing_hook_test.go index 13ab2aef..23f59571 100644 --- a/ldotel/tracing_hook_test.go +++ b/ldotel/tracing_hook_test.go @@ -11,8 +11,8 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/sdk/trace" + "go.opentelemetry.io/otel/sdk/trace/tracetest" ) -import "go.opentelemetry.io/otel/sdk/trace/tracetest" func configureMemoryExporter() *tracetest.InMemoryExporter { exporter := tracetest.NewInMemoryExporter() diff --git a/testservice/go.mod b/testservice/go.mod index e4bbbf81..058b9e62 100644 --- a/testservice/go.mod +++ b/testservice/go.mod @@ -1,6 +1,6 @@ module github.com/launchdarkly/go-server-sdk/v7/testservice -go 1.21 +go 1.18 require ( github.com/gorilla/mux v1.8.0 @@ -15,14 +15,14 @@ require ( github.com/launchdarkly/ccache v1.1.0 // indirect github.com/launchdarkly/eventsource v1.6.2 // indirect github.com/launchdarkly/go-jsonstream/v3 v3.0.0 // indirect - github.com/launchdarkly/go-sdk-events/v3 v3.2.0 // indirect + github.com/launchdarkly/go-sdk-events/v3 v3.4.0 // indirect github.com/launchdarkly/go-semver v1.0.2 // indirect github.com/launchdarkly/go-server-sdk-evaluation/v3 v3.0.0 // indirect github.com/launchdarkly/go-test-helpers/v2 v2.3.1 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect - golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect + golang.org/x/sync v0.8.0 // indirect ) replace github.com/launchdarkly/go-server-sdk/v7 => ../ diff --git a/testservice/go.sum b/testservice/go.sum index 8dfcc99e..d04690eb 100644 --- a/testservice/go.sum +++ b/testservice/go.sum @@ -19,8 +19,8 @@ github.com/launchdarkly/go-jsonstream/v3 v3.0.0 h1:qJF/WI09EUJ7kSpmP5d1Rhc81NQdY github.com/launchdarkly/go-jsonstream/v3 v3.0.0/go.mod h1:/1Gyml6fnD309JOvunOSfyysWbZ/ZzcA120gF/cQtC4= github.com/launchdarkly/go-sdk-common/v3 v3.1.0 h1:KNCP5rfkOt/25oxGLAVgaU1BgrZnzH9Y/3Z6I8bMwDg= github.com/launchdarkly/go-sdk-common/v3 v3.1.0/go.mod h1:mXFmDGEh4ydK3QilRhrAyKuf9v44VZQWnINyhqbbOd0= -github.com/launchdarkly/go-sdk-events/v3 v3.2.0 h1:FUby/4cUSVDghCkFDpvy+7vZlIW4+CK95HjQnuqGXVs= -github.com/launchdarkly/go-sdk-events/v3 v3.2.0/go.mod h1:oepYWQ2RvvjfL2WxkE1uJJIuRsIMOP4WIVgUpXRPcNI= +github.com/launchdarkly/go-sdk-events/v3 v3.4.0 h1:22sVSEDEXpdOEK3UBtmThwsUHqc+cbbe/pJfsliBAA4= +github.com/launchdarkly/go-sdk-events/v3 v3.4.0/go.mod h1:oepYWQ2RvvjfL2WxkE1uJJIuRsIMOP4WIVgUpXRPcNI= github.com/launchdarkly/go-semver v1.0.2 h1:sYVRnuKyvxlmQCnCUyDkAhtmzSFRoX6rG2Xa21Mhg+w= github.com/launchdarkly/go-semver v1.0.2/go.mod h1:xFmMwXba5Mb+3h72Z+VeSs9ahCvKo2QFUTHRNHVqR28= github.com/launchdarkly/go-server-sdk-evaluation/v3 v3.0.0 h1:nQbR1xCpkdU9Z71FI28bWTi5LrmtSVURy0UFcBVD5ZU= @@ -29,7 +29,6 @@ github.com/launchdarkly/go-test-helpers/v2 v2.2.0/go.mod h1:L7+th5govYp5oKU9iN7T github.com/launchdarkly/go-test-helpers/v2 v2.3.1 h1:KXUAQVTeHNcWVDVQ94uEkybI+URXI9rEd7E553EsZFw= github.com/launchdarkly/go-test-helpers/v2 v2.3.1/go.mod h1:L7+th5govYp5oKU9iN7To5PgznBuIjBPn+ejqKR0avw= github.com/launchdarkly/go-test-helpers/v3 v3.0.2 h1:rh0085g1rVJM5qIukdaQ8z1XTWZztbJ49vRZuveqiuU= -github.com/launchdarkly/go-test-helpers/v3 v3.0.2/go.mod h1:u2ZvJlc/DDJTFrshWW50tWMZHLVYXofuSHUfTU/eIwM= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= @@ -41,16 +40,14 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 h1:3UeQBvD0TFrlVjOeLOBz+CPAI8dnbqNSVwUwRrkp7vQ= github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0/go.mod h1:IXCdmsXIht47RaVFLEdVnh1t+pgYtTAhQGj73kz+2DM= -golang.org/x/exp v0.0.0-20220823124025-807a23277127 h1:S4NrSKDfihhl3+4jSTgwoIevKxX9p7Iv9x++OEIptDo= -golang.org/x/exp v0.0.0-20220823124025-807a23277127/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=