-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from openconfig/master-push-fix
Be resilient to PR-only flags that don't exist during pushes to master
- Loading branch information
Showing
2 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,26 +22,28 @@ import ( | |
"os" | ||
"path/filepath" | ||
"sort" | ||
"strconv" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/openconfig/models-ci/commonci" | ||
) | ||
|
||
var ( | ||
// Commandline flags | ||
// Commandline flags: should be string if it may not exist | ||
modelRoot string // modelRoot is the root directory of the models. | ||
repoSlug string // repoSlug is the "owner/repo" name of the models repo (e.g. openconfig/public). | ||
commitSHA string | ||
branchName string // branchName is the name of the branch where the commit occurred. | ||
prNumber int | ||
prNumberStr string // prNumberStr is the PR number. | ||
compatReports string // e.g. "goyang-ygot,pyangbind,[email protected]" | ||
extraPyangVersions string // e.g. "1.2.3,3.4.5" | ||
skippedValidators string // e.g. "yanglint,pyang@head" | ||
|
||
// Derived flags (for ease of use) | ||
owner string | ||
repo string | ||
owner string | ||
repo string | ||
prNumber int | ||
|
||
// local run flags | ||
local bool // local run toggle | ||
|
@@ -68,7 +70,7 @@ func init() { | |
flag.StringVar(&modelRoot, "modelRoot", "", "root directory to OpenConfig models") | ||
flag.StringVar(&repoSlug, "repo-slug", "openconfig/public", "repo where CI is run") | ||
flag.StringVar(&commitSHA, "commit-sha", "", "commit SHA of the PR") | ||
flag.IntVar(&prNumber, "pr-number", 0, "PR number") | ||
flag.StringVar(&prNumberStr, "pr-number", "", "PR number") | ||
flag.StringVar(&branchName, "branch", "", "branch name of commit") | ||
flag.StringVar(&compatReports, "compat-report", "", "comma-separated validators (e.g. goyang-ygot,[email protected],pyang@head) in compatibility report instead of a standalone PR status") | ||
flag.StringVar(&skippedValidators, "skipped-validators", "", "comma-separated validators (e.g. goyang-ygot,[email protected],pyang@head) not to be ran at all, not even in the compatibility report") | ||
|
@@ -305,6 +307,13 @@ func main() { | |
log.Fatalf("modelDirName and validator can only be specified for local cmd generation") | ||
} | ||
|
||
if prNumberStr != "" { | ||
var err error | ||
if prNumber, err = strconv.Atoi(prNumberStr); err != nil { | ||
log.Fatalf("error encountered while parsing PR number: %s", err) | ||
} | ||
} | ||
|
||
badgeOnly := false | ||
// If it's a push on master, just upload badge for normal validators as the only action. | ||
if prNumber == 0 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters