Skip to content

Commit

Permalink
fix_3811: send semver version in api/stattus/buildinfo for cloud depl…
Browse files Browse the repository at this point in the history
…oyments (#4110)

* fix(tools): fix github action

* fix(tools): use correct ref fr v4

* fix(tools): use correct ref

* fix(tools): fecth tags

* fix(tools): fetch tags

* fix(tools): use tag directly during build

* Revert "fix(tools): use tag directly during build"

This reverts commit 5cbd055.

* fix(tools): inject tag as version directly during build
  • Loading branch information
Aki0x137 authored Oct 9, 2024
1 parent 1de25ca commit 8c23c56
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## main / unreleased

* [ENHANCEMENT] Send semver version in api/stattus/buildinfo for cloud deployments [#4110](https://github.com/grafana/tempo/pull/4110) [@Aki0x137]
* [ENHANCEMENT] Speedup tempo-query trace search by allowing parallel queries [#4159](https://github.com/grafana/tempo/pull/4159) (@pavolloffay)
* [CHANGE] tempo-cli: add support for /api/v2/traces endpoint [#4127](https://github.com/grafana/tempo/pull/4127) (@electron0zero)
**BREAKING CHANGE** The `tempo-cli` now uses the `/api/v2/traces` endpoint by default,
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ help: ## Display this help
.DEFAULT_GOAL:=help

# Version number
VERSION=$(shell ./tools/image-tag | cut -d, -f 1)
VERSION=$(shell ./tools/version-tag.sh | cut -d, -f 1)

GIT_REVISION := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
Expand Down
6 changes: 6 additions & 0 deletions integration/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ func CallBuildinfo(t *testing.T, svc *e2e.HTTPService) {
_, ok := jsonResponse[key]
require.True(t, ok)
}

version, ok := jsonResponse["version"].(string)
require.True(t, ok)
semverRegex := `^v?(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-]+)*))?$`
require.Regexp(t, semverRegex, version)

defer res.Body.Close()
}

Expand Down
27 changes: 27 additions & 0 deletions tools/version-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT=$(git rev-parse --show-toplevel)

is_valid_semver() {
local version=$1
# regex taken from https://semver.org/
if [[ $version =~ ^v(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-]+)*))?$ ]] ;then
return 1
else
return 0
fi
}


VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)
if is_valid_semver "$VERSION"; then
echo "$VERSION"
exit 0
fi


source "${REPO_ROOT}/tools/image-tag"

0 comments on commit 8c23c56

Please sign in to comment.