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

Add the commit revision to binary/reports/docker #255

Merged
merged 4 commits into from
Jul 12, 2024
Merged
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
15 changes: 15 additions & 0 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Branch CI

on:
push:
branches-ignore:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
ruiAzevedo19 marked this conversation as resolved.
Show resolved Hide resolved

jobs:
docker:
name: 'Run docker image building'
uses: ./.github/workflows/docker.yml
bauersimon marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ jobs:
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
ruiAzevedo19 marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export ARGS
HAVE_CHANGED_FILES := ! git --no-pager diff --exit-code
HAVE_UNTRACKED_FILES := git ls-files --others --exclude-standard | grep .

export GIT_REVISION := $(shell git rev-parse --short HEAD)
export GO_LDFLAGS=-X $(PACKAGE_BASE)/evaluate.Revision=$(GIT_REVISION)

ifdef ARGS
HAS_ARGS := "1"
PACKAGE := $(ARGS)
Expand Down Expand Up @@ -41,7 +44,7 @@ help: # Show this help message.
.PHONY: help

install: # [<Go package] - # Build and install everything, or only the specified package.
go install -v $(PACKAGE)
go install -v -ldflags="$(GO_LDFLAGS)" $(PACKAGE)
.PHONY: install

install-all: install install-tools-testing # Install everything for and of this repository.
Expand Down
1 change: 1 addition & 0 deletions cmd/eval-dev-quality/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Command struct {
Evaluate `command:"evaluate" description:"Run an evaluation, by default with all defined models, repositories and tasks."`
InstallTools `command:"install-tools" description:"Checks and installs all tools required for the evaluation benchmark."`
Version `command:"version" description:"Display the version information of the binary."`
}

// Execute executes the root command.
Expand Down
6 changes: 4 additions & 2 deletions cmd/eval-dev-quality/cmd/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestExecute(t *testing.T) {

ExpectedOutput: bytesutil.StringTrimIndentations(`
Usage:
eval-dev-quality [OPTIONS] [evaluate | install-tools]
eval-dev-quality [OPTIONS] [evaluate | install-tools | version]

Command to manage, update and actually execute the ` + "`" + `eval-dev-quality` + "`" + `
evaluation benchmark.
Expand All @@ -47,6 +47,7 @@ func TestExecute(t *testing.T) {
Available commands:
evaluate Run an evaluation, by default with all defined models, repositories and tasks.
install-tools Checks and installs all tools required for the evaluation benchmark.
version Display the version information of the binary.
`),
})
} else {
Expand All @@ -55,7 +56,7 @@ func TestExecute(t *testing.T) {

ExpectedOutput: bytesutil.StringTrimIndentations(`
Usage:
eval-dev-quality [OPTIONS] [evaluate | install-tools]
eval-dev-quality [OPTIONS] [evaluate | install-tools | version]

Command to manage, update and actually execute the ` + "`" + `eval-dev-quality` + "`" + `
evaluation benchmark.
Expand All @@ -66,6 +67,7 @@ func TestExecute(t *testing.T) {
Available commands:
evaluate Run an evaluation, by default with all defined models, repositories and tasks.
install-tools Checks and installs all tools required for the evaluation benchmark.
version Display the version information of the binary.
`),
})
}
Expand Down
1 change: 1 addition & 0 deletions cmd/eval-dev-quality/cmd/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ func (command *Evaluate) evaluateLocal(evaluationContext *evaluate.Context) (err
if err := (report.Markdown{
DateTime: command.timestamp,
Version: evaluate.Version,
Revision: evaluate.Revision,

CSVPath: "./evaluation.csv",
LogPath: "./evaluation.log",
Expand Down
31 changes: 31 additions & 0 deletions cmd/eval-dev-quality/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"github.com/symflower/eval-dev-quality/evaluate"
"github.com/symflower/eval-dev-quality/log"
)

// Version defines the "version" command.
type Version struct {
// logger holds the logger of the command.
logger *log.Logger
}

var _ SetLogger = (*Version)(nil)

// SetLogger sets the logger of the command.
func (command *Version) SetLogger(logger *log.Logger) {
command.logger = logger
}

// Execute executes the command.
func (command *Version) Execute(args []string) (err error) {
revision := evaluate.Revision
if revision == "" {
revision = "development"
}
command.logger.SetFlags(0) // Remove the timestamp and everything from the log output while still being able to test it.
command.logger.Printf("eval-dev-quality version %s - revision %s", evaluate.Version, revision)

return nil
}
19 changes: 19 additions & 0 deletions cmd/eval-dev-quality/cmd/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
"github.com/symflower/eval-dev-quality/evaluate"
"github.com/symflower/eval-dev-quality/log"
)

func TestVersionExecute(t *testing.T) {
logOutput, logger := log.Buffer()

Execute(logger, []string{"version"})

expected := fmt.Sprintf("eval-dev-quality version %s - revision %s", evaluate.Version, "development")
assert.Contains(t, logOutput.String(), expected)
}
4 changes: 3 additions & 1 deletion evaluate/report/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Markdown struct {
DateTime time.Time
// Version holds the version of the evaluation tool.
Version string
// Revision holds the Git revision of the evaluation tool.
Revision string

// CSVPath holds the path of detailed CSV results.
CSVPath string
Expand Down Expand Up @@ -71,7 +73,7 @@ var markdownTemplate = template.Must(template.New("template-report").Parse(bytes

![Bar chart that categorizes all evaluated models.]({{.SVGPath}})

This report was generated by [DevQualityEval benchmark](https://github.com/symflower/eval-dev-quality) in ` + "`" + `version {{.Version}}` + "`" + `.
This report was generated by [DevQualityEval benchmark](https://github.com/symflower/eval-dev-quality) in ` + "`" + `version {{.Version}}` + "`" + ` - ` + "`" + `revision {{.Revision}}` + "`" + `.

## Results

Expand Down
6 changes: 4 additions & 2 deletions evaluate/report/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestMarkdownWriteToFile(t *testing.T) {
Markdown: Markdown{
DateTime: testTime,
Version: "1234",
Revision: "abcd",

CSVPath: "./file.csv",
LogPath: "./file.log",
Expand All @@ -74,7 +75,7 @@ func TestMarkdownWriteToFile(t *testing.T) {

![Bar chart that categorizes all evaluated models.](./file.svg)

This report was generated by [DevQualityEval benchmark](https://github.com/symflower/eval-dev-quality) in ` + "`" + `version 1234` + "`" + `.
This report was generated by [DevQualityEval benchmark](https://github.com/symflower/eval-dev-quality) in ` + "`" + `version 1234` + "`" + ` - ` + "`" + `revision abcd` + "`" + `.

## Results

Expand All @@ -101,6 +102,7 @@ func TestMarkdownWriteToFile(t *testing.T) {
Markdown: Markdown{
DateTime: testTime,
Version: "1234",
Revision: "abcd",

CSVPath: "./file.csv",
LogPath: "./file.log",
Expand All @@ -121,7 +123,7 @@ func TestMarkdownWriteToFile(t *testing.T) {

![Bar chart that categorizes all evaluated models.](./file.svg)

This report was generated by [DevQualityEval benchmark](https://github.com/symflower/eval-dev-quality) in ` + "`" + `version 1234` + "`" + `.
This report was generated by [DevQualityEval benchmark](https://github.com/symflower/eval-dev-quality) in ` + "`" + `version 1234` + "`" + ` - ` + "`" + `revision abcd` + "`" + `.

## Results

Expand Down
3 changes: 3 additions & 0 deletions evaluate/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ package evaluate

// Version holds the current version of the evaluation benchmark.
var Version = "0.5.0"

// Revision holds the Git revision of the current build.
var Revision string
Loading