Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Script for OC Path and RPC Coverage in READMEs #2865

Merged
merged 19 commits into from
Apr 8, 2024
Merged

Conversation

wenovus
Copy link
Contributor

@wenovus wenovus commented Mar 30, 2024

  • tools/internal/mdocspec/* package parses ocpath.proto and ocrpcs.proto from yaml according to the format shown below by mdocspec.Parse's documentation.
  • tools/validate_readme_spec/validate_readme_spec.go script is added that can parse and then validate OC Paths and RPCs according to existing repo states in github.com/openconfig.
// Parse extracts sorted OpenConfig Path and RPC Coverage from an FNT README.
//
// The first yaml code block after a heading line named exactly as
// "OpenConfig Path and RPC Coverage" will be used. Any other code blocks are
// ignored.
//
// Expected markdown format:
//
//      ## OpenConfig Path and RPC Coverage
//
//      ```yaml
//      paths:
//        /interfaces/interface/config/description:
//        /interfaces/interface/config/enabled:
//        /components/component/state/name:
//          platform_type: "CHASSIS"
//
//      rpcs:
//        gnmi:
//          gNMI.Set:
//            union_replace: true
//          gNMI.Subscribe:
//            on_change: true
//      ```
//
// Note: For `rpcs`, only the RPC name and methods are validated. Any
// attributes defined below RPC methods (e.g. union_replace) are not validated.
func Parse(source []byte) (*ppb.OCPaths, *rpb.OCRPCs, error) {

dplore and others added 4 commits March 28, 2024 12:07
* `mdocspec` package parses ocpath.proto and ocrpcs.proto from yaml
  according to the format shown below by mdocspec.Parse's documentation.
* `tools/validate_readme_spec/validate_readme_spec.go` script is added
  that can parse and then validate OC Paths and RPCs according to
  existing repo states in github.com/openconfig.

```go
// Parse extracts sorted OpenConfig Path and RPC Coverage from an FNT
README.
//
// The first yaml code block after a heading line named exactly as
// "OpenConfig Path and RPC Coverage" will be used. Any other code
blocks are
// ignored.
//
// Expected markdown format:
//
//      ## OpenConfig Path and RPC Coverage
//
//      ```yaml
//      paths:
//        /interfaces/interface/config/description:
//        /interfaces/interface/config/enabled:
//        /components/component/state/name:
//          platform_type: "CHASSIS"
//
//      rpcs:
//        gnmi:
//          gNMI.Set:
//            union_replace: true
//          gNMI.Subscribe:
//            on_change: true
//      ```
//
// Note: For `rpcs`, only the RPC name and methods are validated. Any
// attributes defined below RPC methods (e.g. union_replace) are not validated.
```
@OpenConfigBot
Copy link

OpenConfigBot commented Mar 30, 2024

Pull Request Functional Test Report for #2865 / 2b79d7b

No tests identified for validation.

Help

@coveralls
Copy link

coveralls commented Mar 30, 2024

Pull Request Test Coverage Report for Build 8606754992

Details

  • 105 of 142 (73.94%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.8%) to 55.169%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tools/internal/mdocspec/md.go 41 44 93.18%
tools/internal/mdocspec/ocspec.go 64 72 88.89%
tools/internal/ocpaths/clone_public.go 0 26 0.0%
Totals Coverage Status
Change from base Build 8596811599: 0.8%
Covered Lines: 1948
Relevant Lines: 3531

💛 - Coveralls

@wenovus wenovus requested a review from dplore March 30, 2024 03:10
@wenovus wenovus marked this pull request as ready for review March 30, 2024 03:10
@wenovus wenovus requested review from a team as code owners March 30, 2024 03:10
@wenovus wenovus requested a review from robshakir March 30, 2024 03:10
@wenovus wenovus removed the request for review from robshakir March 30, 2024 03:12
@wenovus
Copy link
Contributor Author

wenovus commented Mar 30, 2024

This validation routine is based on the template README style being defined in #2863

.github/workflows/readme_oc_path_and_rpc.yml Show resolved Hide resolved
tools/internal/mdocspec/md_test.go Outdated Show resolved Hide resolved
tools/internal/mdocspec/md_test.go Show resolved Hide resolved
tools/internal/mdocspec/ocspec.go Outdated Show resolved Hide resolved
tools/internal/mdocspec/ocspec.go Outdated Show resolved Hide resolved
tools/internal/mdocspec/md.go Outdated Show resolved Hide resolved
Base automatically changed from dplore-patch-2 to main April 5, 2024 04:39
wenovus and others added 4 commits April 5, 2024 10:07
Co-authored-by: Darren Loher <dloher@google.com>
* Skip repo-cloning during validation if repo already cloned.
* Validate that at least one RPC method is specified for any coverage spec.
* Add additional validation for script in bash file.
* Style Improvements.
@wenovus wenovus requested a review from dplore April 5, 2024 20:59
tools/internal/mdocspec/md.go Show resolved Hide resolved
tools/internal/mdocspec/ocspec.go Show resolved Hide resolved
tools/internal/ocpaths/clone_public.go Show resolved Hide resolved
tools/internal/ocrpcs/ocrpcs.go Show resolved Hide resolved
dplore
dplore previously approved these changes Apr 8, 2024
@wenovus
Copy link
Contributor Author

wenovus commented Apr 8, 2024

@dplore Need another approval due to slight doc fix.

@wenovus wenovus merged commit 7d92195 into main Apr 8, 2024
15 checks passed
@wenovus wenovus deleted the mdocspec branch April 8, 2024 21:59
frasieroh pushed a commit to aristanetworks/openconfig-featureprofiles that referenced this pull request Apr 9, 2024
…#2865)

* Add yaml spec for oc path/rpc to test-requirements-template

* revise yaml

* revise yaml

* Validation Script for OC Path and RPC Coverage in READMEs

* `mdocspec` package parses ocpath.proto and ocrpcs.proto from yaml
  according to the format shown below by mdocspec.Parse's documentation.
* `tools/validate_readme_spec/validate_readme_spec.go` script is added
  that can parse and then validate OC Paths and RPCs according to
  existing repo states in github.com/openconfig.

```go
// Parse extracts sorted OpenConfig Path and RPC Coverage from an FNT
README.
//
// The first yaml code block after a heading line named exactly as
// "OpenConfig Path and RPC Coverage" will be used. Any other code
blocks are
// ignored.
//
// Expected markdown format:
//
//      ## OpenConfig Path and RPC Coverage
//
//      ```yaml
//      paths:
//        /interfaces/interface/config/description:
//        /interfaces/interface/config/enabled:
//        /components/component/state/name:
//          platform_type: "CHASSIS"
//
//      rpcs:
//        gnmi:
//          gNMI.Set:
//            union_replace: true
//          gNMI.Subscribe:
//            on_change: true
//      ```
//
// Note: For `rpcs`, only the RPC name and methods are validated. Any
// attributes defined below RPC methods (e.g. union_replace) are not validated.
```

* Add invalid README example

* Fix style

* Make YAMLRenderer unexported

* Improve comments

* Update tools/internal/mdocspec/ocspec.go

Co-authored-by: Darren Loher <dloher@google.com>

* Minor improvements for OC coverage validation

* Skip repo-cloning during validation if repo already cloned.
* Validate that at least one RPC method is specified for any coverage spec.
* Add additional validation for script in bash file.
* Style Improvements.

* Improve logic by searching from header rather than YAML block

* add another corner case test

* add another corner case test

* Improve doc comment

* Improve doc comments

* Fix doc comment

---------

Co-authored-by: Darren Loher <dloher@google.com>
ANISH-GOTTAPU pushed a commit to open-traffic-generator/featureprofiles that referenced this pull request Jul 10, 2024
…#2865)

* Add yaml spec for oc path/rpc to test-requirements-template

* revise yaml

* revise yaml

* Validation Script for OC Path and RPC Coverage in READMEs

* `mdocspec` package parses ocpath.proto and ocrpcs.proto from yaml
  according to the format shown below by mdocspec.Parse's documentation.
* `tools/validate_readme_spec/validate_readme_spec.go` script is added
  that can parse and then validate OC Paths and RPCs according to
  existing repo states in github.com/openconfig.

```go
// Parse extracts sorted OpenConfig Path and RPC Coverage from an FNT
README.
//
// The first yaml code block after a heading line named exactly as
// "OpenConfig Path and RPC Coverage" will be used. Any other code
blocks are
// ignored.
//
// Expected markdown format:
//
//      ## OpenConfig Path and RPC Coverage
//
//      ```yaml
//      paths:
//        /interfaces/interface/config/description:
//        /interfaces/interface/config/enabled:
//        /components/component/state/name:
//          platform_type: "CHASSIS"
//
//      rpcs:
//        gnmi:
//          gNMI.Set:
//            union_replace: true
//          gNMI.Subscribe:
//            on_change: true
//      ```
//
// Note: For `rpcs`, only the RPC name and methods are validated. Any
// attributes defined below RPC methods (e.g. union_replace) are not validated.
```

* Add invalid README example

* Fix style

* Make YAMLRenderer unexported

* Improve comments

* Update tools/internal/mdocspec/ocspec.go

Co-authored-by: Darren Loher <dloher@google.com>

* Minor improvements for OC coverage validation

* Skip repo-cloning during validation if repo already cloned.
* Validate that at least one RPC method is specified for any coverage spec.
* Add additional validation for script in bash file.
* Style Improvements.

* Improve logic by searching from header rather than YAML block

* add another corner case test

* add another corner case test

* Improve doc comment

* Improve doc comments

* Fix doc comment

---------

Co-authored-by: Darren Loher <dloher@google.com>
bkreddy143 pushed a commit to nokia/featureprofiles that referenced this pull request Jul 17, 2024
…#2865)

* Add yaml spec for oc path/rpc to test-requirements-template

* revise yaml

* revise yaml

* Validation Script for OC Path and RPC Coverage in READMEs

* `mdocspec` package parses ocpath.proto and ocrpcs.proto from yaml
  according to the format shown below by mdocspec.Parse's documentation.
* `tools/validate_readme_spec/validate_readme_spec.go` script is added
  that can parse and then validate OC Paths and RPCs according to
  existing repo states in github.com/openconfig.

```go
// Parse extracts sorted OpenConfig Path and RPC Coverage from an FNT
README.
//
// The first yaml code block after a heading line named exactly as
// "OpenConfig Path and RPC Coverage" will be used. Any other code
blocks are
// ignored.
//
// Expected markdown format:
//
//      ## OpenConfig Path and RPC Coverage
//
//      ```yaml
//      paths:
//        /interfaces/interface/config/description:
//        /interfaces/interface/config/enabled:
//        /components/component/state/name:
//          platform_type: "CHASSIS"
//
//      rpcs:
//        gnmi:
//          gNMI.Set:
//            union_replace: true
//          gNMI.Subscribe:
//            on_change: true
//      ```
//
// Note: For `rpcs`, only the RPC name and methods are validated. Any
// attributes defined below RPC methods (e.g. union_replace) are not validated.
```

* Add invalid README example

* Fix style

* Make YAMLRenderer unexported

* Improve comments

* Update tools/internal/mdocspec/ocspec.go

Co-authored-by: Darren Loher <dloher@google.com>

* Minor improvements for OC coverage validation

* Skip repo-cloning during validation if repo already cloned.
* Validate that at least one RPC method is specified for any coverage spec.
* Add additional validation for script in bash file.
* Style Improvements.

* Improve logic by searching from header rather than YAML block

* add another corner case test

* add another corner case test

* Improve doc comment

* Improve doc comments

* Fix doc comment

---------

Co-authored-by: Darren Loher <dloher@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants