Skip to content

Commit

Permalink
Make Version Version Again (#271)
Browse files Browse the repository at this point in the history
Changes:
- add build date and sent it to the telemetry
- change `private-release.yml` workflow, docker tag is different than
version name now

<img width="528" alt="Screenshot 2024-06-05 at 17 11 01"
src="https://github.com/QuesmaOrg/quesma/assets/1474/2c2743a0-f4f7-4dfe-ba42-230555421b17">


Workflow works.  There is image build using it:

<img width="1350" alt="Screenshot 2024-06-05 at 17 13 30"
src="https://github.com/QuesmaOrg/quesma/assets/1474/d9448b13-3f72-4ffb-8b48-9f6a64679a6b">


Will alter production telemetry in another PR. 

@mieciu  Please take a look.

---------

Co-authored-by: Przemysław Hejman <[email protected]>
  • Loading branch information
nablaone and mieciu authored Jun 6, 2024
1 parent 2db4be4 commit f14217f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 12 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/private-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Build Quesma container image for customers and prospects (private beta rep
on:
workflow_dispatch:
inputs:
GIT_REF:
description: 'Commit hash to use for the release (can be a branch name or tag)'
RELEASE_TAG:
description: 'Tag to use for the release. This tag will be show as version in telemetry.'
required: true
VERSION_TAG:
description: 'Version tag for the released Docker image'
description: 'Version tag for the released Docker image. This tag will be used to pull the image.'
required: true
LICENSE_KEY:
description: 'License key - when empty, development key will be used'
Expand All @@ -23,7 +23,10 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.GIT_REF }}
ref: ${{ github.event.inputs.RELEASE_TAG }}

- name: Set build date
run: echo QUESMA_BUILD_DATE=$(git --no-pager log -1 --date=format:'%Y-%m-%d' --format="%ad") >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -43,6 +46,7 @@ jobs:
push: ${{ github.event_name == 'workflow_dispatch' }}
build-args: |
QUESMA_BUILD_SHA=${{ github.sha }}
QUESMA_VERSION=${{ github.event.inputs.VERSION_TAG }}
QUESMA_VERSION=${{ github.event.inputs.RELEASE_TAG }}
QUESMA_LICENSE_KEY=${{ github.event.inputs.LICENSE_KEY }}
QUESMA_BUILD_DATE=${{ env.QUESMA_BUILD_DATE }}
platforms: linux/amd64,linux/arm64
9 changes: 7 additions & 2 deletions bin/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ if [ ! -f "$QUESMA_COMPOSE_FILE" ]; then
fi

# Get the current git commit hash
QUESMA_VERSION=$(git rev-parse --short HEAD)
DOCKER_COMPOSE_BUILD_ARGS="--build-arg QUESMA_VERSION=$QUESMA_VERSION"
QUESMA_BUILD_DATE=$(git --no-pager log -1 --date=format:'%Y-%m-%d' --format="%ad")
QUESMA_VERSION=$(git describe)
QUESMA_BUILD_SHA=$(git rev-parse --short HEAD)




2 changes: 1 addition & 1 deletion bin/rebuild-attach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -e
cd "$(dirname "$0/")/.."
source bin/lib.sh

docker compose -f "$QUESMA_COMPOSE_FILE" build ${DOCKER_COMPOSE_BUILD_ARGS} quesma && \
docker compose -f "$QUESMA_COMPOSE_FILE" build "$QUESMA_COMPOSE_FILE" build --build-arg QUESMA_BUILD_DATE="$QUESMA_BUILD_DATE" --build-arg QUESMA_VERSION="$QUESMA_VERSION" --build-arg QUESMA_BUILD_SHA="$QUESMA_BUILD_SHA" quesma && \
docker compose -f "$QUESMA_COMPOSE_FILE" stop quesma && \
docker compose -f "$QUESMA_COMPOSE_FILE" up --no-deps quesma
2 changes: 1 addition & 1 deletion bin/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -e
cd "$(dirname "$0/")/.."
source bin/lib.sh

docker compose -f "$QUESMA_COMPOSE_FILE" build ${DOCKER_COMPOSE_BUILD_ARGS} quesma && \
docker compose -f "$QUESMA_COMPOSE_FILE" build "$QUESMA_COMPOSE_FILE" build --build-arg QUESMA_BUILD_DATE="$QUESMA_BUILD_DATE" --build-arg QUESMA_VERSION="$QUESMA_VERSION" --build-arg QUESMA_BUILD_SHA="$QUESMA_BUILD_SHA" quesma && \
docker compose -f "$QUESMA_COMPOSE_FILE" stop quesma && \
docker compose -f "$QUESMA_COMPOSE_FILE" up -d --no-deps quesma
2 changes: 1 addition & 1 deletion bin/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
cd "$(dirname "$0/")/.."
source bin/lib.sh

docker compose -f "$QUESMA_COMPOSE_FILE" build ${DOCKER_COMPOSE_BUILD_ARGS} && docker compose -f "$QUESMA_COMPOSE_FILE" up -d
docker compose -f "$QUESMA_COMPOSE_FILE" build --build-arg QUESMA_BUILD_DATE="$QUESMA_BUILD_DATE" --build-arg QUESMA_VERSION="$QUESMA_VERSION" --build-arg QUESMA_BUILD_SHA="$QUESMA_BUILD_SHA" && docker compose -f "$QUESMA_COMPOSE_FILE" up -d

cat <<"EOF"
________
Expand Down
1 change: 1 addition & 0 deletions docker/clean-clickhouse/schema/05-phone-home-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ CREATE TABLE IF NOT EXISTS "phone_home_data"
"config_mode" Nullable(String),
"top_errors" Array(String),
"build_hash" Nullable(String),
"build_date" Nullable(DateTime64(3)),
"number_of_failed_requests" Nullable(Int64),

)
Expand Down
4 changes: 4 additions & 0 deletions quesma/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ENV GOCACHE=/root/.cache/go-build
ARG QUESMA_BUILD_SHA
ARG QUESMA_VERSION
ARG QUESMA_LICENSE_KEY
ARG QUESMA_BUILD_DATE

COPY util/healthcheck util/healthcheck

Expand All @@ -31,6 +32,9 @@ RUN --mount=type=cache,target="/root/.cache/go-build" \
-X 'buildinfo.Version=$QUESMA_VERSION' \
-X 'mitmproxy/quesma/buildinfo.LicenseKey=$QUESMA_LICENSE_KEY' \
-X 'buildinfo.LicenseKey=$QUESMA_LICENSE_KEY' \
-X 'mitmproxy/quesma/buildinfo.BuildDate=$QUESMA_BUILD_DATE' \
-X 'buildinfo.BuildDate=$QUESMA_BUILD_DATE' \
" \
-o bin

Expand Down
1 change: 1 addition & 0 deletions quesma/buildinfo/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ const (

var Version = "development"
var BuildHash = ""
var BuildDate = ""
var LicenseKey = DevelopmentLicenseKey
4 changes: 2 additions & 2 deletions quesma/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const banner = `

func main() {
println(banner)
fmt.Printf("Quesma build info: version=[%s], build hash=[%s], license key=[%s]\n",
buildinfo.Version, buildinfo.BuildHash, config.MaskLicenseKey(buildinfo.LicenseKey))
fmt.Printf("Quesma build info: version=[%s], build hash=[%s], build date=[%s] license key=[%s]\n",
buildinfo.Version, buildinfo.BuildHash, buildinfo.BuildDate, config.MaskLicenseKey(buildinfo.LicenseKey))

sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
Expand Down
2 changes: 2 additions & 0 deletions quesma/telemetry/phone_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type PhoneHomeStats struct {
Hostname string `json:"hostname"`
QuesmaVersion string `json:"quesma_version"`
BuildHash string `json:"build_hash"`
BuildDate string `json:"build_date"`
InstanceID string `json:"instanceId"`

// add more stats here about running
Expand Down Expand Up @@ -470,6 +471,7 @@ func (a *agent) collect(ctx context.Context, reportType string) (stats PhoneHome
stats.TakenAt = time.Now().Unix()
stats.QuesmaVersion = buildinfo.Version
stats.BuildHash = buildinfo.BuildHash
stats.BuildDate = buildinfo.BuildDate
stats.NumberOfPanics = recovery.PanicCounter.Load()
stats.InstanceID = a.instanceId

Expand Down

0 comments on commit f14217f

Please sign in to comment.