Skip to content

CI: Format isort output for azure #29654

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

Merged
merged 13 commits into from
Dec 6, 2019
Merged

CI: Format isort output for azure #29654

merged 13 commits into from
Dec 6, 2019

Conversation

alimcmaster1
Copy link
Member

@alimcmaster1 alimcmaster1 commented Nov 16, 2019

Current behaviour on master of isort formatting:
image

Finishing up stale PR @#27334

@alimcmaster1 alimcmaster1 added CI Continuous Integration Error Reporting Incorrect or improved errors from pandas labels Nov 16, 2019
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Thanks for picking this up! FYI for smaller changes we typically try to push to the original contributors branch so they get credit (I use hub to do this). By no means required just something to consider

@datapythonista @jbrockmendel if you care to look

@WillAyd WillAyd added this to the 1.0 milestone Nov 17, 2019
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff. Some minor stylistic comments, but looks good.

I think the error in the CI is missing some space that you may want to add in the awk expression too.

@WillAyd, I don't think @alimcmaster1 has got the permissions to push to other people PRs. @alimcmaster1 you can still give credits by adding co-authors to you commits I think. I don't remember the syntax, and it's not important. Just in case you think it's worth the research (probably not).

@@ -109,7 +109,13 @@ 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
set -o pipefail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should disable when it's not needed anymore. Otherwise things in other part of the script can fail, and this is not expected to be active by default.

@@ -109,7 +109,13 @@ 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
set -o pipefail
isort_cmd="isort --recursive --check-only pandas asv_bench"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the convention is to have environment variables in bash in upper case.

if [[ "$AZURE" == "true" ]]; then
eval $isort_cmd | awk '{ORS=""} {print "##vso[task.logissue type=error;sourcepath="$2";]"} {$1=$2=""; print $0}'
else
eval $isort_cmd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indentation doesn't much the previous eval.

set -o pipefail
isort_cmd="isort --recursive --check-only pandas asv_bench"
if [[ "$AZURE" == "true" ]]; then
eval $isort_cmd | awk '{ORS=""} {print "##vso[task.logissue type=error;sourcepath="$2";]"} {$1=$2=""; print $0}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an opinion, but I'd personally prefer something like:

if [[ "$AZURE" == "true" ]]; then
    FORMAT_ISORT="awk '{ORS=""} {print "##vso[task.logissue type=error;sourcepath="$2";]"} {$1=$2=""; print $0}'"
else
    FORMAT_ISORT="cat"
fi
isort --recursive --check-only pandas asv_bench | eval $FORMAT_ISORT

Not a huge difference, but I think it makes more clear what's going on, since the line that actually does things is just one, shorter, and more explicit on what it does

@datapythonista datapythonista changed the title Format isort output for azure CI: Format isort output for azure Nov 17, 2019
@alimcmaster1
Copy link
Member Author

Since we are now using Github Actions ill update this.

Before this change output is:
image

@alimcmaster1
Copy link
Member Author

Output now looks better - but I need to fix the return code
image

isort --recursive --check-only pandas asv_bench
ISORT_CMD="isort --recursive --check-only pandas asv_bench"
if [[ "$GITHUB_ACTIONS" == "true" ]]; then
eval $ISORT_CMD | awk '{print "##[error]" $0}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
eval $ISORT_CMD | awk '{print "##[error]" $0}'
eval $ISORT_CMD | awk '{print "##[error]" $0}' ; $?=${PIPESTATUS[0]}

Not sure if you can do something like this, or similar, but this will consider the return of awk to fail the CI, and will always be 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this v. handy

Co-Authored-By: Marc Garcia <[email protected]>
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, happy to get this merged once you restore the import order

@alimcmaster1 alimcmaster1 reopened this Dec 4, 2019
@alimcmaster1
Copy link
Member Author

Related failures: #30031

@alimcmaster1
Copy link
Member Author

CI finally passed. @datapythonista @WillAyd to merge

@WillAyd WillAyd merged commit 0be70ee into pandas-dev:master Dec 6, 2019
@alimcmaster1
Copy link
Member Author

Thanks @WillAyd

proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
@alimcmaster1 alimcmaster1 deleted the mcmali-azure-isort branch December 25, 2019 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: Format isort output to be detected as Azure pipelines errors
3 participants