test.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. name: Test
  2. on:
  3. push:
  4. branches:
  5. - master
  6. - release/*
  7. pull_request:
  8. branches:
  9. - master
  10. - release/*
  11. jobs:
  12. test:
  13. runs-on: ubuntu-latest
  14. strategy:
  15. matrix:
  16. os: [ubuntu-latest, macos-latest, windows-latest]
  17. python-version: [3.5, 3.6, 3.7, 3.8, pypy3]
  18. steps:
  19. - uses: actions/checkout@v2
  20. - name: Set up Python
  21. uses: actions/setup-python@v1
  22. with:
  23. python-version: ${{ matrix.python-version }}
  24. - name: Install from source
  25. run: python -m pip install --editable .[test,bcrypt]
  26. - name: Run tests
  27. run: python setup.py test
  28. - name: Upload coverage to Coveralls
  29. if: github.event_name == 'push' && github.ref == 'refs/heads/master'
  30. env:
  31. COVERALLS_PARALLEL: true
  32. COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
  33. run: |
  34. python -m pip install coveralls
  35. python -m coveralls
  36. coveralls-finished:
  37. needs: test
  38. if: github.event_name == 'push' && github.ref == 'refs/heads/master'
  39. runs-on: ubuntu-latest
  40. steps:
  41. - name: Set up Python
  42. uses: actions/setup-python@v1
  43. with:
  44. python-version: 3.x
  45. - name: Install Coveralls
  46. run: python -m pip install coveralls
  47. - name: Call Coveralls parallel builds webhook
  48. shell: python
  49. env:
  50. COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
  51. run: |
  52. import json, os, sys
  53. from urllib.request import Request, urlopen
  54. from coveralls import Coveralls
  55. _, job, _ = Coveralls.load_config_from_github()
  56. data = json.dumps({'repo_token': os.environ.get('COVERALLS_REPO_TOKEN', ''),
  57. 'payload': {'status': 'done', 'build_num': job}}).encode()
  58. headers = {'Content-type': 'application/json'}
  59. with urlopen(Request('https://coveralls.io/webhook', data, headers)) as f:
  60. sys.stderr.buffer.write(f.read() + b'\n')