Skip to content

CI: Linting with azure instead of travis #22854

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 120 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
46620f2
Moving one-line linting and checks from lint.sh to azure steps
datapythonista Sep 27, 2018
dc8c528
Moving everything from lint.sh to azure (so far repeating the command…
datapythonista Sep 27, 2018
adeb0ca
Fixing continueOnError settings
datapythonista Sep 27, 2018
dcfb203
Reverting the exit status of the grep commands, we want them to fail …
datapythonista Sep 27, 2018
b765df8
Testing the continueOnError, doesn't seem to be working at job level,…
datapythonista Sep 27, 2018
3c77fc9
Escaping exclamation marks to reverse the exist status of grep, azure…
datapythonista Sep 27, 2018
3d8af7d
Adding the continueOnError to every step, and trying if bash instead …
datapythonista Sep 27, 2018
ed1064d
Fixes to missing continueOnError, and to the grep command exit status
datapythonista Sep 27, 2018
8cb7b0f
Testing couple of ways to invert the exit status of grep
datapythonista Sep 27, 2018
dee5a08
Fixing azure config syntax error
datapythonista Sep 27, 2018
54f9e98
Fixing the checks (they should be ok now), and adding an intentional …
datapythonista Sep 27, 2018
20cb360
Removing intentional pep8 issue, and fixing last known problems
datapythonista Sep 27, 2018
50d2757
fixing style of azure settings
datapythonista Sep 27, 2018
19a213c
Replacing continueOnError (that converts errors in warnings) to condi…
datapythonista Sep 29, 2018
0cf5da9
Fixing multiline in yaml, and removing job level continueOnError
datapythonista Sep 29, 2018
4d10702
Changing the format of flake8 output to azure (so it creates links, a…
datapythonista Sep 30, 2018
a356f03
Removing unnecessary quotes in flake8 format config
datapythonista Sep 30, 2018
50cb867
flake8 format breaks pip (ConfigParser) when present in setup.cfg, mo…
datapythonista Sep 30, 2018
091193c
Adding azure formatting to all failing flake8
datapythonista Sep 30, 2018
4a2ddba
Merging from master
datapythonista Oct 10, 2018
e7c276a
Fixing azure job name
datapythonista Oct 10, 2018
8f73c08
Making the format look good for flake8 and patterns, and adding file …
datapythonista Oct 12, 2018
87b5048
Trying if environment variables can be defined in the script setting
datapythonista Oct 12, 2018
dc2e3a6
Merging from master
datapythonista Nov 4, 2018
5ab03ab
Removing file with errors to be displayed, and comment in the setup.cfg
datapythonista Nov 4, 2018
ca9e12a
Changing cython cast grep to invgrep
datapythonista Nov 4, 2018
c591a17
Merging from master
datapythonista Nov 9, 2018
c671da5
Building source of the checks build and moving the documentation buil…
datapythonista Nov 9, 2018
a6eed3e
Adding dependencies file for the checks and doc build
datapythonista Nov 9, 2018
3b853f9
Renaming conda yaml env variable
datapythonista Nov 9, 2018
850202d
Fixing env variables to set up conda
datapythonista Nov 9, 2018
a896532
Debugging why azure is not installing desired dependencies
datapythonista Nov 9, 2018
bed55be
Fixing once more env variables
datapythonista Nov 9, 2018
e555ce0
Fixing indentation in dependencies file
datapythonista Nov 9, 2018
101f7f3
Adding missing env variables and dependencies
datapythonista Nov 10, 2018
fce22e6
Fixing unset env variables for the doc build
datapythonista Nov 10, 2018
167f6dc
Fixing directory for the doc build script
datapythonista Nov 10, 2018
d44f189
WIP: Testing a simpler way to build and upload the documentation
datapythonista Nov 10, 2018
906da22
Printing installed dependencies in checks job (temporary, to debug py…
datapythonista Nov 10, 2018
9fb3999
Printing installed dependencies in azure, for debugging
datapythonista Nov 11, 2018
c72c0e5
Fixing bug when uploading the docs to github pages
datapythonista Nov 11, 2018
de1f52f
Adding an extra error to the validation of docstrings, as it's been f…
datapythonista Nov 11, 2018
e4aa371
Adding new docstring error code to the validation, and tests with the…
datapythonista Nov 11, 2018
f33b6e6
Merging from master
datapythonista Nov 12, 2018
63cfd5b
Generating the script of the deps check in azure format
datapythonista Nov 12, 2018
eb558df
Publishing docs with azure artifacts instead of github pages, and add…
datapythonista Nov 12, 2018
371f06e
Removing unnecessary checks on travis on whether the doc is being bui…
datapythonista Nov 13, 2018
ca6e910
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 13, 2018
d262a04
Debugging why pyqt is not being installed
datapythonista Nov 13, 2018
fc4574c
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 13, 2018
168ec55
Adding section names check to validate docstrings, now that all wrong…
datapythonista Nov 13, 2018
2f1b270
Fixing conda install pyqt for debugging
datapythonista Nov 13, 2018
798698d
Merging from master
datapythonista Nov 19, 2018
a3f601c
Using github pages to publish the documentation
datapythonista Nov 19, 2018
5ea21c6
Testing if linux variables can be defined once for the whole job
datapythonista Nov 19, 2018
46d281c
Using env for the environment variables, and implemented azure storag…
datapythonista Nov 19, 2018
faf49e9
Fixing typo
datapythonista Nov 19, 2018
fa4f16c
Setting environment variables at the beginning of the job, and adding…
datapythonista Nov 19, 2018
c05f6b7
Fixing /home/mgarcia/miniconda3/envs/pandas-dev/bin:/home/mgarcia/min…
datapythonista Nov 19, 2018
9162aeb
Fixed typo in PATH
datapythonista Nov 19, 2018
5640907
Formatting flake8-rst output for azure
datapythonista Nov 19, 2018
0286099
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 20, 2018
629a209
Updating azure connection string
datapythonista Nov 20, 2018
588d153
Checking if environment.yml can be used for the docs and checks build…
datapythonista Nov 20, 2018
bc9c3b3
Remove unused stuff from azure config
datapythonista Nov 20, 2018
324b1e2
Doing checks as soon as possible (before conda, before build)
datapythonista Nov 20, 2018
5bf1709
Fixing build errors (typo in dependencies, missing cpplint, code chec…
datapythonista Nov 20, 2018
7cf2d68
Addapting generate_pip_deps_from_conda.py to support pip dependencies…
datapythonista Nov 20, 2018
2f8441e
Setting DISPLAY env to see if that fixes the to_clipboard problem
datapythonista Nov 20, 2018
30ba23e
Consistent way to source the conda environment
datapythonista Nov 20, 2018
85172b3
Fixing typo in environment name, and removing pyqt debug info
datapythonista Nov 20, 2018
450f84a
Adding checkpoints to see where the docstests change the exit status
datapythonista Nov 20, 2018
7b4b1ea
Restoring required html5lib dependency
datapythonista Nov 20, 2018
5d69e8b
Removing travis doc job
datapythonista Nov 20, 2018
3ce1aa0
Removing linting comments, and token for the docs from travis
datapythonista Nov 20, 2018
ee01df4
removing checkpoints and increasing verbosity of failing doctests
datapythonista Nov 20, 2018
e353e8a
Restoring bf4 in travis deps, as it's required, and fixing the to_cli…
datapythonista Nov 21, 2018
92a3921
Moving scripts unit tests to azure
datapythonista Nov 21, 2018
9e34037
Adding conda environment to run scripts tests, and changing verbosity…
datapythonista Nov 21, 2018
5a82f59
Using connection string secret variable instead of composing it in th…
datapythonista Nov 21, 2018
6cbb31b
Adding benchmark run to the CI
datapythonista Nov 22, 2018
2617696
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 22, 2018
75ad473
Adding git remote for the benchmarks, and removing connection string …
datapythonista Nov 22, 2018
7af04e1
Providing azure storage info as arguments instead of env, and fetchin…
datapythonista Nov 22, 2018
cc4331c
Trying to fix benchmarks and azure storage issues
datapythonista Nov 22, 2018
c5df401
Testing if azure storage key has a missing =, and setting up machine …
datapythonista Nov 22, 2018
4eac8bb
More changes to the doc upload and the benchmarks, to try to make the…
datapythonista Nov 22, 2018
00032d1
More fixes to doc upload and benchmarks
datapythonista Nov 22, 2018
e9ab754
Adding debug info for the docs upload and the benchmarks
datapythonista Nov 22, 2018
e47b4e1
Fixing bug in benchmarks set up, and fixing docstring errors, so vali…
datapythonista Nov 22, 2018
d0d4ae1
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 23, 2018
a225d44
Clean up of debug info
datapythonista Nov 23, 2018
d6d5c66
Uploading docs to GitHub pages in the same way as travis
datapythonista Nov 23, 2018
f7a6048
Adding variable group to the job config, to see if that makes them ac…
datapythonista Nov 23, 2018
9aa18d0
WIP: Restoring travis documentation build
datapythonista Nov 23, 2018
283233d
Restoing documentation build in travis
datapythonista Nov 23, 2018
991304d
Removing variable group, as variables are not in a group anymore, and…
datapythonista Nov 27, 2018
3a71185
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 27, 2018
19c396f
Adding missing conda environment activation
datapythonista Nov 27, 2018
a69e667
Fixing docstring errors
datapythonista Nov 27, 2018
59d55d8
Removing documentation build from azure
datapythonista Nov 28, 2018
df50c58
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 28, 2018
455e77c
Adding debug info to diagnose /home/mgarcia/miniconda3/bin:/home/mgar…
datapythonista Nov 28, 2018
7f48ac2
adding more debug information
datapythonista Nov 28, 2018
078a987
Revert "Removing documentation build from azure"
datapythonista Nov 28, 2018
d7883a1
Clean up of debug commands
datapythonista Nov 28, 2018
c2be491
Removing doc build in azure (restored because of the path problem)
datapythonista Nov 28, 2018
910825a
Building docs in azure, and uploading them to azure storage if it's a…
datapythonista Nov 29, 2018
35c7d99
Merge remote-tracking branch 'upstream/master' into azure_lint
datapythonista Nov 30, 2018
d321a42
Merging from master
datapythonista Nov 30, 2018
4328b04
Fixing pending docstrings
datapythonista Dec 1, 2018
4c57f48
Updating dependencies with the version that fixes the speed problems
datapythonista Dec 1, 2018
497f032
Updating pip requirements
datapythonista Dec 1, 2018
c88911a
Always uploading docs (removed if to test if uploading the docs work …
datapythonista Dec 1, 2018
75b89eb
Adding parallelization to build and docs
datapythonista Dec 1, 2018
011950e
Removing documentation build in azure, and reverting using more than …
datapythonista Dec 1, 2018
01942b9
Made an invgrep a newly added pattern validation
datapythonista Dec 1, 2018
0a14165
Merging from master
datapythonista Dec 1, 2018
705eb9d
Regenerating pip dependencies
datapythonista Dec 1, 2018
498cebb
Merging from master
datapythonista Dec 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ matrix:
- python-gtk2
- dist: trusty
env:
- JOB="3.6, lint, coverage" ENV_FILE="ci/deps/travis-36.yaml" TEST_ARGS="--skip-slow --skip-network" PANDAS_TESTING_MODE="deprecate" COVERAGE=true LINT=true
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36.yaml" TEST_ARGS="--skip-slow --skip-network" PANDAS_TESTING_MODE="deprecate" COVERAGE=true
- dist: trusty
env:
- JOB="3.7, NumPy dev" ENV_FILE="ci/deps/travis-37-numpydev.yaml" TEST_ARGS="--skip-slow --skip-network -W error" PANDAS_TESTING_MODE="deprecate"
Expand Down Expand Up @@ -109,7 +109,6 @@ script:
- ci/run_build_docs.sh
- ci/script_single.sh
- ci/script_multi.sh
- ci/code_checks.sh

after_success:
- ci/upload_coverage.sh
Expand Down
157 changes: 157 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,160 @@ jobs:
parameters:
name: WindowsPy27
vmImage: vs2017-win2016

- job: 'Checks_and_doc'
pool:
vmImage: ubuntu-16.04
timeoutInMinutes: 90
steps:
- script: |
# XXX not sure why setting $PATH here does not work
# echo '##vso[task.setvariable variable=PATH]$HOME/miniconda3/bin:$PATH'
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, you can echo "##vso[task.prependpath]$HOME/miniconda3/bin" here to make the path change durable for the job.

echo '##vso[task.setvariable variable=CONDA_ENV]pandas-dev'
echo '##vso[task.setvariable variable=ENV_FILE]environment.yml'
echo '##vso[task.setvariable variable=AZURE]true'
displayName: 'Setting environment variables'

# Do not require a conda environment
- script: |
export PATH=$HOME/miniconda3/bin:$PATH
ci/code_checks.sh patterns
displayName: 'Looking for unwanted patterns'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
sudo apt-get install -y libc6-dev-i386
ci/incremental/install_miniconda.sh
ci/incremental/setup_conda_environment.sh
displayName: 'Set up environment'

# Do not require pandas
- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/code_checks.sh lint
displayName: 'Linting'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/code_checks.sh dependencies
displayName: 'Dependencies consistency'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/incremental/build.sh
displayName: 'Build'
condition: true

# Require pandas
- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/code_checks.sh code
displayName: 'Checks on imported code'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/code_checks.sh doctests
displayName: 'Running doctests'
condition: true
Copy link
Member

@gfyoung gfyoung Dec 3, 2018

Choose a reason for hiding this comment

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

Hmm...IMO, I think running doctests should be a separate build entirely from linting. They are two semantically different things, and the separation would allow us to provide more semantically clear display names such as "Doctests" and "Linting" instead of the slightly vaguer mashup of "Checks_and_doc".

Copy link
Member

@gfyoung gfyoung Dec 3, 2018

Choose a reason for hiding this comment

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

I see there was a concern about not having to use an extra build for this due to resource constraints (the conversation is a very long in this PR...)? However, I'm not sure I fully understand...

Also, based on the conversation, are the master docs no longer being published on https://pandas-docs.github.io/pandas-docs-travis? In which case, we need to update the GITHUB_ISSUE template that we have here.


- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/code_checks.sh docstrings
displayName: 'Docstring validation'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
pytest --capture=no --strict scripts
displayName: 'Testing docstring validaton script'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
doc/make.py html
displayName: 'Building docs'
condition: true

- script: |
if [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
export NAME="master"
else
export NAME=$(System.PullRequest.PullRequestId)
fi
az extension add --name storage-preview
az storage blob upload-batch --connection-string $CONNECTION_STRING \
Copy link
Contributor

@vtbassmatt vtbassmatt Nov 27, 2018

Choose a reason for hiding this comment

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

A difference I see is that I'm relying on az's inherent use of an environment variable called AZURE_STORAGE_CONNECTION_STRING. My secret is called CONNECTION_STRING, and I map it into the script block like this:

- script: |
    az extension add --name storage-preview
    az storage blob upload-batch -s some/path/ -d '$web'
  env:
    AZURE_STORAGE_CONNECTION_STRING: $(CONNECTION_STRING)

But I think this may be a red herring... will reply with another comment on what I think is going on.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI @datapythonista the correct environment variable is now called AZURE_STORAGE_CONNECTION_STRING, so you may be able to delete this.

Copy link
Contributor

Choose a reason for hiding this comment

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

(In the process of writing out the below instructions, I just realized what's happening. Will follow up with another comment.)

Since the pipeline variable now has the correct name, this should work:

  - script: |
      if [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
          export NAME="master"
      else
          export NAME=$(System.PullRequest.PullRequestId)
      fi
      az extension add --name storage-preview
      az storage blob upload-batch --source $SOURCE \
                                   --destination '$web'
                                   --destination-path "docs/$NAME"
    displayName: 'Publishing docs (Azure storage)'
    condition: true
    env:
      AZURE_STORAGE_CONNECTION_STRING: $(AZURE_STORAGE_CONNECTION_STRING)  # this should map in the secret explicitly
      SOURCE: $(Build.SourcesDirectory)/doc/build/html/

--source $SOURCE \
--destination $DESTINATION \
--destination-path $NAME
echo "Documentation uploaded to https://pandas.blob.core.windows.net/docs/$NAME"
displayName: 'Publishing docs (Azure storage)'
condition: true
env:
CONNECTION_STRING: $(AZURE_STORAGE_CONNECTION_STRING)
SOURCE: $(Build.SourcesDirectory)/doc/build/html/
DESTINATION: 'docs'
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize we haven't gotten to the bottom of the secrets/connection string thing, but also, the Azure static sites feature requires that your destination container be the string $web. I suspect you can publish a docs folder within that container.


- script: |
echo "Publishing documentation to GitHub pages is still done in Travis"
exit 0
if [ "$(Build.SourceBranch)" == "refs/heads/master" ]; then
mkdir -p $REPO_DIR
rm -rf $REPO_DIR/*
cp -r doc/build/html/* $REPO_DIR/
cd $REPO_DIR
git config --global user.email "[email protected]"
git config --global user.name "pandas-docs-bot"
git init
touch README
git add README
git commit -m "Initial commit" --allow-empty
git branch gh-pages
git checkout gh-pages
touch .nojekyll
git add --all .
git commit -m "Version" --allow-empty
git remote remove origin
git remote add origin "https://${TOKEN}@github.com/pandas-dev/pandas-docs-travis.git"
git fetch origin
git remote -v
git push origin gh-pages -f
fi
displayName: 'Publishing docs (GitHub pages)'
condition: true
env:
REPO_DIR: $(Build.ArtifactStagingDirectory)/pandas-docs-travis
TOKEN: $(GITHUB_DOCS_TOKEN)

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
git remote add upstream https://github.com/pandas-dev/pandas.git
git fetch upstream
if git diff upstream/master --name-only | grep -q "^asv_bench/"; then
cd asv_bench
asv machine --yes
ASV_OUTPUT="$(asv dev)"
if [[ $(echo "$ASV_OUTPUT" | grep "failed") ]]; then
echo "##vso[task.logissue type=error]Benchmarks run with errors"
echo $ASV_OUTPUT
exit 1
else
echo "Benchmarks run without errors"
fi
else
echo "Benchmarks did not run, no changes detected"
fi
displayName: 'Running benchmarks'
condition: true
Copy link
Member

@gfyoung gfyoung Dec 3, 2018

Choose a reason for hiding this comment

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

Why did you add running benchmarks when the original issue was just to migrate lint.sh to Azure? IMO, this should have been considered in a separate PR.

Also, as your changes did not actually modify any Python benchmark code, it was not possible to review how it would look in the Azure logs. This log here from another PR (#23752) is unfortunately impossible to read:

https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=4580

Copy link
Member

@gfyoung gfyoung Dec 3, 2018

Choose a reason for hiding this comment

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

Also, it's somewhat debatable as to whether we even want to just run benchmarks when there's only a diff in asv_bench. We often ask people to run asv whenever there are changes to C and Cython code in general, just to make sure that no benchmarks were affected as a result of the changes.

83 changes: 61 additions & 22 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,48 @@
# This script is intended for both the CI and to check locally that code standards are
# respected. We are currently linting (PEP-8 and similar), looking for patterns of
# common mistakes (sphinx directives with missing blank lines, old style classes,
# unwanted imports...), and we also run doctests here (currently some files only).
# In the future we may want to add the validation of docstrings and other checks here.
# unwanted imports...), we run doctests here (currently some files only), and we
# validate formatting error in docstrings.
#
# Usage:
# $ ./ci/code_checks.sh # run all checks
# $ ./ci/code_checks.sh lint # run linting only
# $ ./ci/code_checks.sh patterns # check for patterns that should not exist
# $ ./ci/code_checks.sh code # checks on imported code
# $ ./ci/code_checks.sh doctests # run doctests
# $ ./ci/code_checks.sh docstrings # validate docstring errors
# $ ./ci/code_checks.sh dependencies # check that dependencies are consistent

echo "inside $0"
[[ $LINT ]] || { echo "NOT Linting. To lint use: LINT=true $0 $1"; exit 0; }
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "doctests" || "$1" == "dependencies" ]] \
|| { echo "Unknown command $1. Usage: $0 [lint|patterns|doctests|dependencies]"; exit 9999; }
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "dependencies" ]] || \
{ echo "Unknown command $1. Usage: $0 [lint|patterns|code|doctests|docstrings|dependencies]"; exit 9999; }

BASE_DIR="$(dirname $0)/.."
RET=0
CHECK=$1

function invgrep {
# grep with inverse exist status and formatting for azure-pipelines
#
# This function works exactly as grep, but with opposite exit status:
# - 0 (success) when no patterns are found
# - 1 (fail) when the patterns are found
#
# This is useful for the CI, as we want to fail if one of the patterns
# that we want to avoid is found by grep.
if [[ "$AZURE" == "true" ]]; then
set -o pipefail
grep -n "$@" | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Found unwanted pattern: " $3}'
else
grep "$@"
fi
return $((! $?))
}

if [[ "$AZURE" == "true" ]]; then
FLAKE8_FORMAT="##vso[task.logissue type=error;sourcepath=%(path)s;linenumber=%(row)s;columnnumber=%(col)s;code=%(code)s;]%(text)s"
else
FLAKE8_FORMAT="default"
fi

### LINTING ###
if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
Expand All @@ -35,30 +58,30 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then

# pandas/_libs/src is C code, so no need to search there.
MSG='Linting .py code' ; echo $MSG
flake8 .
flake8 --format="$FLAKE8_FORMAT" .
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pyx code' ; echo $MSG
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
flake8 --format="$FLAKE8_FORMAT" pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pxd and .pxi.in' ; echo $MSG
flake8 pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
flake8 --format="$FLAKE8_FORMAT" pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
RET=$(($RET + $?)) ; echo $MSG "DONE"

echo "flake8-rst --version"
flake8-rst --version

MSG='Linting code-blocks in .rst documentation' ; echo $MSG
flake8-rst doc/source --filename=*.rst
flake8-rst doc/source --filename=*.rst --format="$FLAKE8_FORMAT"
RET=$(($RET + $?)) ; echo $MSG "DONE"

# Check that cython casting is of the form `<type>obj` as opposed to `<type> obj`;
# it doesn't make a difference, but we want to be internally consistent.
# Note: this grep pattern is (intended to be) equivalent to the python
# regex r'(?<![ ->])> '
MSG='Linting .pyx code for spacing conventions in casting' ; echo $MSG
! grep -r -E --include '*.pyx' --include '*.pxi.in' '[a-zA-Z0-9*]> ' pandas/_libs
invgrep -r -E --include '*.pyx' --include '*.pxi.in' '[a-zA-Z0-9*]> ' pandas/_libs
RET=$(($RET + $?)) ; echo $MSG "DONE"

# readability/casting: Warnings about C casting instead of C++ casting
Expand Down Expand Up @@ -88,43 +111,48 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then

# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
MSG='Check for non-standard imports' ; echo $MSG
! grep -R --include="*.py*" -E "from pandas.core.common import " pandas
invgrep -R --include="*.py*" -E "from pandas.core.common import " pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for pytest warns' ; echo $MSG
! grep -r -E --include '*.py' 'pytest\.warns' pandas/tests/
invgrep -r -E --include '*.py' 'pytest\.warns' pandas/tests/
RET=$(($RET + $?)) ; echo $MSG "DONE"

# Check for the following code in testing: `np.testing` and `np.array_equal`
MSG='Check for invalid testing' ; echo $MSG
! grep -r -E --include '*.py' --exclude testing.py '(numpy|np)(\.testing|\.array_equal)' pandas/tests/
invgrep -r -E --include '*.py' --exclude testing.py '(numpy|np)(\.testing|\.array_equal)' pandas/tests/
RET=$(($RET + $?)) ; echo $MSG "DONE"

# Check for the following code in the extension array base tests: `tm.assert_frame_equal` and `tm.assert_series_equal`
MSG='Check for invalid EA testing' ; echo $MSG
! grep -r -E --include '*.py' --exclude base.py 'tm.assert_(series|frame)_equal' pandas/tests/extension/base
invgrep -r -E --include '*.py' --exclude base.py 'tm.assert_(series|frame)_equal' pandas/tests/extension/base
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for deprecated messages without sphinx directive' ; echo $MSG
! grep -R --include="*.py" --include="*.pyx" -E "(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)" pandas
invgrep -R --include="*.py" --include="*.pyx" -E "(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)" pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for old-style classes' ; echo $MSG
! grep -R --include="*.py" -E "class\s\S*[^)]:" pandas scripts
invgrep -R --include="*.py" -E "class\s\S*[^)]:" pandas scripts
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for backticks incorrectly rendering because of missing spaces' ; echo $MSG
! grep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/
invgrep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for incorrect sphinx directives' ; echo $MSG
! grep -R --include="*.py" --include="*.pyx" --include="*.rst" -E "\.\. (autosummary|contents|currentmodule|deprecated|function|image|important|include|ipython|literalinclude|math|module|note|raw|seealso|toctree|versionadded|versionchanged|warning):[^:]" ./pandas ./doc/source
invgrep -R --include="*.py" --include="*.pyx" --include="*.rst" -E "\.\. (autosummary|contents|currentmodule|deprecated|function|image|important|include|ipython|literalinclude|math|module|note|raw|seealso|toctree|versionadded|versionchanged|warning):[^:]" ./pandas ./doc/source
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check that the deprecated `assert_raises_regex` is not used (`pytest.raises(match=pattern)` should be used instead)' ; echo $MSG
! grep -R --exclude=*.pyc --exclude=testing.py --exclude=test_testing.py assert_raises_regex pandas
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed an invgrep here.

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 @h-vetinari, that was added later, and I didn't see it after merging from master. Well spotted, I fixed it.

RET=$(($RET + $?)) ; echo $MSG "DONE"

fi

### CODE ###
if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then

MSG='Check for modules that pandas should not import' ; echo $MSG
python -c "
import sys
Expand All @@ -135,7 +163,7 @@ blacklist = {'bs4', 'gcsfs', 'html5lib', 'ipython', 'jinja2' 'hypothesis',
'tables', 'xlrd', 'xlsxwriter', 'xlwt'}
mods = blacklist & set(m.split('.')[0] for m in sys.modules)
if mods:
sys.stderr.write('pandas should not import: {}\n'.format(', '.join(mods)))
sys.stderr.write('err: pandas should not import: {}\n'.format(', '.join(mods)))
sys.exit(len(mods))
"
RET=$(($RET + $?)) ; echo $MSG "DONE"
Expand All @@ -157,7 +185,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then

MSG='Doctests generic.py' ; echo $MSG
pytest -q --doctest-modules pandas/core/generic.py \
-k"-_set_axis_name -_xs -describe -droplevel -groupby -interpolate -pct_change -pipe -reindex -reindex_axis -to_json -transpose -values -xs"
-k"-_set_axis_name -_xs -describe -droplevel -groupby -interpolate -pct_change -pipe -reindex -reindex_axis -to_json -transpose -values -xs -to_clipboard"
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Doctests top-level reshaping functions' ; echo $MSG
Expand All @@ -178,11 +206,22 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then

fi

### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Validate docstrings (GL06, SS04, PR03, PR05, EX04)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,SS04,PR03,PR05,EX04
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi

### DEPENDENCIES ###
if [[ -z "$CHECK" || "$CHECK" == "dependencies" ]]; then

MSG='Check that requirements-dev.txt has been generated from environment.yml' ; echo $MSG
$BASE_DIR/scripts/generate_pip_deps_from_conda.py --compare
$BASE_DIR/scripts/generate_pip_deps_from_conda.py --compare --azure
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi

exit $RET
9 changes: 0 additions & 9 deletions ci/deps/travis-36.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ dependencies:
- cython>=0.28.2
- dask
- fastparquet
- flake8>=3.5
- flake8-comprehensions
- flake8-rst=0.4.2
- gcsfs
- geopandas
- html5lib
- ipython
- isort
- jinja2
- lxml
- matplotlib
- nomkl
- numexpr
Expand All @@ -32,7 +25,6 @@ dependencies:
- s3fs
- scikit-learn
- scipy
- seaborn
- sqlalchemy
- statsmodels
- xarray
Expand All @@ -48,6 +40,5 @@ dependencies:
- pip:
- brotlipy
- coverage
- cpplint
- pandas-datareader
- python-dateutil
Loading