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

Can 'make lint-py PYTHON=python3' be a manditory Jenkins test? #1631

Closed
cclauss opened this issue Dec 11, 2018 · 39 comments · Fixed by #1745
Closed

Can 'make lint-py PYTHON=python3' be a manditory Jenkins test? #1631

cclauss opened this issue Dec 11, 2018 · 39 comments · Fixed by #1745
Assignees
Labels
ci-change PSA of configuration changes ci-job-request ci-public

Comments

@cclauss
Copy link
Contributor

cclauss commented Dec 11, 2018

Is your feature request related to a problem? Please describe.
Python 2 end-of-life is one year from now. We have been working for a while and this repo's code now contains no Python 3 syntax errors or undefined names. make lint-py shows that we no longer have any syntax errors on either Python 2 or Python 3. It also shows that we have fixed all undefined names like basestring, cmp(), file, reduce(), raw_input(), unicode, xrange() that were removed in Python 3.

The port to Python 3 is not yet complete but the codebase is "syntax compatible" which is a state that we should now preserve and guard against any backsliding.

Describe the solution you'd like
After #24954 lands, it would be helpful if every Jenkins run required that make lint-py PYTHON=python2 and make lint-py PYTHON=python3 both pass. This will ensure that pull requests do not introduce syntax errors (like print without the parens) or undefined names (like raw_input()). This will help as we complete the port.

Describe alternatives you've considered
Please describe alternative solutions or features you have considered.
Going snowboarding.

/cc @nodejs/python

@targos
Copy link
Member

targos commented Dec 11, 2018

/cc @nodejs/build

@Trott
Copy link
Member

Trott commented Dec 11, 2018

I guess the big change this would require would be Python 3 to be installed on all our CI hosts? Or is it possible to lint for Python 3 issues using Python 2? We do already run make lint-py on all CI test runs, but I guess that only covers Python 2 issues in the current state?

@targos
Copy link
Member

targos commented Dec 11, 2018

I think it would be enough to test only on one host, with a custom job. And when the build supports Python 3, switch the job to use Python 3 fully.

@BridgeAR
Copy link
Member

I believe it would be best to move this issue to the build repo. Could someone do that (I do not have the necessary rights)? :)

@targos targos transferred this issue from nodejs/node Dec 11, 2018
@targos
Copy link
Member

targos commented Dec 11, 2018

Issue moved to nodejs/build

@cclauss
Copy link
Contributor Author

cclauss commented Dec 11, 2018

This has to be run on Python 3 because flake8 uses CPython to build an Abstract Syntax Tree and it then lints the AST. This is described in the Very Important Note on the top of http://flake8.pycqa.org

That being said, Python 3 was introduced 8+ years ago so today it is quite easy on all OSes to install both legacy Python and Python side-by-side on the same box and then do python2 -m flake8 [...] and python3 -m flake8 [...].

@Trott
Copy link
Member

Trott commented Dec 11, 2018

I think it would be enough to test only on one host, with a custom job. And when the build supports Python 3, switch the job to use Python 3 fully.

Oh, yeah, maybe we can just install Python 3 on the linter host(s) only and have it run there via a Jenkins config.

@cclauss
Copy link
Contributor Author

cclauss commented Dec 14, 2018

This effort can proceed when consensus is reached because nodejs/node#24954 has landed and make lint-py PYTHON=python2 and make lint-py PYTHON=python3 both pass.

@Trott
Copy link
Member

Trott commented Dec 14, 2018

Adding to the Build WG meeting agenda.

@rvagg
Copy link
Member

rvagg commented Dec 18, 2018

If it's just for linting then it should be straight forward I think since it's limited to a few hosts.

But ...

Python 2 end-of-life is one year from now

