1name: Framework tests
2
3on:
4  push:
5    branches:
6      - master
7  pull_request:
8
9concurrency:
10    group: ${{ github.workflow }}-${{ github.ref }}
11    cancel-in-progress: true
12
13jobs:
14  bottle-testsuite-0_12_19:
15    runs-on: ubuntu-latest
16    env:
17      DD_PROFILING_ENABLED: true
18      DD_TESTING_RAISE: true
19    defaults:
20      run:
21        working-directory: bottle
22    steps:
23      - uses: actions/setup-python@v2
24        with:
25          python-version: '3.9'
26      - uses: actions/checkout@v2
27        with:
28          path: ddtrace
29      - uses: actions/checkout@v2
30        with:
31          repository: bottlepy/bottle
32          ref: master
33          path: bottle
34      - name: Install Dependencies
35        run: sudo apt-get install -y libev-dev
36      - name: Test dependencies (Server back-ends and template engines)
37      # Taken from install script inside of .github/workflows of test suite (https://github.com/bottlepy/bottle/blob/master/.github/workflows/run_tests.yml)
38        run: |
39          pip install -U pip pytest
40          pip install mako jinja2
41          for name in waitress "cherrypy<9" cheroot paste tornado twisted diesel meinheld\
42            gunicorn eventlet flup bjoern gevent aiohttp-wsgi uvloop; do
43            pip install $name || echo "Failed to install $name with $(python -V 2>&1)" 1>&2
44          done
45      - name: Inject ddtrace
46        run: pip install ../ddtrace
47        # Allows tests to continue through deprecation warnings for jinja2 and mako
48      - name: Run tests
49        # Disable TestServerAdapter_gunicorn.test_simple because it checks for
50        # log output and it contains the profiler failing to upload
51        run: ddtrace-run pytest test --continue-on-collection-errors -v -k 'not TestServerAdapter_gunicorn'
52
53  django-testsuite-3_1:
54    runs-on: ubuntu-latest
55    env:
56      DD_PROFILING_ENABLED: true
57      DD_TESTING_RAISE: true
58    defaults:
59      run:
60        working-directory: django
61    steps:
62      - uses: actions/checkout@v2
63        with:
64          path: ddtrace
65      - uses: actions/checkout@v2
66        with:
67          repository: django/django
68          ref: stable/3.1.x
69          path: django
70      - uses: actions/setup-python@v2
71        with:
72          python-version: "3.8"
73      - name: Install pylibmc libmemcached package
74        # Django-specific: pylibmc in Ubuntu requires libmemcached package
75        run: sudo apt install libmemcached-dev zlib1g
76      - name: Install dependencies
77        # Django-specific: separate dependencies for tests
78        run: pip install -r tests/requirements/py3.txt
79      - name: Install ddtrace
80        run: pip install ../ddtrace
81      - name: Install django
82        run: pip install ../django
83      - name: Set Pythonpath
84        run: echo "PYTHONPATH=." >> $GITHUB_ENV
85      - name: Disable unsupported tests
86        run: |
87          # Note: test_supports_json_field_operational_error will fail with the tracer
88          # DEV: Insert @skipUnless before the test definition
89          # DEV: We need to escape the space indenting
90          sed -i'' '/def test_supports_json_field_operational_error/i \ \ \ \ @skipUnless(False, "test not supported by dd-trace-py")' tests/backends/sqlite/test_features.py
91      - name: Run tests
92        # django.tests.requests module interferes with requests library patching in the tracer -> disable requests patch
93        run: DD_TRACE_REQUESTS_ENABLED=0 ddtrace-run tests/runtests.py
94
95  fastapi-testsuite-0_63:
96    runs-on: ubuntu-latest
97    env:
98      DD_TESTING_RAISE: true
99      DD_PROFILING_ENABLED: true
100    defaults:
101      run:
102        working-directory: fastapi
103    steps:
104      - uses: actions/setup-python@v2
105        with:
106          python-version: '3.9'
107      - uses: actions/checkout@v2
108        with:
109          path: ddtrace
110      - uses: actions/checkout@v2
111        with:
112          repository: tiangolo/fastapi
113          ref: 0.63.0
114          path: fastapi
115      #This step installs Flit, a way to put Python packages and modules on PyPI (More info at https://flit.readthedocs.io/en/latest/)
116      - name: Install Flit
117        run: pip install flit
118      #Installs all dependencies needed for FastAPI
119      - name: Install Dependencies
120        run: flit install --symlink
121      #Reverts SQLalchemy to v1.3.24. Newest version breaks tests due to RowProxy module being deprecated in latest v1.4.11 More info: (https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#rowproxy-is-no-longer-a-proxy-is-now-called-row-and-behaves-like-an-enhanced-named-tuple)
122      - name: Downgrade SQLalchemy
123        run: pip install --force-reinstall SQLAlchemy==1.3.24
124      - name: Inject ddtrace
125        run: pip install ../ddtrace
126      - name: Test
127        run: ddtrace-run pytest tests
128
129  flask-testsuite-1_1_4:
130    runs-on: ubuntu-latest
131    env:
132      TOX_TESTENV_PASSENV: DD_TESTING_RAISE DD_PROFILING_ENABLED
133      DD_TESTING_RAISE: true
134      DD_PROFILING_ENABLED: true
135    defaults:
136      run:
137        working-directory: flask
138    steps:
139      - uses: actions/checkout@v2
140        with:
141          path: ddtrace
142      - uses: actions/checkout@v2
143        with:
144          repository: pallets/flask
145          ref: 1.1.4
146          path: flask
147      - uses: actions/setup-python@v2
148        with:
149          python-version: '3.8'
150      - name: Install tox
151        run: pip install tox
152      - name: Create tox env
153        run: tox -e py38 --notest
154      - name: Inject ddtrace
155        run: .tox/py38/bin/pip install ../ddtrace
156      - name: Add pytest configuration for ddtrace
157        run: echo -e "[pytest]\nddtrace-patch-all = 1" > pytest.ini
158      - name: Run tests
159        # test_exception_propagation is broken upstream
160        run: tox -e py38 -- -k 'not test_exception_propagation and not test_memory_consumption'
161
162  httpx-testsuite-0_18_1:
163    runs-on: ubuntu-latest
164    defaults:
165      run:
166        working-directory: httpx
167    steps:
168      - uses: actions/checkout@v2
169        with:
170          path: ddtrace
171      - uses: actions/checkout@v2
172        with:
173          repository: encode/httpx
174          ref: 0.18.1
175          path: httpx
176      - uses: actions/setup-python@v2
177        with:
178          python-version: '3.9'
179      - name: Install dependencies
180        run: pip install -r requirements.txt
181      - name: Inject ddtrace
182        run: pip install ../ddtrace
183      - name: Add pytest configuration for ddtrace
184        run: echo -e "[pytest]\nddtrace-patch-all = 1" > pytest.ini
185      - name: Run tests
186        env:
187          # Disabled distributed tracing since there are a lot of tests that assert on headers
188          DD_HTTPX_DISTRIBUTED_TRACING: "false"
189        run: pytest
190
191  mako-testsuite-1_1_4:
192    runs-on: ubuntu-latest
193    env:
194      TOX_TESTENV_PASSENV: DD_TESTING_RAISE DD_PROFILING_ENABLED
195      DD_TESTING_RAISE: true
196      DD_PROFILING_ENABLED: true
197    defaults:
198      run:
199        working-directory: mako
200    steps:
201      - uses: actions/checkout@v2
202        with:
203          path: ddtrace
204      - uses: actions/checkout@v2
205        with:
206          repository: sqlalchemy/mako
207          ref: rel_1_1_4
208          path: mako
209      - uses: actions/setup-python@v2
210        with:
211          python-version: '3.8'
212      - name: Install tox
213        run: pip install tox
214      - name: Create tox env
215        run: tox -e py --notest
216      - name: Inject ddtrace
217        run: .tox/py/bin/pip install ../ddtrace
218      - name: Add pytest configuration for ddtrace
219        run: echo -e "[pytest]\nddtrace-patch-all = 1" > pytest.ini
220      - name: Run tests
221        run: tox -e py
222
223  starlette-testsuite-0_14_2:
224    runs-on: "ubuntu-latest"
225    env:
226      DD_TESTING_RAISE: true
227      DD_PROFILING_ENABLED: true
228    defaults:
229      run:
230        working-directory: starlette
231    steps:
232      - uses: actions/setup-python@v2
233        with:
234          python-version: '3.9'
235      - uses: actions/checkout@v2
236        with:
237          path: ddtrace
238      - uses: actions/checkout@v2
239        with:
240          repository: encode/starlette
241          ref: 0.14.2
242          path: starlette
243      - name: Install ddtrace
244        run: pip install ../ddtrace
245      - name: Install dependencies
246        run: "scripts/install"
247      #Parameters for keyword expression skip 3 failing tests that are expected due to asserting on headers. The errors are because our context propagation headers are being added
248      - name: Run tests
249        run: pytest -p no:warnings --ddtrace-patch-all tests -k 'not test_request_headers and not test_subdomain_route and not test_websocket_headers'
250
251  requests-testsuite-2_26_0:
252    runs-on: "ubuntu-latest"
253    env:
254      DD_TESTING_RAISE: true
255      DD_PROFILING_ENABLED: true
256    defaults:
257      run:
258        working-directory: requests
259    steps:
260      - uses: actions/setup-python@v2
261        with:
262          python-version: '3.9'
263      - uses: actions/checkout@v2
264        with:
265          path: ddtrace
266      - uses: actions/checkout@v2
267        with:
268          repository: psf/requests
269          ref: v2.26.0
270          path: requests
271      - name: Install ddtrace
272        run: pip install ../ddtrace
273      - name: Install dependencies
274        run: "make init"
275      - name: Run tests
276        run: ddtrace-run pytest -p no:warnings tests
277