summaryrefslogtreecommitdiff
path: root/.github/workflows/codecoverage.yml
blob: 28138b23804a7bc19833209bb0ff70109814187f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Code Coverage

on: [push, pull_request]

jobs:
  code-coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Check out source repository
        uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }} environment
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"
      - name: Run local websockets echo server on port ${{ env.LOCAL_WS_SERVER_PORT }}
        run: |
          pip3 install -U websockets asyncio
          python3 websocket/tests/echo-server.py &
      - name: Run test cases without internet or option dependencies to verify no offline test failures and verify optional dependencies are optional
        run: |
          pip3 install coverage pytest pytest-cov setuptools
          python3 -c "import setuptools; print('Setup tools version'); print(setuptools.__version__)"
          python3 setup.py install
          pytest -vrP --cov=websocket websocket/tests --cov-config=.coveragerc
          coverage report
      - name: Install wsaccel and python-socks, then run all test cases for coverage collection
        run: |
          pip3 install wsaccel python-socks
          pytest -vrP --cov=websocket websocket/tests --cov-config=.coveragerc --cov-append
          coverage report
        env:
          TEST_WITH_INTERNET: 1
          LOCAL_WS_SERVER_PORT: 8765
      - name: Run SSL test with extra environment variable and create report
        run: |
          ls $WEBSOCKET_CLIENT_CA_BUNDLE
          python3 -c "import ssl; print(ssl.get_default_verify_paths().capath)"
          pytest -vrP --cov=websocket websocket/tests --cov-config=.coveragerc --cov-append -k "testSSLopt"
          coverage report -m
        env:
          TEST_WITH_INTERNET: 1
          LOCAL_WS_SERVER_PORT: 8765
          WEBSOCKET_CLIENT_CA_BUNDLE: "/usr/lib/ssl/certs"
      - name: Run SSL test with extra environment variable and create report
        run: |
          python3 -c "import ssl; print(ssl.get_default_verify_paths().capath)"
          pytest -vrP --cov=websocket websocket/tests --cov-config=.coveragerc --cov-append -k "testSSLopt"
          coverage xml
        env:
          TEST_WITH_INTERNET: 1
          LOCAL_WS_SERVER_PORT: 8765
          WEBSOCKET_CLIENT_CA_BUNDLE: "/usr/lib/ssl/certs/Baltimore_CyberTrust_Root.pem"
      - name: Submit code coverage report to Codecov.io
        uses: codecov/codecov-action@v3