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

Be able to run pyang #186

Open
richsalz opened this issue Apr 23, 2019 · 8 comments
Open

Be able to run pyang #186

richsalz opened this issue Apr 23, 2019 · 8 comments

Comments

@richsalz
Copy link
Contributor

In xml2rfc v3, YANG code is marked with

<sourcecode type="yang">
...
</sourcecode>

It would be nice to strip those out and feed them through pyang --ietf for syntax-checks, and perhaps also pyang -f yang --keep-comments And maybe put max-line-length 69 somewhere.

@martinthomson
Copy link
Owner

I've left this sort of linting to other tools. The Makefile for the QUIC drafts adds a lint that looks for line length, for instance. To that, I would use the native inclusion functions of the tool, whatever that is, and add a lint that uses pyang for those files. Something like:

<sourcecode type="yang">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file.yang" parse="text"/>
</sourcecode>

...and:

lint::
        pyang --ietf *.yang

That said, it's probably good to integrate this sort of check into the tool proper. It's fairly easy to extract the relevant pieces using xmllint.

@martinthomson
Copy link
Owner

Of note here is a new option for people who want more tools in CI images. pyang is probably small enough to include in the core image; but if it is not, then that option exists.

@mcr
Copy link

mcr commented Jun 14, 2021

<sourcecode type="yang">

You can't include the yang directly like this, as it needs CDATA, I think.

@mcr
Copy link

mcr commented Mar 6, 2022

At: https://github.com/anima-wg/voucher/runs/5436309463?check_suite_focus=true I notice that the pyang in the circleCI container is too old to understand --keep-comments.
@martinthomson I don't remember how you want us to report problems like this.

@martinthomson
Copy link
Owner

@mcr, the image I'm using is just 3 days old (as of your comment), so if pyang was updated in the intervening time to include support for that argument, that's expected. Do I need to rebuild the image for a new version?

@mcr
Copy link

mcr commented Mar 8, 2022

%pyang --help | grep keep-comment
--keep-comments Pyang will not discard comments;
%pyang --version
pyang 2.5.0

Could I be using something from git, rather than released?
% which pyang
/home/mcr/.local/bin/pyang
% ls -l ~/.local/bin/pyang
-rwxr-xr-x 1 mcr mcr 21131 Dec 1 15:09 /home/mcr/.local/bin/pyang*

I don't think so.

@martinthomson
Copy link
Owner

https://github.com/martinthomson/i-d-template/runs/5401518893?check_suite_focus=true#step:7:387 shows that pyang 2.5.2 was installed. So it's not that.

The specific message is this:

sed -e 's/YYYY-MM-DD/'2021-07-04'/g' ietf-voucher.yang | pyang -p /github/home/.local/share/yang/modules -f --keep-comments >yang/[email protected]
unsupported format '--keep-comments'

Note here that the -f option is not followed by a yang parameter. That's probably something to look into.

@mcr
Copy link

mcr commented Mar 9, 2022

Yes, you are exactly correct.
Thanks to makefiles not running rules when there is nothing to do, never caught it.
I have fixed my end of things. I think that I need to do some slides/explanation on doing yang work with your templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@mcr @martinthomson @richsalz and others