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

fix_3811: send semver version in api/stattus/buildinfo for cloud deployments #4110

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow automatically updates VERSION file in repo if any change is pushed to main branch. It performs below steps:
# 1. Checks out the repo with depth 0 for full history.
# 2. Runs make command to update VERSION file with the latest tag
# 3. Commit and push updated VERSION file

name: Update VERSION File

on:
push:
branches:
- main

jobs:
update-version-file:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update VERSION file
run: make update-version

- name: Commit and push changes
run: |
if [ -n "$(git status --porcelain VERSION)" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ie-pham do you think this will work with our latest security changes to GHA?

i'll admit i'm not sure where the creds are that allow this to work?

git add VERSION
git commit -m "Update VERSION file to latest tag"
git push
else
echo "No changes to VERSION file."
fi
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## main / unreleased

* [ENHANCEMENT] Send semver version in api/stattus/buildinfo for cloud deployments [#4110](https://github.com/grafana/tempo/pull/4110) [@Aki0x137]
* [ENHANCEMENT] Speedup DistinctValue collector and exit early for ingesters [#4104](https://github.com/grafana/tempo/pull/4104) (@electron0zero)
* [ENHANCEMENT] Add disk caching in ingester SearchTagValuesV2 for completed blocks [#4069](https://github.com/grafana/tempo/pull/4069) (@electron0zero)
* [BUGFIX] Replace hedged requests roundtrips total with a counter. [#4063](https://github.com/grafana/tempo/pull/4063) [#4078](https://github.com/grafana/tempo/pull/4078) (@galalen)
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ help: ## Display this help

.DEFAULT_GOAL:=help

# Get the latest tag and store it in VERSION file
update-version:
@latest_tag=$$(git describe --tags `git rev-list --tags --max-count=1`); \
echo $$latest_tag > VERSION; \

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

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v2.6.0
5 changes: 5 additions & 0 deletions integration/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ func CallBuildinfo(t *testing.T, svc *e2e.HTTPService) {
_, ok := jsonResponse[key]
require.True(t, ok)
}

version, ok := jsonResponse["version"].(string)
require.True(t, ok)
require.Regexp(t, `^v?(\d+\.)?(\d+\.)?(\d+)$`, version)

defer res.Body.Close()
}

Expand Down
21 changes: 21 additions & 0 deletions tools/image-tag
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ 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
}

# Check if there is a VERSION file
if [ -f "${REPO_ROOT}/VERSION" ]; then
VERSION=$(cat "${REPO_ROOT}/VERSION" )
if is_valid_semver "$VERSION"; then
echo "$VERSION"
exit 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I believe that changing this script will update the version as expected b/c of this line:

https://github.com/grafana/tempo/blob/main/Makefile#L50

However I think it will also change the output of the script as used here:

https://github.com/grafana/tempo/blob/main/.drone/drone.yml#L12

which I'm pretty sure is how our docker images are tagged:

https://hub.docker.com/r/grafana/tempo/tags

@zalegrala do you know off the top of your head if this is how it works?

fi
fi

WIP=$(git diff --quiet || echo '-WIP')
BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's#/#-#g')
# When 7 chars are not enough to be unique, git automatically uses more.
Expand Down
Loading