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

Emitting version metrics also adding a githook that runs a script the automatically updates the version unless the user manually skips #4994

Merged
merged 37 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7247a42
add version metric to buildinfo
allenchen2244 Sep 8, 2022
b99d000
Merge branch 'master' into CDNC-2846
davidporter-id-au Sep 28, 2022
692ce5f
Merge branch 'master' into CDNC-2846
davidporter-id-au Oct 4, 2022
63b07fa
add version
allenchen2244 Nov 1, 2022
e06692e
test
allenchen2244 Nov 1, 2022
fd7631f
Test
allenchen2244 Nov 1, 2022
75969ce
test
allenchen2244 Nov 1, 2022
3ba5d7d
test
allenchen2244 Nov 1, 2022
3fadb7a
add script
allenchen2244 Nov 1, 2022
68d9362
add script
allenchen2244 Nov 1, 2022
51e3ae3
test
allenchen2244 Nov 1, 2022
0c40db4
test
allenchen2244 Nov 1, 2022
bdcc4c5
test
allenchen2244 Nov 1, 2022
b43eb63
test
allenchen2244 Nov 1, 2022
5bad2e0
TEST MESSAGE
allenchen2244 Nov 1, 2022
424136e
updated
allenchen2244 Nov 1, 2022
b256197
SKIP VERSION
allenchen2244 Nov 1, 2022
5b45383
SKIP VERSION
allenchen2244 Nov 1, 2022
ad7741d
SKIP VERSION
allenchen2244 Nov 1, 2022
42bce5f
DFSDF SKIP VERSION
allenchen2244 Nov 1, 2022
eb561b8
add script SKIP VERSION
allenchen2244 Nov 1, 2022
518790d
update logs SKIP VERSION
allenchen2244 Nov 1, 2022
642af18
add copywrite SKIP VERSION
allenchen2244 Nov 1, 2022
359bade
fix SKIP VERSION
allenchen2244 Nov 1, 2022
066e94a
fix SKIP VERSION
allenchen2244 Nov 1, 2022
f9868a6
fix SKIP VERSION
allenchen2244 Nov 1, 2022
d407c5b
fix SKIP VERSION
allenchen2244 Nov 1, 2022
d9b8c16
Merge branch 'master' into CDNC-2846
allenchen2244 Nov 1, 2022
d909307
SKIP VERSION
allenchen2244 Nov 1, 2022
97d8308
Revert "SKIP VERSION"
allenchen2244 Nov 2, 2022
ca25e5a
fix SKIP VERSION
allenchen2244 Nov 2, 2022
5be0537
Revert "fix SKIP VERSION"
allenchen2244 Nov 2, 2022
7b04603
Revert "fix SKIP VERSION"
allenchen2244 Nov 2, 2022
d26acd6
SKIP VERSION
allenchen2244 Nov 2, 2022
98ddba9
test shit
allenchen2244 Nov 2, 2022
96763b2
Revert "test shit"
allenchen2244 Nov 2, 2022
7b46008
Merge branch 'master' into CDNC-2846
davidporter-id-au Nov 2, 2022
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
20 changes: 20 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

TEMPORARY_FILE_PATH=$1

COMMIT_MSG=`head -n1 $TEMPORARY_FILE_PATH`

if [[ $COMMIT_MSG =~ "SKIP VERSION" ]]; then
echo "Skipping version update or already updated"
exit 0
fi

echo "Updating Version"

./scripts/update-version.sh

git add common/metrics/version.go

echo "Commit again with the words SKIP VERSION in the commit message"

exit 1
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ You have a few options for choosing when to submit:

### Commit Messages And Titles of Pull Requests

We use githooks to enforce versions and some commit messages. Please run: `git config core.hooksPath .githooks
`. When committing the githook will automatically run a script to update an internal version number
that we. In order to skip include the string `SKIP VERSION` in your message. i.e `some message SKIP VERSION`.

Overcommit adds some requirements to your commit messages. At Uber, we follow the
[Chris Beams](http://chris.beams.io/posts/git-commit/) guide to writing git
commit messages. Read it, follow it, learn it, love it.
Expand Down
13 changes: 8 additions & 5 deletions common/metrics/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var (

// goVersion is the current runtime version.
goVersion = runtime.Version()
// cadenceVersion is the current version of cadence
cadenceVersion = VersionString
)

const (
Expand Down Expand Up @@ -99,11 +101,12 @@ func NewRuntimeMetricsReporter(
}
rReporter.buildInfoScope = scope.Tagged(
map[string]string{
revisionTag: Revision,
branchTag: Branch,
buildDateTag: BuildDate,
buildVersionTag: ReleaseVersion,
goVersionTag: goVersion,
revisionTag: Revision,
branchTag: Branch,
buildDateTag: BuildDate,
buildVersionTag: ReleaseVersion,
goVersionTag: goVersion,
cadenceVersionTag: cadenceVersion,
},
)
sec, err := strconv.ParseInt(BuildTimeUnix, base, bitSize)
Expand Down
11 changes: 6 additions & 5 deletions common/metrics/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import (
)

const (
revisionTag = "revision"
branchTag = "branch"
buildDateTag = "build_date"
buildVersionTag = "build_version"
goVersionTag = "go_version"
revisionTag = "revision"
branchTag = "branch"
buildDateTag = "build_date"
buildVersionTag = "build_version"
goVersionTag = "go_version"
cadenceVersionTag = "cadence_version"

instance = "instance"
domain = "domain"
Expand Down
28 changes: 28 additions & 0 deletions common/metrics/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// The MIT License (MIT)

// Copyright (c) 2017-2020 Uber Technologies Inc.

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package metrics

const MajorVersion = "0.25"

// VersionString this is updated via scripts/update-version.sh
const VersionString = "0.25.1667344608"
9 changes: 9 additions & 0 deletions scripts/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -e
cd "$(dirname $0)"

majorVersion="$(grep MajorVersion ../common/metrics/version.go | awk '{print $4}' | sed 's/"//g')"
versionString="$majorVersion.$(date +%s)"

goLiteral="const VersionString = \"$versionString\""

sed -i "" "s/^const VersionString = \".*\"$/$goLiteral/" ../common/metrics/version.go