Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

test_all: write index.json and add branch, commit and Go version to report

Nick Craig-Woode028c006fc8b
diff --git a/fstest/test_all/report.go b/fstest/test_all/report.go
index 3de70e900..8a4cdc94b 100644
--- a/fstest/test_all/report.go
+++ b/fstest/test_all/report.go
@@ -3,6 +3,7 @@
package main
import (
+ "encoding/json"
"fmt"
"html/template"
"io/ioutil"
@@ -10,6 +11,8 @@ import (
"os"
"os/exec"
"path"
+ "regexp"
+ "runtime"
"sort"
"time"
@@ -32,6 +35,11 @@ type Report struct {
Previous string // previous test name if known
IndexHTML string // path to the index.html file
URL string // online version
+ Branch string // rclone branch
+ Commit string // rclone commit
+ GOOS string // Go OS
+ GOARCH string // Go Arch
+ GoVersion string // Go Version
}
// ReportRun is used in the templates to report on a test run
@@ -40,11 +48,24 @@ type ReportRun struct {
Runs Runs
}
+// Parse version numbers
+// v1.49.0
+// v1.49.0-031-g2298834e-beta
+// v1.49.0-032-g20793a5f-sharefile-beta
+// match 1 is commit number
+// match 2 is branch name
+var parseVersion = regexp.MustCompile(`^v(?:[0-9.]+)-(?:\d+)-g([0-9a-f]+)(?:-(.*))?-beta$`)
+
+// FIXME take -issue or -pr parameter...
+
// NewReport initialises and returns a Report
func NewReport() *Report {
r := &Report{
StartTime: time.Now(),
Version: fs.Version,
+ GOOS: runtime.GOOS,
+ GOARCH: runtime.GOARCH,
+ GoVersion: runtime.Version(),
}
r.DateTime = r.StartTime.Format(timeFormat)
@@ -64,6 +85,16 @@ func NewReport() *Report {
// Online version
r.URL = *urlBase + r.DateTime + "/index.html"
+ // Get branch/commit out of version
+ parts := parseVersion.FindStringSubmatch(r.Version)
+ if len(parts) >= 3 {
+ r.Commit = parts[1]
+ r.Branch = parts[2]
+ }
+ if r.Branch == "" {
+ r.Branch = "master"
+ }
+
return r
}
@@ -116,6 +147,18 @@ func (r *Report) LogSummary() {
}
}
+// LogJSON writes the summary to index.json in LogDir
+func (r *Report) LogJSON() {
+ out, err := json.MarshalIndent(r, "", "\t")
+ if err != nil {
+ log.Fatalf("Failed to marshal data for index.json: %v", err)
+ }
+ err = ioutil.WriteFile(path.Join(r.LogDir, "index.json"), out, 0666)
+ if err != nil {
+ log.Fatalf("Failed to write index.json: %v", err)
+ }
+}
+
// LogHTML writes the summary to index.html in LogDir
func (r *Report) LogHTML() {
r.IndexHTML = path.Join(r.LogDir, "index.html")
@@ -195,6 +238,9 @@ a:focus {
<table>
<tr><th>Version</th><td>{{ .Version }}</td></tr>
<tr><th>Test</th><td><a href="{{ .URL }}">{{ .DateTime}}</a></td></tr>
+<tr><th>Branch</th><td><a href="https://github.com/rclone/rclone/tree/{{ .Branch }}">{{ .Branch }}</a></td></tr>
+{{ if .Commit}}<tr><th>Commit</th><td><a href="https://github.com/rclone/rclone/commit/{{ .Commit }}">{{ .Commit }}</a></td></tr>{{ end }}
+<tr><th>Go</th><td>{{ .GoVersion }} {{ .GOOS }}/{{ .GOARCH }}</td></tr>
<tr><th>Duration</th><td>{{ .Duration }}</td></tr>
{{ if .Previous}}<tr><th>Previous</th><td><a href="../{{ .Previous }}/index.html">{{ .Previous }}</a></td></tr>{{ end }}
<tr><th>Up</th><td><a href="../">Older Tests</a></td></tr>
diff --git a/fstest/test_all/test_all.go b/fstest/test_all/test_all.go
index e2ee6a31e..0d800572b 100644
--- a/fstest/test_all/test_all.go
+++ b/fstest/test_all/test_all.go
@@ -145,6 +145,7 @@ func main() {
// Log and exit
report.End()
report.LogSummary()
+ report.LogJSON()
report.LogHTML()
report.EmailHTML()
report.Upload()