Skip to content

Commit

Permalink
Merge branch 'ivana/tox-script-4' into ivana/tox-script-10
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Jan 22, 2025
2 parents fc2aa1b + b907e69 commit 452c1ab
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 416 deletions.
2 changes: 2 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ targets:
- python3.9
- python3.10
- python3.11
- python3.12
- python3.13
license: MIT
- name: sentry-pypi
internalPypiRepo: getsentry/pypi
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/test-integrations-gevent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Do not edit this YAML file. This file is generated automatically by executing
# python scripts/split_tox_gh_actions/split_tox_gh_actions.py
# The template responsible for it is in
# scripts/split_tox_gh_actions/templates/base.jinja
name: Test Gevent
on:
push:
branches:
- master
- release/**
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
env:
BUILD_CACHE_KEY: ${{ github.sha }}
CACHED_BUILD_PATHS: |
${{ github.workspace }}/dist-serverless
jobs:
test-gevent-pinned:
name: Gevent (pinned)
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.6","3.8","3.10","3.11","3.12"]
# python3.6 reached EOL and is no longer being supported on
# new versions of hosted runners on Github Actions
# ubuntu-20.04 is the last version that supported python3.6
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
os: [ubuntu-20.04]
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Setup Test Env
run: |
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
- name: Test gevent pinned
run: |
set -x # print commands that are executed
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gevent"
- name: Generate coverage XML (Python 3.6)
if: ${{ !cancelled() && matrix.python-version == '3.6' }}
run: |
export COVERAGE_RCFILE=.coveragerc36
coverage combine .coverage-sentry-*
coverage xml --ignore-errors
- name: Generate coverage XML
if: ${{ !cancelled() && matrix.python-version != '3.6' }}
run: |
coverage combine .coverage-sentry-*
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
# make sure no plugins alter our coverage reports
plugin: noop
verbose: true
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: .junitxml
verbose: true
check_required_tests:
name: All pinned Gevent tests passed
needs: test-gevent-pinned
# Always run this, even if a dependent job failed
if: always()
runs-on: ubuntu-20.04
steps:
- name: Check for failures
if: contains(needs.test-gevent-pinned.result, 'failure') || contains(needs.test-gevent-pinned.result, 'skipped')
run: |
echo "One of the dependent jobs has failed. You may need to re-run it." && exit 1
8 changes: 0 additions & 8 deletions .github/workflows/test-integrations-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ jobs:
- name: Erase coverage
run: |
coverage erase
- name: Test gevent latest
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-gevent-latest"
- name: Test grpc latest
run: |
set -x # print commands that are executed
Expand Down Expand Up @@ -115,10 +111,6 @@ jobs:
- name: Erase coverage
run: |
coverage erase
- name: Test gevent pinned
run: |
set -x # print commands that are executed
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gevent"
- name: Test grpc pinned
run: |
set -x # print commands that are executed
Expand Down
69 changes: 45 additions & 24 deletions scripts/populate_tox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There is a template in this directory called `tox.jinja` which contains a
combination of hardcoded and generated entries.

The `populate_tox.py` script fills out the auto-generated part of that template.
It does this by querying PYPI for each framework's package and its metadata and
It does this by querying PyPI for each framework's package and its metadata and
then determining which versions make sense to test to get good coverage.

The lowest supported and latest version of a framework are always tested, with
Expand Down Expand Up @@ -48,7 +48,20 @@ integration_name: {
}
```

The following can be set as a rule:
### `package`

The name of the third party package as it's listed on PyPI. The script will
be picking different versions of this package to test.

This key is mandatory.

### `deps`

The test dependencies of the test suite. They're defined as a dictionary of
`rule: [package1, package2, ...]` key-value pairs. All packages
in the package list of a rule will be installed as long as the rule applies.

`rule`s are predefined. Each `rule` must be one of the following:
- `*`: packages will be always installed
- a version specifier on the main package (e.g. `<=0.32`): packages will only
be installed if the main package falls into the version bounds specified
Expand All @@ -60,53 +73,61 @@ package's dependencies, for example. If e.g. Flask tests generally need
Werkzeug and don't care about its version, but Flask older than 3.0 needs
a specific Werkzeug version to work, you can say:

```
```python
"flask": {
"deps": {
"*": ["Werkzeug"],
"<3.0": ["Werkzeug<2.1.0"],
}
}
```

Sometimes, things depend on the Python version installed. If the integration
test should only run on specific Python version, e.g. if you want AIOHTTP
tests to only run on Python 3.7+, you can say:

```
"aiohttp": {
},
...
"python": ">=3.7",
}
```

If, on the other hand, you need to install a specific version of a secondary
dependency on specific Python versions (so the test suite should still run on
said Python versions, just with different dependency-of-a-dependency bounds),
you can say:
If you need to install a specific version of a secondary dependency on specific
Python versions, you can say:

```
```python
"celery": {
...
"deps": {
"*": ["newrelic", "redis"],
"py3.7": ["importlib-metadata<5.0"],
},
},
...
}
```

### `python`

Sometimes, the whole test suite should only run on specific Python versions.
This can be achieved via the `python` key, which expects a version specifier.

For example, if you want AIOHTTP tests to only run on Python 3.7+, you can say:

```python
"aiohttp": {
"python": ">=3.7",
...
}
```

Specifying `python` is discouraged as the script itself finds out which
Python versions are supported by the package. However, if a package has broken
metadata or the SDK is explicitly not supporting some packages on specific
Python versions (because of, for example, broken context vars), the `python`
key can be used.


## How-Tos

### Add a new test suite

1. Add the minimum supported version of the framework/library to `_MIN_VERSIONS`
in `integrations/__init__.py`. This should be the lowest version of the
framework that we can guarantee works with the SDK. If you've just added the
integration, it's fine to set this to the latest version of the framework
integration, you should generally set this to the latest version of the framework
at the time.
2. Add the integration and any constraints to `TEST_SUITE_CONFIG`. See the
"Defining constraints" section for the format (or copy-paste one
of the existing entries).
"Defining constraints" section for the format.
3. Add the integration to one of the groups in the `GROUPS` dictionary in
`scripts/split_tox_gh_actions/split_tox_gh_actions.py`.
4. Add the `TESTPATH` for the test suite in `tox.jinja`'s `setenv` section.
Expand Down
Loading

0 comments on commit 452c1ab

Please sign in to comment.