Yikes .. I didn't know this but it has huge ramifications across the board for us. Some things off the top of my head:

  • node-gyp and GYP in general .. I've mostly tuned out of the many attempts to make our GYP Python 3 compatible because it's such a mess (and mostly I'm just cranky at Google for being so terrible at tools—with a combination of pathological NIMBY and "bored of this, let's invent something new"). If Python 2 is genuinely something we shouldn't be relying on in a year, then we need to have a plan to migrate the entire ecosystem to a Python 3 version of GYP. That's going to take some care and skillful planning I think. Maybe it's time to consider a more radical move for addon building? Promote CMake? Revisit Fedor's gyp.js? Something else?
  • Our custom Ansible stuff is only partly Python 3 compatible, mostly it works but there are special use cases where it fails still. There's a couple of PRs and issues open on this repo about this. On my macOS machine I get Python 3 with Ansible thanks to brew, but on my Linux machine I get Python 2 with Ansible, because <reasons>.

Python 2 is still everywhere. If 2 is EOL so soon, why do we still have this kind of thing:

$ lsb_release -d
Description:	Ubuntu 18.04.1 LTS
$ head -1 $(which ansible)
#! /usr/bin/python2

Have distros thrown up their hands too? I believe it's possible to install Python 3 on older hosts we maintain, like CentOS 6. Some of them are a bit awkward because a lot of internal tooling on Linux distros use Python so conflicts are really easy.

This feels to me like a big enough problem that it needs needs something at a higher level, a strategic initiative or short-lived working group to sort out all of the issues. Not that I really want to be thinking more than I have to about this mess but the pain is only going to increase. No, I'm not volunteering to lead such an initiative, our strategy of 🙈 🙉 🙊 isn't sustainable though.

@cclauss
Copy link
Contributor Author

cclauss commented Dec 18, 2018

https://python3statement.org

https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

Being syntax compatible != fully supporting.

@JamesMGreene
Copy link

JamesMGreene commented Dec 18, 2018

Note that this is only as of ~1 week ago and it is still largely untested.

@cclauss
Copy link
Contributor Author

cclauss commented Dec 18, 2018

Installing Python 3 on FreeBSD: pkg install python3

@rvagg
Copy link
Member

rvagg commented Dec 18, 2018

https://ci.nodejs.org/job/node-test-linter/24474/console failing with python3

10:43:05 python3 -m pip install --upgrade -t tools/pip/site-packages flake8 || \
10:43:05 	python3 -m pip install --upgrade --system -t tools/pip/site-packages flake8
10:43:05 /usr/local/bin/python3: No module named pip

...

10:44:24 Running C++ linter...
10:44:25 Traceback (most recent call last):
10:44:25   File "tools/cpplint.py", line 6526, in <module>
10:44:25     main()
10:44:25   File "tools/cpplint.py", line 6510, in main
10:44:25     ProcessFile(filename.decode('utf-8'), _cpplint_state.verbose_level)
10:44:25 AttributeError: 'str' object has no attribute 'decode'
10:44:25 gmake: *** [Makefile:1262: tools/.cpplintstamp] Error 1

on master, but even if we fix on master we need a strategy for older branches - do we backport? or do we hack CI to switch python version for older branches?

@rvagg
Copy link
Member

rvagg commented Dec 18, 2018

added py36-pip to the install list which cleaned up the first one, second one remains:

10:57:11 Running C++ linter...
10:57:12 Traceback (most recent call last):
10:57:12   File "tools/cpplint.py", line 6526, in <module>
10:57:12     main()
10:57:12   File "tools/cpplint.py", line 6510, in main
10:57:12     ProcessFile(filename.decode('utf-8'), _cpplint_state.verbose_level)
10:57:12 AttributeError: 'str' object has no attribute 'decode'
10:57:12 gmake: *** [Makefile:1262: tools/.cpplintstamp] Error 1

@cclauss
Copy link
Contributor Author

cclauss commented Dec 19, 2018

Running an outa date version of cpplint.py

@rvagg
Copy link
Member

rvagg commented Dec 19, 2018

so we need to fix that on master then?

@cclauss
Copy link
Contributor Author

cclauss commented Dec 19, 2018

Why are we bothering with C++?

We merely want the flake8 jobs to run on Py2 and Py3.

This issue is about lint-py, not about all lint jobs in Makefile.

@rvagg
Copy link
Member

rvagg commented Dec 19, 2018

because they're all tangled together:

which gmake &>/dev/null && MAKE=gmake || MAKE=make
PYTHON=python2

$MAKE lint-md-build PYTHON=$PYTHON || true
$MAKE lint-py-build PYTHON=$PYTHON || true
# If lint-ci fails, print all the interesting lines to the console.
# FreeBSD sed can't handle \s, so use gsed if it exists.
which gsed &>/dev/null && SED=gsed || SED=sed
$MAKE lint-ci PYTHON=$PYTHON || { 
  cat test-eslint.tap | grep -v '^ok\|^TAP version 13\|^1\.\.' | $SED '/^\s*$/d' && 
  exit 1; }

We run lint-ci which is:

lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs

So this doesn't sound like it's a nodejs/build problem until nodejs/node has Makefile, or cpplint.py, or whatever else sorted out. Then that's going to need to be backported to the supported release lines or we're going to need to add complex version switching logic in our linting job in CI.

@cclauss
Copy link
Contributor Author

cclauss commented Dec 19, 2018

Let's make two variables $PYTHON2 and $PYTHON3 like in nodejs/node#25118

@cclauss
Copy link
Contributor Author

cclauss commented Dec 19, 2018

@cclauss
Copy link
Contributor Author

cclauss commented Dec 20, 2018

For now, can we merely add the command make lint-py PYTHON=python3 ?

@cclauss cclauss changed the title Can 'make lint-py' on Python 3 be a manditory Jenkins test? Can 'make lint-py PYTHON=python3' be a manditory Jenkins test? Dec 20, 2018
@refack refack added ci-public ci-job-request ci-change PSA of configuration changes and removed build-agenda labels Jan 21, 2019
@refack
Copy link
Contributor

refack commented Jan 21, 2019

I'm removing from agenda since the specific issue has a clear path to resolution.
Bigger issue addressed in nodejs/TSC#642.

@thefourtheye
Copy link

As per: #1644 (comment) job can't go live until lint issue is solved in node core (Ref: nodejs/node#25614)

@refack Now that we do not lint python scripts in test/fixtures (ref: nodejs/node#25639), can we push the job to live?

@mhdawson
Copy link
Member

@refack do you already have the job ready to go and we just need to add it to the regressions runs or is there more to do beyond that assuming that we are ready to go given nodejs/node#25639

@refack
Copy link
Contributor

refack commented Jan 25, 2019

Ready to go. I just wanted the patched code in master to get to as many people as possible.
(Still PR that were not rebased will fail linting, so I was hoping to minimize noise)

@mhdawson
Copy link
Member

Ok so you are planning to turn it on in a few days or a week at most?

@refack
Copy link
Contributor

refack commented Jan 25, 2019

Ok so you are planning to turn it on in a few days or a week at most?

At most. I'll send a PSA now.

@refack
Copy link
Contributor

refack commented Jan 26, 2019

Activated for node-test-linter (part of node-test-pull-request) -> https://ci.nodejs.org/job/node-test-linter/25180/console

Testing job for node-linter (part of node-test-pull-request-lite-pipeline) -> https://ci.nodejs.org/job/refack-node-linter/2/console

@cclauss
Copy link
Contributor Author

cclauss commented Jan 26, 2019

Thanks massively... This will help us avoid any backsliding.

@Trott
Copy link
Member

Trott commented Jan 26, 2019

Closable now? Or is there still more to be done?

@refack
Copy link
Contributor

refack commented Jan 26, 2019

Closable now? Or is there still more to be done?

The pipeline variant hasn't gone live yet...

@cclauss
Copy link
Contributor Author

cclauss commented Mar 4, 2019

Can we please get this resolves and closed? 303 daze left...

@Trott
Copy link
Member

Trott commented Mar 4, 2019

(Adding build-agenda so it gets discussed at the next Build meeting if there isn't any significant progress between now and then.)

@refack refack removed their assignment Mar 4, 2019
@refack
Copy link
Contributor

refack commented Mar 4, 2019

IMO fixing the pipeline job has low ROI. It's mostly a convenience. The main job (https://ci.nodejs.org/job/node-test-linter/) runs python linting with Python3, so we have regression testing.

If someone wants to follow up with porting https://github.com/nodejs/build/blob/master/jenkins/pipelines/node-linter.jenkinsfile, that will be very helpful.

@cclauss
Copy link
Contributor Author

cclauss commented Jun 27, 2019

@rvagg @thefourtheye How do we progress this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-change PSA of configuration changes ci-job-request ci-public
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants