ci.yml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: CI
  2. on:
  3. push:
  4. branches:
  5. - master
  6. tags:
  7. - v*
  8. pull_request:
  9. branches:
  10. - master
  11. jobs:
  12. check-code-format:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - uses: actions/checkout@v4
  16. - name: Set up Python 3.9
  17. uses: actions/setup-python@v5
  18. with:
  19. python-version: 3.9
  20. - name: Install module
  21. run: |
  22. pip install wheel
  23. pip install -e .[dev]
  24. - name: Check code format with Black
  25. run: |
  26. black --check .
  27. - name: Check imports order with isort
  28. run: |
  29. isort --check-only .
  30. - name: Check code style with Flake8
  31. if: ${{ always() }}
  32. run: |
  33. flake8 .
  34. run-tests:
  35. runs-on: ubuntu-latest
  36. steps:
  37. - uses: actions/checkout@v4
  38. - name: Set up Python 3.9
  39. uses: actions/setup-python@v5
  40. with:
  41. python-version: 3.9
  42. - name: Install module
  43. run: |
  44. pip install wheel
  45. pip install -e .[dev]
  46. - name: Run pytest
  47. run: |
  48. pytest -v tests/
  49. build-and-push-package:
  50. runs-on: ubuntu-latest
  51. needs: [check-code-format, run-tests]
  52. steps:
  53. - uses: actions/checkout@v4
  54. - name: Set up Python 3.9
  55. uses: actions/setup-python@v5
  56. with:
  57. python-version: 3.9
  58. - name: Install dependencies
  59. run: |
  60. pip install wheel
  61. - name: Build package
  62. run: |
  63. python3 setup.py sdist bdist_wheel
  64. - name: Push package on PyPI
  65. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
  66. uses: pypa/gh-action-pypi-publish@release/v1
  67. with:
  68. user: __token__
  69. password: ${{ secrets.PYPI_API_TOKEN }}