Skip to content

Commit

Permalink
Revert "Promote git metadata functionality from experimental to stable"
Browse files Browse the repository at this point in the history
This reverts commit 2bcee53.
  • Loading branch information
jasonrudolph committed Jan 19, 2021
1 parent 2bcee53 commit f7de8f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
5 changes: 3 additions & 2 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ func (s *Submit) Init(args []string, envs map[string]string) error {

info, err = os.Stat(s.repositoryPath)
if err != nil || !info.IsDir() {
return fmt.Errorf("invalid value for flag -repository-dir: %s is not a directory", s.repositoryPath)
return fmt.Errorf("[experimental] invalid value for flag -repository-dir: %s is not a directory", s.repositoryPath)
}
s.commitResolver, err = metadata.NewCommitResolver(s.repositoryPath)
if err != nil {
return fmt.Errorf("invalid value for flag -repository-dir: %v", err)
// Git metadata functionality is experimental. While it's experimental, don't let an invalid repository prevent the test-reporter from continuing normal operation.
fmt.Fprintf(os.Stderr, "[experimental] invalid value for flag -repository-dir: %v\n", err)
}

s.envs = envs
Expand Down
1 change: 1 addition & 0 deletions cmd/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func TestSubmit_Init_invalidPath(t *testing.T) {

func TestSubmit_Init_invalidRepoPath(t *testing.T) {
t.Run("NonRepoPath", func(t *testing.T) {
t.Skip("skipping while git metadata functionality is experimental")
s := NewSubmit(&metadata.Version{})
err := s.Init([]string{
".",
Expand Down
31 changes: 22 additions & 9 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package metadata

import (
"fmt"
"os"
"regexp"
"strconv"
"strings"
Expand All @@ -25,29 +26,41 @@ type Metadata interface {
// AbstractMetadata provides the fields that are common across all Metadata
// instances, regardless of the specific CI provider.
type AbstractMetadata struct {
AuthoredAt time.Time `yaml:":authored_at"`
AuthorEmail string `yaml:":author_email"`
AuthorName string `yaml:":author_name"`
AuthoredAt time.Time `yaml:":authored_at,omitempty"`
AuthorEmail string `yaml:":author_email,omitempty"`
AuthorName string `yaml:":author_name,omitempty"`
Branch string `yaml:":branch"`
BuildURL string `yaml:":build_url"`
Check string `yaml:":check" env:"BUILDPULSE_CHECK_NAME"`
CIProvider string `yaml:":ci_provider"`
CommitMessage string `yaml:":commit_message"`
CommitMessage string `yaml:":commit_message,omitempty"`
CommitSHA string `yaml:":commit"`
CommittedAt time.Time `yaml:":committed_at"`
CommitterEmail string `yaml:":committer_email"`
CommitterName string `yaml:":committer_name"`
CommittedAt time.Time `yaml:":committed_at,omitempty"`
CommitterEmail string `yaml:":committer_email,omitempty"`
CommitterName string `yaml:":committer_name,omitempty"`
RepoNameWithOwner string `yaml:":repo_name_with_owner"`
ReporterOS string `yaml:":reporter_os"`
ReporterVersion string `yaml:":reporter_version"`
Timestamp time.Time `yaml:":timestamp"`
TreeSHA string `yaml:":tree"`
TreeSHA string `yaml:":tree,omitempty"`
}

func (a *AbstractMetadata) initCommitData(cr CommitResolver, sha string) error {
// Git metadata functionality is experimental. While it's experimental, detect a nil CommitResolver and allow the commit metadata fields to be uploaded with empty values.
if cr == nil {
fmt.Fprintf(os.Stderr, "[experimental] no commit resolver available; falling back to commit data from environment\n")

a.CommitSHA = sha
return nil
}

// Git metadata functionality is experimental. While it's experimental, don't let this error prevent the test-reporter from continuing normal operation. Allow the commit metadata fields to be uploaded with empty values.
c, err := cr.Lookup(sha)
if err != nil {
return err
fmt.Fprintf(os.Stderr, "[experimental] git-based commit lookup unsuccessful; falling back to commit data from environment: %v\n", err)

a.CommitSHA = sha
return nil
}

a.AuthoredAt = c.AuthoredAt
Expand Down

0 comments on commit f7de8f3

Please sign in to comment.