From cb83f69c031f22cca2b049b7780b035bbf5dfb1e Mon Sep 17 00:00:00 2001 From: wenovus Date: Tue, 30 Jun 2020 16:38:22 -0700 Subject: [PATCH 1/7] Convert validators to recognize posix-pattern instead of pattern statements --- .../testdata/openconfig-extensions.yang | 18 ++++++++++++++++++ validators/oc-pyang/test.sh | 3 ++- .../go/src/gotests/regexp/regexp_test.go | 6 +++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/validators/misc-checks/ocversion/testdata/openconfig-extensions.yang b/validators/misc-checks/ocversion/testdata/openconfig-extensions.yang index 5fe060f..0ab7560 100644 --- a/validators/misc-checks/ocversion/testdata/openconfig-extensions.yang +++ b/validators/misc-checks/ocversion/testdata/openconfig-extensions.yang @@ -105,6 +105,24 @@ module openconfig-extensions { specified by RFC6020 and RFC7950."; } + extension posix-pattern { + argument "pattern" { + yin-element false; + } + description + "Provides a POSIX ERE regular expression pattern statement as an + alternative to YANG regular expresssions based on XML Schema Datatypes. + It is used the same way as the standard YANG pattern statement defined in + RFC6020 and RFC7950, but takes an argument that is a POSIX ERE regular + expression string. + + If present, any posix-pattern statement should have a corresponding + pattern statement that provides equivalent behavior."; + reference + "POSIX Extended Regular Expressions (ERE) Specification: + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04"; + } + extension telemetry-on-change { description "The telemetry-on-change annotation is specified in the context diff --git a/validators/oc-pyang/test.sh b/validators/oc-pyang/test.sh index 1131788..88c87e5 100755 --- a/validators/oc-pyang/test.sh +++ b/validators/oc-pyang/test.sh @@ -19,7 +19,8 @@ setup() { virtualenv $VENVDIR source $VENVDIR/bin/activate - git clone https://github.com/openconfig/oc-pyang $OCPYANG_REPO + # FIXME(wenbli): remove branch statement. + git clone -b posix-pattern-existence-check https://github.com/openconfig/oc-pyang $OCPYANG_REPO pip3 install --no-cache-dir -r $OCPYANG_DIR/requirements.txt pip3 install enum34 pip3 install jinja2 diff --git a/validators/regexp/go/src/gotests/regexp/regexp_test.go b/validators/regexp/go/src/gotests/regexp/regexp_test.go index 19137cc..e8796b5 100644 --- a/validators/regexp/go/src/gotests/regexp/regexp_test.go +++ b/validators/regexp/go/src/gotests/regexp/regexp_test.go @@ -195,18 +195,18 @@ func TestRegexps(t *testing.T) { for _, tc := range tt.testData { var gotMatch bool if len(leaf.Type.Type) == 0 { - _, gotMatch = checkPattern(tc.inData, leaf.Type.Pattern) + _, gotMatch = checkPattern(tc.inData, leaf.Type.POSIXPattern) } else { // Handle unions results := make([]bool, 0) for _, membertype := range leaf.Type.Type { // Only do the test when there is a pattern specified against the // type as it may not be a string. - if membertype.Kind != yang.Ystring || len(membertype.Pattern) == 0 { + if membertype.Kind != yang.Ystring || len(membertype.POSIXPattern) == 0 { continue } matchedAllForType := true - _, matchedAllForType = checkPattern(tc.inData, membertype.Pattern) + _, matchedAllForType = checkPattern(tc.inData, membertype.POSIXPattern) results = append(results, matchedAllForType) } From bf80a9cb5b95ca1da9d368d524f8bd3596d41e77 Mon Sep 17 00:00:00 2001 From: wenovus Date: Fri, 17 Jul 2020 10:18:49 -0700 Subject: [PATCH 2/7] Fix test name --- cmd_gen/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd_gen/main_test.go b/cmd_gen/main_test.go index 2d6cc42..650c5d0 100644 --- a/cmd_gen/main_test.go +++ b/cmd_gen/main_test.go @@ -32,7 +32,7 @@ func (p *postLabelRecorder) PostLabel(labelName, labelColor, owner, repo string, return nil } -func TestGenOpenConfigLinterScript(t *testing.T) { +func TestGenOpenConfigValidatorScript(t *testing.T) { prNumber = 1 basicModelMap, err := commonci.ParseOCModels("testdata") if err != nil { From b64773905af020c8f21729bd2951345fb345de26 Mon Sep 17 00:00:00 2001 From: wenovus Date: Tue, 21 Jul 2020 15:50:50 -0700 Subject: [PATCH 3/7] Add oc-pyang to widely-used-tools list --- commonci/commonci.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commonci/commonci.go b/commonci/commonci.go index db5370f..49b8dcc 100644 --- a/commonci/commonci.go +++ b/commonci/commonci.go @@ -111,8 +111,9 @@ var ( IsWidelyUsedTool: true, }, "oc-pyang": &Validator{ - Name: "OpenConfig Linter", - IsPerModel: true, + Name: "OpenConfig Linter", + IsPerModel: true, + IsWidelyUsedTool: true, }, "pyangbind": &Validator{ Name: "pyangbind", From f5980739286bc97b972479a4aeae8078411a24f9 Mon Sep 17 00:00:00 2001 From: wenovus Date: Tue, 21 Jul 2020 19:38:32 -0700 Subject: [PATCH 4/7] temp changes to upload badges --- cmd_gen/main.go | 1 + post_results/main.go | 1 + 2 files changed, 2 insertions(+) diff --git a/cmd_gen/main.go b/cmd_gen/main.go index 61f73fe..5cc9c1b 100644 --- a/cmd_gen/main.go +++ b/cmd_gen/main.go @@ -328,6 +328,7 @@ func main() { } pushToMaster = true } + pushToMaster = true // Skip testing non-widely used validators, as we don't need to post badges for those tools. if pushToMaster { diff --git a/post_results/main.go b/post_results/main.go index 6a2f06c..644afa2 100644 --- a/post_results/main.go +++ b/post_results/main.go @@ -646,6 +646,7 @@ func postResult(validatorId, version string) error { } pushToMaster = true } + pushToMaster = true compatReportsStr, err := readFile(commonci.CompatReportValidatorsFile) if err != nil { From 5cd58c2d77a5bac0f1faa7f19b0cdbe981e2ae2c Mon Sep 17 00:00:00 2001 From: wenovus Date: Tue, 21 Jul 2020 20:09:52 -0700 Subject: [PATCH 5/7] Add badge uploading commands for all validators --- post_results/main.go | 2 +- validators/misc-checks/test.sh | 4 ++++ validators/oc-pyang/test.sh | 4 ++++ validators/regexp/test.sh | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/post_results/main.go b/post_results/main.go index 644afa2..070110c 100644 --- a/post_results/main.go +++ b/post_results/main.go @@ -535,7 +535,7 @@ func getGistHeading(validatorId, version, resultsDir string) (string, string, er // If version is latest, then get the concrete version output by the tool if it exists. if version == "" { if outBytes, err := ioutil.ReadFile(filepath.Join(resultsDir, commonci.LatestVersionFileName)); err != nil { - log.Printf("did not read latest version for %s: %v", validatorId, err) + log.Printf("INFO: did not read latest version for %s: %v", validatorId, err) } else { // Get the first line of the version output as the tool's display title. nameAndVersionParts := strings.Fields(strings.TrimSpace(strings.SplitN(string(outBytes), "\n", 2)[0])) diff --git a/validators/misc-checks/test.sh b/validators/misc-checks/test.sh index 97046c9..bb4a4b9 100755 --- a/validators/misc-checks/test.sh +++ b/validators/misc-checks/test.sh @@ -49,3 +49,7 @@ if find $REPODIR -name '*.yang' | xargs $GOPATH/bin/ocversion -p $REPODIR > $RES fi $GOPATH/bin/post_results -validator=misc-checks -modelRoot=$_MODEL_ROOT -repo-slug=$_REPO_SLUG -pr-number=$_PR_NUMBER -commit-sha=$COMMIT_SHA -branch=$BRANCH_NAME +BADGEFILE=$RESULTSDIR/upload-badge.sh +if stat $BADGEFILE; then + bash $BADGEFILE +fi diff --git a/validators/oc-pyang/test.sh b/validators/oc-pyang/test.sh index 88c87e5..9bd5624 100755 --- a/validators/oc-pyang/test.sh +++ b/validators/oc-pyang/test.sh @@ -54,6 +54,10 @@ if bash $RESULTSDIR/script.sh $VENVDIR/bin/pyang --plugindir $OCPYANG_PLUGIN_DIR find $FAILFILE -size 0 -delete fi $GOPATH/bin/post_results -validator=oc-pyang -modelRoot=$_MODEL_ROOT -repo-slug=$_REPO_SLUG -pr-number=$_PR_NUMBER -commit-sha=$COMMIT_SHA -branch=$BRANCH_NAME +BADGEFILE=$RESULTSDIR/upload-badge.sh +if stat $BADGEFILE; then + bash $BADGEFILE +fi ########################## CLEANUP ############################# teardown diff --git a/validators/regexp/test.sh b/validators/regexp/test.sh index 3f38ac6..7444b28 100755 --- a/validators/regexp/test.sh +++ b/validators/regexp/test.sh @@ -14,3 +14,7 @@ if go test -v gotests/regexp > $OUTFILE 2> $FAILFILE; then find $FAILFILE -size 0 -delete fi $GOPATH/bin/post_results -validator=regexp -modelRoot=$_MODEL_ROOT -repo-slug=$_REPO_SLUG -pr-number=$_PR_NUMBER -commit-sha=$COMMIT_SHA -branch=$BRANCH_NAME +BADGEFILE=$RESULTSDIR/upload-badge.sh +if stat $BADGEFILE; then + bash $BADGEFILE +fi From 439f9eeda026bade95c507c270b28a3ef79d591e Mon Sep 17 00:00:00 2001 From: wenovus Date: Tue, 21 Jul 2020 20:17:06 -0700 Subject: [PATCH 6/7] Remove experimental, temporary changes --- cmd_gen/main.go | 1 - post_results/main.go | 1 - 2 files changed, 2 deletions(-) diff --git a/cmd_gen/main.go b/cmd_gen/main.go index 5cc9c1b..61f73fe 100644 --- a/cmd_gen/main.go +++ b/cmd_gen/main.go @@ -328,7 +328,6 @@ func main() { } pushToMaster = true } - pushToMaster = true // Skip testing non-widely used validators, as we don't need to post badges for those tools. if pushToMaster { diff --git a/post_results/main.go b/post_results/main.go index 070110c..9404a07 100644 --- a/post_results/main.go +++ b/post_results/main.go @@ -646,7 +646,6 @@ func postResult(validatorId, version string) error { } pushToMaster = true } - pushToMaster = true compatReportsStr, err := readFile(commonci.CompatReportValidatorsFile) if err != nil { From 7a57602aefc00503cbf707e48c0fa4eb9716ccf8 Mon Sep 17 00:00:00 2001 From: wenovus Date: Thu, 6 Aug 2020 13:47:00 -0700 Subject: [PATCH 7/7] Remove temporary change --- validators/oc-pyang/test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/validators/oc-pyang/test.sh b/validators/oc-pyang/test.sh index 9bd5624..e76bbdc 100755 --- a/validators/oc-pyang/test.sh +++ b/validators/oc-pyang/test.sh @@ -19,8 +19,7 @@ setup() { virtualenv $VENVDIR source $VENVDIR/bin/activate - # FIXME(wenbli): remove branch statement. - git clone -b posix-pattern-existence-check https://github.com/openconfig/oc-pyang $OCPYANG_REPO + git clone https://github.com/openconfig/oc-pyang $OCPYANG_REPO pip3 install --no-cache-dir -r $OCPYANG_DIR/requirements.txt pip3 install enum34 pip3 install jinja2