python.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # sync with https://github.com/fphammerle/ical2vdir/blob/master/.github/workflows/python.yml
  2. # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
  3. # shown in badge
  4. # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow#adding-a-workflow-status-badge-to-your-repository
  5. name: tests
  6. on:
  7. push:
  8. pull_request:
  9. schedule:
  10. - cron: '0 20 * * 5'
  11. jobs:
  12. code-format:
  13. runs-on: ubuntu-20.04
  14. strategy:
  15. matrix:
  16. python-verison: ['3.9']
  17. steps:
  18. - uses: actions/checkout@v2.3.4
  19. - uses: actions/setup-python@v2.2.2
  20. with:
  21. python-version: ${{ matrix.python-version }}
  22. - run: pip install --upgrade pipenv==2020.8.13
  23. - run: pipenv install --python "$PYTHON_VERSION" --deploy --dev
  24. env:
  25. PYTHON_VERSION: ${{ matrix.python-version }}
  26. - run: pipenv graph
  27. - run: pipenv run black --check .
  28. tests:
  29. runs-on: ubuntu-20.04
  30. strategy:
  31. matrix:
  32. python-version:
  33. - '3.6'
  34. - '3.7'
  35. - '3.8'
  36. - '3.9'
  37. pandas-version:
  38. - '' # locked version
  39. - 0.21.*
  40. - 0.22.*
  41. - 0.23.*
  42. - 0.24.*
  43. - 0.25.*
  44. - 1.1.* # python3.6
  45. - 1.*
  46. exclude:
  47. # https://github.com/pandas-dev/pandas/commit/83807088329b2a7e6422e0d0ba460870a265d3d2#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7R768
  48. - python-version: 3.6
  49. pandas-version: 1.*
  50. - python-version: 3.7
  51. pandas-version: 0.21.*
  52. - python-version: 3.7
  53. pandas-version: 0.22.*
  54. # > astroid.exceptions.AttributeInferenceError: '_constructor_expanddim' not found on <ClassDef.Series l.139 at 0x7f314baa6410>.
  55. # https://github.com/fphammerle/freesurfer-volume-reader/runs/1937182916
  56. - python-version: 3.7
  57. pandas-version: 1.1.*
  58. # >/tmp/pip-install-g4jx0np4/numpy/_configtest.c:6: undefined reference to `exp'
  59. # https://travis-ci.org/github/fphammerle/freesurfer-stats/jobs/683704331#L437
  60. - python-version: 3.8
  61. pandas-version: 0.21.*
  62. # https://travis-ci.org/github/fphammerle/freesurfer-stats/jobs/683704330#L437
  63. - python-version: 3.8
  64. pandas-version: 0.22.*
  65. # no python3.8 wheels for pandas v0.24.2 & v0.23.4 available
  66. # https://travis-ci.org/github/fphammerle/freesurfer-stats/builds/701952350
  67. # build takes longer than 10min
  68. # https://travis-ci.org/github/fphammerle/freesurfer-stats/jobs/702077404#L199
  69. - python-version: 3.8
  70. pandas-version: 0.23.*
  71. - python-version: 3.8
  72. pandas-version: 0.24.*
  73. # > astroid.exceptions.AttributeInferenceError: '_constructor_expanddim' not found on <ClassDef.Series l.139 at 0x7f314baa6410>.
  74. # https://github.com/fphammerle/freesurfer-volume-reader/runs/1937182916
  75. - python-version: 3.8
  76. pandas-version: 1.1.*
  77. - python-version: 3.9
  78. pandas-version: 0.21.*
  79. - python-version: 3.9
  80. pandas-version: 0.22.*
  81. - python-version: 3.9
  82. pandas-version: 0.23.*
  83. - python-version: 3.9
  84. pandas-version: 0.24.*
  85. # > Cython-generated file 'pandas/_libs/algos.c' not found.
  86. - python-version: 3.9
  87. pandas-version: 0.25.*
  88. fail-fast: false
  89. steps:
  90. - uses: actions/checkout@v2.3.4
  91. - uses: actions/setup-python@v2.2.2
  92. with:
  93. python-version: ${{ matrix.python-version }}
  94. - run: pip install --upgrade pipenv==2020.8.13
  95. # by default pipenv picks the latest version in PATH
  96. - run: pipenv --python "$(which python)" install --deploy --dev
  97. # `pipenv install --selective-upgrade "pandas==$PANDAS_VERSION"` was not effective
  98. - run: '[ -z "$PANDAS_VERSION" ] || pipenv run pip install "pandas==$PANDAS_VERSION"'
  99. env:
  100. PANDAS_VERSION: ${{ matrix.pandas-version }}
  101. - run: pipenv graph
  102. - run: pipenv run pytest --cov="$(cat *.egg-info/top_level.txt)" --cov-report=term-missing --cov-fail-under=100
  103. - run: pipenv run pylint --load-plugins=pylint_import_requirements "$(cat *.egg-info/top_level.txt)"
  104. # https://github.com/PyCQA/pylint/issues/352
  105. # disable parse-error due to:
  106. # > tests/resources/__init__.py:1:0: F0010: error while code parsing: Unable to load file tests/resources/__init__.py:
  107. # > [Errno 2] No such file or directory: 'tests/resources/__init__.py' (parse-error)
  108. - run: pipenv run pylint --disable=parse-error tests/*
  109. - run: pipenv run mypy "$(cat *.egg-info/top_level.txt)" tests
  110. # >=2.1.0 to support GITHUB_TOKEN
  111. # COVERALLS_REPO_TOKEN required manual configuration of secret
  112. # https://github.com/TheKevJames/coveralls-python/commit/f597109b62fadaf900af79d4f08a7debee5229e2
  113. - run: pip install 'coveralls>=2.1.0,<4'
  114. - run: coveralls
  115. env:
  116. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  117. # https://github.com/TheKevJames/coveralls-python/issues/240#issuecomment-758336355
  118. COVERALLS_SERVICE_NAME: github
  119. test-examples: # sync with https://github.com/fphammerle/freesurfer-surface/blob/dev/.github/workflows/python.yml#L73
  120. runs-on: ubuntu-18.04
  121. strategy:
  122. matrix:
  123. python-version:
  124. - '3.6'
  125. - '3.7'
  126. - '3.8'
  127. - '3.9'
  128. fail-fast: false
  129. defaults:
  130. run:
  131. working-directory: examples/
  132. steps:
  133. - uses: actions/checkout@v2.3.4
  134. - uses: actions/setup-python@v1
  135. with:
  136. python-version: ${{ matrix.python-version }}
  137. - run: pip install --upgrade pipenv==2020.8.13
  138. - run: pipenv --python "$(which python)" install --deploy --dev
  139. # > RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
  140. - run: python3 -c 'import sys; sys.exit(sys.version_info >= (3, 8))'
  141. || pipenv run pip install --no-deps numpy==1.20.1
  142. - run: pipenv graph
  143. # > the default behaviour is to abort conversion [...] if one of the cells throws an error
  144. - run: pipenv run jupyter nbconvert --execute --inplace *.ipynb
  145. # revert line specifying version of python interpreter
  146. - run: sudo apt-get update
  147. - run: sudo apt-get install --yes --no-install-recommends patchutils
  148. - run: >-
  149. git diff --unified=0
  150. | grepdiff --output-matching=hunk '^\( "version":\| "execution": {\| "<img src=\\"data:image/png;base64,\)'
  151. | patch --reverse
  152. - run: git diff --exit-code