python.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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-version: ['3.9']
  17. steps:
  18. - uses: actions/checkout@v3
  19. - uses: actions/setup-python@v4
  20. with:
  21. python-version: ${{ matrix.python-version }}
  22. - run: pip install --upgrade pipenv==2022.9.21
  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.7'
  34. - '3.8'
  35. - '3.9'
  36. - '3.10'
  37. pandas-version:
  38. - '' # locked version
  39. - 0.23.*
  40. - 0.24.*
  41. - 0.25.*
  42. - 1.1.* # pandas does not use semantic versioning
  43. - 1.*
  44. exclude:
  45. # > astroid.exceptions.AttributeInferenceError: '_constructor_expanddim' not found on <ClassDef.Series l.139 at 0x7f314baa6410>.
  46. # https://github.com/fphammerle/freesurfer-volume-reader/runs/1937182916
  47. - python-version: 3.7
  48. pandas-version: 1.1.*
  49. # no python3.8 wheels for pandas v0.24.2 & v0.23.4 available
  50. # https://travis-ci.org/github/fphammerle/freesurfer-stats/builds/701952350
  51. # build takes longer than 10min
  52. # https://travis-ci.org/github/fphammerle/freesurfer-stats/jobs/702077404#L199
  53. - python-version: 3.8
  54. pandas-version: 0.23.*
  55. - python-version: 3.8
  56. pandas-version: 0.24.*
  57. # > astroid.exceptions.AttributeInferenceError: '_constructor_expanddim' not found on <ClassDef.Series l.139 at 0x7f314baa6410>.
  58. # https://github.com/fphammerle/freesurfer-volume-reader/runs/1937182916
  59. - python-version: 3.8
  60. pandas-version: 1.1.*
  61. - python-version: 3.9
  62. pandas-version: 0.23.*
  63. - python-version: 3.9
  64. pandas-version: 0.24.*
  65. # > Cython-generated file 'pandas/_libs/algos.c' not found.
  66. - python-version: 3.9
  67. pandas-version: 0.25.*
  68. - python-version: '3.10'
  69. pandas-version: 0.23.*
  70. - python-version: '3.10'
  71. pandas-version: 0.24.*
  72. - python-version: '3.10'
  73. pandas-version: 0.25.*
  74. - python-version: '3.10'
  75. pandas-version: 1.1.* # building for >4min
  76. fail-fast: false
  77. steps:
  78. - uses: actions/checkout@v3
  79. - uses: actions/setup-python@v4
  80. with:
  81. python-version: ${{ matrix.python-version }}
  82. - run: pip install --upgrade pipenv==2022.9.21
  83. # by default pipenv picks the latest version in PATH
  84. - run: pipenv install --python "$PYTHON_VERSION" --deploy --dev
  85. env:
  86. PYTHON_VERSION: ${{ matrix.python-version }}
  87. # > TypeError: Cannot interpret '<attribute 'dtype' of 'numpy.generic' objects>' as a data type
  88. - run: pipenv run pip install numpy==1.19.5
  89. if: startsWith(matrix.pandas-version, '0.')
  90. # `pipenv install --selective-upgrade "pandas==$PANDAS_VERSION"` was not effective
  91. - run: '[ -z "$PANDAS_VERSION" ] || pipenv run pip install "pandas==$PANDAS_VERSION"'
  92. env:
  93. PANDAS_VERSION: ${{ matrix.pandas-version }}
  94. - run: pipenv graph
  95. - run: pipenv run pytest --cov="$(cat *.egg-info/top_level.txt)" --cov-report=term-missing --cov-fail-under=100
  96. - run: pipenv run pylint --load-plugins=pylint_import_requirements "$(cat *.egg-info/top_level.txt)"
  97. # workaround pylint reporting:
  98. # > E0401: Unable to import 'freesurer_volume_reader' (import-error)
  99. # pyproject.toml broken?
  100. - run: >-
  101. printenv GITHUB_WORKSPACE
  102. | tee "$(pipenv --venv)/lib/python${PYTHON_VERSION}/site-packages/easy-install.pth"
  103. env:
  104. PYTHON_VERSION: ${{ matrix.python-version }}
  105. - run: pipenv run pylint tests
  106. - run: pipenv run mypy "$(cat *.egg-info/top_level.txt)" tests
  107. # >=2.1.0 to support GITHUB_TOKEN
  108. # COVERALLS_REPO_TOKEN required manual configuration of secret
  109. # https://github.com/TheKevJames/coveralls-python/commit/f597109b62fadaf900af79d4f08a7debee5229e2
  110. - run: pip install 'coveralls>=2.1.0,<4'
  111. - run: coveralls
  112. env:
  113. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  114. # https://github.com/TheKevJames/coveralls-python/issues/240#issuecomment-758336355
  115. COVERALLS_SERVICE_NAME: github
  116. install:
  117. runs-on: ubuntu-20.04
  118. steps:
  119. - uses: actions/checkout@v3
  120. - uses: actions/setup-python@v4
  121. with: {python-version: 3.9}
  122. - run: '! freesurfer-volume-reader --help'
  123. - run: pip install wheel==0.37.1
  124. - run: python setup.py bdist_wheel
  125. - run: pip install dist/*.whl
  126. - run: freesurfer-volume-reader --help
  127. test-examples: # sync with https://github.com/fphammerle/freesurfer-surface/blob/dev/.github/workflows/python.yml#L73
  128. runs-on: ubuntu-18.04
  129. strategy:
  130. matrix:
  131. python-version:
  132. - '3.7'
  133. - '3.8'
  134. - '3.9'
  135. - '3.10'
  136. fail-fast: false
  137. defaults:
  138. run:
  139. working-directory: examples/
  140. steps:
  141. - uses: actions/checkout@v3
  142. - uses: actions/setup-python@v4
  143. with:
  144. python-version: ${{ matrix.python-version }}
  145. - run: pip install --upgrade pipenv==2022.9.21
  146. - run: pipenv --python "$(which python)" install --deploy --dev
  147. - run: pipenv graph
  148. # > the default behaviour is to abort conversion [...] if one of the cells throws an error
  149. - run: pipenv run jupyter nbconvert --execute --inplace *.ipynb
  150. # revert line specifying version of python interpreter
  151. - run: sudo apt-get update
  152. - run: sudo apt-get install --yes --no-install-recommends patchutils
  153. - run: >-
  154. git diff --unified=0
  155. | grepdiff --output-matching=hunk '^\( "version":\| "execution": {\| "<img src=\\"data:image/png;base64,\)'
  156. | patch --reverse
  157. - run: git diff --exit-code