diff --git a/cmd/hiveview/assets/lib/app-common.js b/cmd/hiveview/assets/lib/app-common.js index 4df5d67d55..8bdb2ccb6d 100644 --- a/cmd/hiveview/assets/lib/app-common.js +++ b/cmd/hiveview/assets/lib/app-common.js @@ -32,6 +32,11 @@ function hiveInfoHTML(data) { let link = makeLink(url, data.sourceCommit.substring(0, 8)); txt += 'commit: ' + link.outerHTML + ''; } + if (data.simulatorsVersion) { + let url = 'https://github.com/ethereum/hive/commits/' + escape(data.simulatorsVersion); + let link = makeLink(url, data.simulatorsVersion.substring(0, 8)); + txt += 'simulators: ' + link.outerHTML + ''; + } return txt; } diff --git a/hive.go b/hive.go index b6bda9a755..ba2f19eeb7 100644 --- a/hive.go +++ b/hive.go @@ -6,6 +6,7 @@ import ( "flag" "fmt" "os" + "os/exec" "os/signal" "regexp" "strings" @@ -114,6 +115,7 @@ func main() { SimRandomSeed: *simRandomSeed, SimDurationLimit: *simTimeLimit, ClientStartTimeout: *clientTimeout, + SimulatorsVersion: simulatorsVersion(), } runner := libhive.NewRunner(inv, builder, cb) @@ -189,3 +191,13 @@ func flagIsSet(name string) bool { }) return found } + +func simulatorsVersion() (commit *string) { + // Get the current folder's HEAD commit. + out, err := exec.Command("git", "rev-parse", "HEAD").Output() + if err != nil { + return nil + } + output := strings.TrimSpace(string(out[:])) + return &output +} diff --git a/internal/libhive/data.go b/internal/libhive/data.go index 95ee73d37b..63b2471d56 100644 --- a/internal/libhive/data.go +++ b/internal/libhive/data.go @@ -22,11 +22,12 @@ func (tsID TestID) String() string { // TestSuite is a single run of a simulator, a collection of testcases. type TestSuite struct { - ID TestSuiteID `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - ClientVersions map[string]string `json:"clientVersions"` - TestCases map[TestID]*TestCase `json:"testCases"` + ID TestSuiteID `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + ClientVersions map[string]string `json:"clientVersions"` + SimulatorsVersion *string `json:"simulatorsVersion,omitempty"` + TestCases map[TestID]*TestCase `json:"testCases"` SimulatorLog string `json:"simLog"` // path to simulator log-file simulator. (may be shared with multiple suites) TestDetailsLog string `json:"testDetailsLog"` // the test details output file @@ -74,9 +75,10 @@ type ClientInfo struct { // HiveInstance contains information about hive itself. type HiveInstance struct { - SourceCommit string `json:"sourceCommit"` - SourceDate string `json:"sourceDate"` - BuildDate string `json:"buildDate"` + SourceCommit string `json:"sourceCommit"` + SourceDate string `json:"sourceDate"` + BuildDate string `json:"buildDate"` + SimulatorsVersion *string `json:"simulatorsVersion,omitempty"` } // ClientDefinition is served by the /clients API endpoint to list the available clients diff --git a/internal/libhive/run.go b/internal/libhive/run.go index b01229642d..9992a95bc1 100644 --- a/internal/libhive/run.go +++ b/internal/libhive/run.go @@ -104,7 +104,7 @@ func (r *Runner) Run(ctx context.Context, sim string, env SimEnv) (SimResult, er if err := createWorkspace(env.LogDir); err != nil { return SimResult{}, err } - writeInstanceInfo(env.LogDir) + writeInstanceInfo(env.LogDir, env.SimulatorsVersion) return r.run(ctx, sim, env) } @@ -303,9 +303,10 @@ func createWorkspace(logdir string) error { return nil } -func writeInstanceInfo(logdir string) { +func writeInstanceInfo(logdir string, simulatorsVersion *string) { var obj HiveInstance obj.SourceCommit, obj.SourceDate = hiveVersion() + obj.SimulatorsVersion = simulatorsVersion buildDate := hiveBuildTime() if !buildDate.IsZero() { obj.BuildDate = buildDate.Format("2006-01-02T15:04:05Z") diff --git a/internal/libhive/testmanager.go b/internal/libhive/testmanager.go index fe7bc6a0cf..e7a0e84a0e 100644 --- a/internal/libhive/testmanager.go +++ b/internal/libhive/testmanager.go @@ -48,6 +48,9 @@ type SimEnv struct { // This configures the amount of time the simulation waits // for the client to open port 8545 after launching the container. ClientStartTimeout time.Duration + + // Information about the simulators to put in the results. + SimulatorsVersion *string } // SimResult summarizes the results of a simulation run. @@ -395,14 +398,15 @@ func (manager *TestManager) StartTestSuite(name string, description string) (Tes } manager.runningTestSuites[newSuiteID] = &TestSuite{ - ID: newSuiteID, - Name: name, - Description: description, - ClientVersions: make(map[string]string), - TestCases: make(map[TestID]*TestCase), - SimulatorLog: manager.simLogFile, - TestDetailsLog: testLogPath, - testDetailsFile: testLogFile, + ID: newSuiteID, + Name: name, + Description: description, + ClientVersions: make(map[string]string), + TestCases: make(map[TestID]*TestCase), + SimulatorLog: manager.simLogFile, + SimulatorsVersion: manager.config.SimulatorsVersion, + TestDetailsLog: testLogPath, + testDetailsFile: testLogFile, } manager.testSuiteCounter++ return newSuiteID, nil