Page MenuHomeVyOS Platform

equuleus: Testing: vyos-1x: syntax checking python scripts in PR
Open, Requires assessmentPublic

Description

In the past there have been quite a few tickets regarding python syntax errors on scripts rewritten to python.
To make a quickfix on some of these faults we could make a Jenkins step that executes: python3 -m compileall -q . to do a offline compile of the python files.

as for writing this tasks we have these faults in the repository:

*** Error compiling './src/conf_mode/interfaces-openvpn.py'...
Sorry: IndentationError: unindent does not match any outer indentation level (interfaces-openvpn.py, line 635)
*** Error compiling './src/conf_mode/interfaces-pseudo-ethernet.py'...
  File "./src/conf_mode/interfaces-pseudo-ethernet.py", line 130
    or peth['ipv6_autoconf'] ) ):
                                ^
SyntaxError: invalid syntax

*** Error compiling './src/conf_mode/interfaces-vxlan.py'...
  File "./src/conf_mode/interfaces-vxlan.py", line 172
    return None
    ^
SyntaxError: invalid syntax

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

runar created this task.May 8 2020, 7:51 AM
runar created this object in space S1 VyOS Public.
jjakob added a subscriber: jjakob.May 8 2020, 8:18 AM

Wouldn't it be better to add it to the vyos-1x Makefile so we could test it ourselves, before committing, making a PR, it being merged, and only then figuring out it's a problem?

jjakob added a comment.EditedMay 8 2020, 8:19 AM

The fix for the error for openvpn is already waiting in PR since yesterday, fix for pseudo-ethernet and vxlan will be ready right now.

pasik added a subscriber: pasik.May 8 2020, 9:33 AM

I would also suggest doing the same using github actions so that on push to your local repository to get a warning from github.

It seems that github has special rules for the .github file and that no PR can be done for it:
https://github.com/thomas-mangin/vyos-1x/blob/T2436/.github/workflows/pythonapp.yml

This does not compile python scripts without a .py extension (there are several in src/services, src/utils that have #!/usr/bin/env python3)

Many scripts also so do implement if name == โ€œmainโ€