-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI: format isort output for detection by azure pipelines #27334
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
CI: format isort output for detection by azure pipelines #27334
Conversation
ci/code_checks.sh
Outdated
@@ -109,7 +109,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then | |||
|
|||
# Imports - Check formatting using isort see setup.cfg for settings | |||
MSG='Check import format using isort ' ; echo $MSG | |||
isort --recursive --check-only pandas asv_bench | |||
isort --recursive --check-only pandas asv_bench | awk -F ":" '##vso[task.logissue type=error;sourcepath=%(path)s]%(text)s' |
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.
Looks good, but we just want to change the format when the environment variable AZURE
is set. You can see how this is done for flake8. Sorry it wasn't clear in the issue.
Can you also change the order of an import to see this failing in the CI please? So we can see it working before we merge. Thanks!
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.
yes, thank you for being so helpful!
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.
Does this still grab the return code from isort
?
@datapythonista sorry I'm a bit new to bash scripting. It's definitely catching the import error but it is ignoring the exception as shown here:
|
fix isort formatting for awk fix isort format output test awk change fix isort output for azure remove comment fix deliberate import errors fix whitespace whitespace fix
pinging for review! Spent some time on it to understand |
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.
Thanks @leeyspaul, getting closer, still some comments.
ci/code_checks.sh
Outdated
@@ -109,9 +109,12 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then | |||
|
|||
# Imports - Check formatting using isort see setup.cfg for settings | |||
MSG='Check import format using isort ' ; echo $MSG | |||
isort --recursive --check-only pandas asv_bench | |||
if [[ "$AZURE" == "true" ]]; then | |||
isort --recursive --check-only pandas asv_bench | awk -F ':' '{print $0"\n" "##vso[task.logissue type=error;sourcepath=%(path)s]%(text)s"}' |
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.
I think the return code $?
we are checking later to see if isort
was successful or not, will actually be the one of awk with this, which will always be 0.
This means that if the imports are not correctly sorted, we won't detect them in the CI.
Can you start by swapping the order of two imports in pandas in this PR, so we know if this is working or not? We'll remove them once the PR is approved.
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.
Yes, I will push up the badly sorted imports
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.
here is the output! Check import format using isort ERROR: /home/vsts/work/1/s/pandas/plotting/_matplotlib/core.py Imports are incorrectly sorted. ##[error]%(path)s(,): error : %(text)s Check import format using isort DONE ##[error]Bash exited with code '1'. ##[section]Finishing: Linting
Seems like But the first things would probably be fixing the output, from:
to
Thanks! |
fix output test azuredev output fix awk output to show path reformat output to incorporate error msg format output to catch path and error name
ok! I think I'm getting closer now. @datapythonista could you check out the failure? I've pasted below what it's returning for ease.
I added the ORS as the error message was moving to a new line with print. If there is a better way to do this do let me know, thank you! |
is there a reason to not use the |
er, I didn't mean to remove anything. I'm not too familiar on vso codes but I read up on logging here: https://github.com/microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md Could you clarify what you mean by the vso code and I will change it back, or point me to the docs. Thank you! |
I refer to what is suggested in #27334 (comment) instead of using |
ah right. So oddly it seems to be getting converted from I might be missing something obvious here |
ah, sorry, didn't see in the code you were already using the I'd prefer to remove the And the thing that concerns me is the Does this make sense? |
I think so, I'll take a look at this tonight! Thanks for the info. : ) (will ping if I can't get it!) |
@leeyspaul can you merge master again? Old builds are no longer available |
@leeyspaul is this still active? |
@WillAyd hey yeah, sorry. Had gotten caught up with work. I will work on this this weekend. |
Great! No worries on timing - not in any rush. Just wanted to make sure this was something that you were still looking at, so thanks for confirming |
@leeyspaul can you merge master and update |
@leeyspaul can you rebase |
If we dont hear from @leeyspaul I can take this on |
@alimcmaster1 feel free to take over. I don't think I'll be able to complete this any time soon. Thanks! |
Restarted this over here: #29654 Closing this for now |
I'm moving the Checks build to actions, and I think it only supports the |
Ahh so there probably isn’t much value in this at all? I can close my PR if so |
There is surely value on letting the CI know what's an error. Just the format will probably be different. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff