test.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. - name: Set up Python
  13. uses: actions/setup-python@v1
  14. with:
  15. python-version: ${{ matrix.python-version }}
  16. - name: Install from source
  17. run: python -m pip install --editable .[test,bcrypt]
  18. - name: Run tests
  19. run: python setup.py test
  20. - name: Upload coverage to Coveralls
  21. if: github.event_name == 'push' && github.ref == 'refs/heads/master'
  22. env:
  23. COVERALLS_PARALLEL: true
  24. COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
  25. run: |
  26. python -m pip install coveralls
  27. python -m coveralls
  28. coveralls-finish:
  29. needs: test
  30. if: github.event_name == 'push' && github.ref == 'refs/heads/master'
  31. runs-on: ubuntu-latest
  32. steps:
  33. - name: Set up Python
  34. uses: actions/setup-python@v1
  35. with:
  36. python-version: 3.x
  37. - name: Install Coveralls
  38. run: python -m pip install coveralls
  39. - name: Call Coveralls parallel builds webhook
  40. shell: python
  41. env:
  42. COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
  43. run: |
  44. import json, os, sys
  45. from urllib.request import Request, urlopen
  46. from coveralls import Coveralls
  47. _, job, _ = Coveralls.load_config_from_github()
  48. data = json.dumps({'repo_token': os.environ.get('COVERALLS_REPO_TOKEN', ''),
  49. 'payload': {'status': 'done', 'build_num': job}}).encode()
  50. headers = {'Content-type': 'application/json'}
  51. with urlopen(Request('https://coveralls.io/webhook', data, headers)) as f:
  52. sys.stderr.buffer.write(f.read() + b'\n')