From c338d8eb8a30e2b782cd7745aaba4737e2fd55d5 Mon Sep 17 00:00:00 2001 From: Rakshit Parashar <34675136+ChillOrb@users.noreply.github.com> Date: Tue, 9 May 2023 08:29:19 -0700 Subject: [PATCH] added version.go and test file for issue 2143 (#3677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added version.go and test file for issue 2143 * added license in metric versiont_test * goimport file linting * update trace version to v.1.13.0 and metric to 0.36.0 * Update sdk/metric/version.go Co-authored-by: Robert Pająk * using asser.Regxp * changing regex string as per recommendations Signed-off-by: ChillOrb * changing regex string as per recommendations Signed-off-by: ChillOrb * reverting go mod and go sum changes Signed-off-by: ChillOrb * trace and metric version bump up Signed-off-by: ChillOrb * version update in sdk/metric , sdk/trace Signed-off-by: ChillOrb * doc typo fix Signed-off-by: ChillOrb * Apply suggestions from code review --------- Signed-off-by: ChillOrb Co-authored-by: Chester Cheung Co-authored-by: Robert Pająk Co-authored-by: Tyler Yahn --- sdk/metric/version.go | 20 ++++++++++++++++++++ sdk/metric/version_test.go | 33 +++++++++++++++++++++++++++++++++ sdk/trace/version.go | 20 ++++++++++++++++++++ sdk/trace/version_test.go | 32 ++++++++++++++++++++++++++++++++ version_test.go | 9 +++++---- 5 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 sdk/metric/version.go create mode 100644 sdk/metric/version_test.go create mode 100644 sdk/trace/version.go create mode 100644 sdk/trace/version_test.go diff --git a/sdk/metric/version.go b/sdk/metric/version.go new file mode 100644 index 000000000..3a7c86dd0 --- /dev/null +++ b/sdk/metric/version.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package metric // import "go.opentelemetry.io/otel/sdk/metric" + +// version is the current release version of the metric SDK in use. +func version() string { + return "1.16.0-rc.1" +} diff --git a/sdk/metric/version_test.go b/sdk/metric/version_test.go new file mode 100644 index 000000000..34e00201e --- /dev/null +++ b/sdk/metric/version_test.go @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package metric + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" +) + +// regex taken from https://github.com/Masterminds/semver/tree/v3.1.1 +var versionRegex = regexp.MustCompile(`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)` + + `(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)` + + `(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?` + + `(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) + +func TestVersionSemver(t *testing.T) { + v := version() + assert.Regexp(t, versionRegex, v) +} diff --git a/sdk/trace/version.go b/sdk/trace/version.go new file mode 100644 index 000000000..d3457ed13 --- /dev/null +++ b/sdk/trace/version.go @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace // import "go.opentelemetry.io/otel/sdk/trace" + +// version is the current release version of the metric SDK in use. +func version() string { + return "1.16.0-rc.1" +} diff --git a/sdk/trace/version_test.go b/sdk/trace/version_test.go new file mode 100644 index 000000000..a973d4b69 --- /dev/null +++ b/sdk/trace/version_test.go @@ -0,0 +1,32 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trace + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" +) + +var versionRegex = regexp.MustCompile(`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)` + + `(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)` + + `(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?` + + `(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) + +func TestVersionSemver(t *testing.T) { + v := version() + assert.Regexp(t, versionRegex, v) +} diff --git a/version_test.go b/version_test.go index ce598d1f4..2ac174609 100644 --- a/version_test.go +++ b/version_test.go @@ -23,10 +23,11 @@ import ( "go.opentelemetry.io/otel" ) -// regex taken from https://github.com/Masterminds/semver/tree/v3.1.1 -var versionRegex = regexp.MustCompile(`^v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?` + - `(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` + - `(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?$`) +// regex taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string +var versionRegex = regexp.MustCompile(`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)` + + `(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)` + + `(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?` + + `(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) func TestVersionSemver(t *testing.T) { v := otel.Version()