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

Pre-commit tests are skipped #860

Closed
szoupanos opened this issue Oct 26, 2017 · 3 comments · Fixed by #863
Closed

Pre-commit tests are skipped #860

szoupanos opened this issue Oct 26, 2017 · 3 comments · Fixed by #863
Assignees

Comments

@szoupanos
Copy link
Contributor

I have the following .pre-commit-config.yaml

# yet another python formatter
- repo: git://github.com/pre-commit/mirrors-yapf
  sha: v0.17.0
  hooks:
  - id: yapf
    language: system
    files: >-
      ^(aiida/control/)
      |(aiida/cmdline/tests)
      |(aiida/cmdline/commands/share.py)
      |(docs/update_req_for_rtd.py)
      |(.travis_data/test_setup.py)
      |(aiida/backends/tests/verdi_commands.py)
      |(aiida/utils/.*fixtures.py)

# prospector: collection of linters
- repo: git://github.com/guykisel/prospector-mirror
  sha: b27f281eb9398fc8504415d7fbdabf119ea8c5e1
  hooks:
  - id: prospector
    language: system
    exclude: '^(tests/)|(examples/)'
    files: >-
      ^(aiida/control/)
      |(aiida/cmdline/tests)
      |(aiida/cmdline/commands/share.py)
      |(docs/update_req_for_rtd.py)
      |(.travis_data/test_setup.py)
      |(aiida/backends/tests/verdi_commands.py)
      |(aiida/utils/.*fixtures.py)

- repo: local
  hooks: 
  - id: rtd-requirements
    name: Requirements for RTD
    entry: python ./docs/update_req_for_rtd.py --pre-commit
    language: system
    files: >-
      ^(setup_requirements.py)
      |(docs/requirements_for_rtd.txt)
      |(docs/update_req_for_rtd.py)
    pass_filenames: false

- repo: git://github.com/pre-commit/pre-commit-hooks
  sha: v0.9.4
  hooks:
  - id: check-yaml

- repo: local
  hooks:
  - id: travis-linter
    name: travis
    entry: travis lint
    files: .travis.yml
    language: ruby
    additional_dependencies: ['travis']

and for some reason the yap & the prospector tests are skipped (even if my file is in the corresponding lists)

E.g.

(aiidapy) aiida@ubuntu-aiida-vm1:~/aiida-code/aiida_core$ git add .
(aiidapy) aiida@ubuntu-aiida-vm1:~/aiida-code/aiida_core$ pre-commit
yapf.................................................(no files to check)Skipped
prospector...........................................(no files to check)Skipped
Requirements for RTD.................................(no files to check)Skipped
Check Yaml...............................................................Passed
travis...............................................(no files to check)Skipped
@DropD
Copy link
Contributor

DropD commented Oct 26, 2017 via email

@ltalirz
Copy link
Member

ltalirz commented Oct 26, 2017

seems like it's my fault - sorry about that! I wanted to split the string over multiple lines and I thought it worked, but when I change it back to a single line, it checks also the single .py files again.
I'll have a look.

@ltalirz
Copy link
Member

ltalirz commented Oct 26, 2017

If one can believe this post on stackoverflow, then the problem might be that with >-, line feeds aren't simply removed, but are replaced by single spaces.

An alternative way of still splitting the lines that works for me is

   files: "\
      ^aiida/control/\
      |aiida/cmdline/tests\
      |docs/update_req_for_rtd.py\
      |.travis_data/test_setup.py\
      |aiida/backends/tests/verdi_commands.py\
      |aiida/utils/.*fixtures.py\
      "

Not the most pretty solution, but still a lot better than having everything on one line.

Note that I also removed the brackets, since they didn't seem to be necessary for the cases I tested (both folders and single files).

Let me know whether it works for you and feel free to change it in your next pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants