-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Jenkins CI Lint Improvements #50026
Jenkins CI Lint Improvements #50026
Conversation
Best I could do is a syntax check to check if it will work. Testing which needs to be performed:
Another option is consider, is testing if people have submitted new code with .PY or .pY or .Py extension, as the original code would skip these files. (not that many people would use anything other than .py) |
.ci/lint
Outdated
@@ -22,6 +22,10 @@ pipeline { | |||
stage('setup') { | |||
steps { | |||
sh ''' | |||
git diff --name-status "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" > file-list-status.log | |||
git diff --name-only '--diff-filter=ACMRTUXB' "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" > file-list-changed.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should just be --diff-filter=d
so we don't get deleted files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line below should cover that correct? He is doing 2 logs 1 for status, 1 for changes, and one for deleted files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, but I would prefer using the not-operator so if anything changes, we'll be fine.
.ci/lint
Outdated
else | ||
tox -e pylint-salt ${_FILES} | tee pylint-report.xml | ||
fi | ||
egrep -i '^salt/.*\\.py$|^setup\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-salt | tee pylint-report-salt.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use grep -E
.
.ci/lint
Outdated
else | ||
tox -e pylint-tests ${_FILES} | tee pylint-report-tests.xml | ||
fi | ||
egrep -i '^tests/.*\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-tests | tee pylint-report-tests.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -E
again
Also, if we can squash some of the commits that would be great. (the ones where you just fix syntax, squash those) |
@damon-atkins I like having all three log files archived. We could patch the server to allow/send the correct mime type. https://issues.jenkins-ci.org/browse/JENKINS-3803 What I would like to see here before we merge is some better testing ran against it. @KaiSforza Can you please test this out on a few PR's by doing a replay or setting up some sort of test? |
Yep I'll get on it |
Change the names to *.log as this is configured https://github.com/jenkinsci/jenkins/blob/master/war/src/main/webapp/WEB-INF/web.xml#L225 The file contents are not xml. |
65da679
to
cf275db
Compare
Should be right now. I am not a trusted user in Jenkins so its still running the old ci/lint. |
.ci/lint
Outdated
else | ||
tox -e pylint-salt ${_FILES} | tee pylint-report.xml | ||
fi | ||
egrep -Ei '^salt/.*\\.py$|^setup\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-salt | tee pylint-report-salt.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not egrep -E
, just grep -E
.
.ci/lint
Outdated
else | ||
tox -e pylint-tests ${_FILES} | tee pylint-report-tests.xml | ||
fi | ||
egrep -Ei '^tests/.*\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-tests | tee pylint-report-tests.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
I'd love these to be squashed down to one or two commits, honestly. |
.ci/lint
Outdated
egrep -i '^salt/.*\\.py$|^setup\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-salt | tee pylint-report-salt.log | ||
egrep -Ei '^salt/.*\\.py$|^setup\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-salt | tee pylint-report-salt.log | ||
# remove color escape coding | ||
sed -ri 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' pylint-report-salt.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay explain to me what this is actually needed for? the colors are automatically removed when pylint is piped to something, unless something is getting through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save the current xml version and you will see them. I suspect PY_COLOR forces it. And is done so, so the console out put looks nice in Jenkins
cf275db
to
f85fb5e
Compare
.ci/lint
Outdated
else | ||
tox -e pylint-salt ${_FILES} | tee pylint-report.xml | ||
fi | ||
egrep -E '^salt/.*\\.py$|^setup\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-salt | tee pylint-report-salt.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still doing egrep
here, please remove that first e
, it should be just grep -E
.
.ci/lint
Outdated
else | ||
tox -e pylint-tests ${_FILES} | tee pylint-report-tests.xml | ||
fi | ||
egrep -E '^tests/.*\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' tox -e pylint-tests | tee pylint-report-tests.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
FYI |
f85fb5e
to
1e3c652
Compare
All updates ask for completed. |
Current Open Pull Requests against 2017.7 are
So if this was merged into 2017.7 and issues occurred it would be manageable. |
@damon-atkins I ran this against a few PR's I didn't dive too much into the reasoning. But there seems to be some discrepancies. https://jenkinsci.saltstack.com/view/Pull%20Requests/job/pr-lint/view/change-requests/job/PR-50124/ 5 is a replay with the new suggested changes and 6 is the old linting pipeline code. I don't have time to dig in at the moment, although it may give you an idea as to what's wrong. |
I will have a look at then |
…iff to find files, instead of find, report on status, changed and deleted files, lint only changed files.
1e3c652
to
6b96a24
Compare
@dubb-b that should do the job. |
b78c7ac
to
5f708fa
Compare
Go Go Jenkins! |
@damon-atkins I ran it against this: https://jenkinsci.saltstack.com/view/Pull%20Requests/job/pr-lint/view/change-requests/job/PR-50152/2/ Build #1 was successful and not it fails. Looking through the logs, it seems to have found 3 warnings. Can you validate that is what you'd expect. It looks right to me. |
Looks Good. |
So with all the recent changes to lint, the next step is only allow the other tests when the lint succeeds. This will reduce the testing load as per the example in #50026 (comment) However "Go Go Jenkins!" should override this (if possible) |
That is definitely on the roadmap. Not sure as to when we will get it in. But thanks for the work here. Much appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have tested this on a number of PR's and it looks to be stable and working as it should.
What does this PR do?
Improvements in .ci/lint
*Remove the need to use find to scan the file system and call git multiple times. (small decrease in overhead)
*Only run a stage if required.
What issues does this PR fix or reference?
Some general improvements.