Skip to content

Commit

Permalink
fixed versioning in nucleus and synapse binaries (#189)
Browse files Browse the repository at this point in the history
* added support for versioning

* makefile formatting
  • Loading branch information
nevilm-lt authored Jun 9, 2022
1 parent 21b6bde commit 7216d42
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release-patch-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
tags: ${{ env.NUCLEUS_TAGS }}
file: build/nucleus/Dockerfile
push: true
build-args: |
VERSION=${{ steps.tag_version.outputs.new_tag }}
- name: Build and push Synapse images
uses: docker/[email protected]
Expand All @@ -67,3 +69,5 @@ jobs:
tags: ${{ env.SYNAPSE_TAGS }}
file: build/synapse/Dockerfile
push: true
build-args: |
VERSION=${{ steps.tag_version.outputs.new_tag }}
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ jobs:
tags: ${{ env.NUCLEUS_TAGS }}
file: build/nucleus/Dockerfile
push: true
build-args: |
VERSION=${{ steps.tag_version.outputs.new_tag }}
- name: Build and push Synapse images
uses: docker/[email protected]
Expand All @@ -118,3 +120,6 @@ jobs:
tags: ${{ env.SYNAPSE_TAGS }}
file: build/synapse/Dockerfile
push: true
build-args: |
VERSION=${{ steps.tag_version.outputs.new_tag }}
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ NUCLEUS_IMAGE_NAME ?= lambdatest/nucleus:latest
SYNAPSE_DOCKER_FILE ?= ./build/synapse/Dockerfile
SYNAPSE_IMAGE_NAME ?= lambdatest/synapse:latest

REV_LIST ?= $(shell git rev-list --tags --max-count=1)
VERSION ?= $(shell git describe --tags ${REV_LIST})

usage: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/:.*##\s*/##/g' | awk -F'##' '{ printf "%-25s -> %s\n", $$1, $$2 }'

lint: ## Runs linting
golangci-lint run

build-nucleus-image: ## Builds nucleus docker image
docker build -t ${NUCLEUS_IMAGE_NAME} --file $(NUCLEUS_DOCKER_FILE) .
docker build --build-arg VERSION=${VERSION}-dev -t ${NUCLEUS_IMAGE_NAME} --file $(NUCLEUS_DOCKER_FILE) .

build-nucleus-bin: ## Builds nucleus binary
bash build/nucleus/build.sh

build-synapse-image: ## Builds synapse docker image
docker build -t ${SYNAPSE_IMAGE_NAME} --file $(SYNAPSE_DOCKER_FILE) .
docker build --build-arg VERSION=${VERSION}-dev -t ${SYNAPSE_IMAGE_NAME} --file $(SYNAPSE_DOCKER_FILE) .

build-synapse-bin: ## Builds synapse binary
bash build/synapse/build.sh
bash build/synapse/build.sh
4 changes: 4 additions & 0 deletions build/nucleus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ RUN GOARCH=amd64 GOOS=linux go build -ldflags="-w -s" -o nucleus cmd/nucleus/*.g

# use a minimal alpine image
FROM nikolaik/python-nodejs:python3.10-nodejs16-slim

ARG VERSION
ENV VERSION=$VERSION

# Installing chromium so that all linux libs get automatically installed for running puppeteer tests
RUN apt update && apt install -y git zstd chromium curl

Expand Down
3 changes: 3 additions & 0 deletions build/synapse/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ RUN go build -o synapse cmd/synapse/*.go
# use a minimal alpine image
FROM docker:latest

ARG VERSION
ENV VERSION=$VERSION

# add ca-certificates in case you need them
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*

Expand Down
4 changes: 2 additions & 2 deletions cmd/nucleus/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func RootCommand() *cobra.Command {
rootCmd := cobra.Command{
Use: "nucleus",
Long: `nucleus is a coordinator binary used as entrypoint in tas containers`,
Version: global.NUCLEUS_BINARY_VERSION,
Version: global.NucleusBinaryVersion,
Run: run,
}

Expand Down Expand Up @@ -160,7 +160,7 @@ func run(cmd *cobra.Command, args []string) {
pl.CacheStore = cache
pl.SecretParser = secretParser

logger.Infof("LambdaTest Nucleus version: %s", global.NUCLEUS_BINARY_VERSION)
logger.Infof("LambdaTest Nucleus version: %s", global.NucleusBinaryVersion)

wg.Add(1)
go func() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/synapse/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func RootCommand() *cobra.Command {
rootCmd := cobra.Command{
Use: "synapse",
Long: `Synapse is an opensource runner for TAS`,
Version: global.SYNAPSE_BINARY_VERSION,
Version: global.SynapseBinaryVersion,
Run: run,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/synapse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// Main function just executes root command `ts`
// this project structure is inspired from `cobra` package
func main() {
log.Printf("Starting synapse %s", global.SYNAPSE_BINARY_VERSION)
log.Printf("Starting synapse %s", global.SynapseBinaryVersion)
if err := RootCommand().Execute(); err != nil {
log.Fatal(err)
}
Expand Down
12 changes: 7 additions & 5 deletions pkg/global/version.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package global

const (
// NUCLEUS_BINARY_VERSION Nucleus version
NUCLEUS_BINARY_VERSION = "0.0.1"
// SYNAPSE_BINARY_VERSION Synapse version
SYNAPSE_BINARY_VERSION = "0.0.1"
import "os"

var (
// NucleusBinaryVersion Nucleus version
NucleusBinaryVersion = os.Getenv("VERSION")
// SynapseBinaryVersion Synapse version
SynapseBinaryVersion = os.Getenv("VERSION")
)

0 comments on commit 7216d42

Please sign in to comment.