Skip to content

Commit

Permalink
ci: add support for testing minimum Go version (#165)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cwaldren-ld authored Aug 19, 2024
1 parent 6704925 commit c0707a3
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/variables/go-versions.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
latest=1.22
penultimate=1.21
min=1.18
5 changes: 4 additions & 1 deletion .github/workflows/go-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand 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
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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/

Expand Down Expand Up @@ -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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
)

Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
3 changes: 2 additions & 1 deletion internal/broadcasters.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 3 additions & 2 deletions internal/endpoints/configure_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ldotel/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ldotel/tracing_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions testservice/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 => ../
15 changes: 6 additions & 9 deletions testservice/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand All @@ -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=

0 comments on commit c0707a3

Please sign in to comment.