test.yml 1.8 KB

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