Repository navigation
Test SQLAlchemy offline on the declared minimum and the latest release (GH-1543) #1620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
50b16ef
09f7b84
522df7f
85f66fc
adda5d9
48fd2b7
26a9e27
397f4fa
8d30938
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,49 @@ jobs: | |
| tool: just | ||
| - run: just test offline | ||
|
|
||
| # The SQLAlchemy tests that need no AWS, and the collection of the compliance | ||
| # suites, on the latest release of each supported SQLAlchemy series; the | ||
| # offline job above runs the dialect tests on the locked version, | ||
| # and the AWS suites run the compliance suites on it. The AWS suites | ||
| # do not wait for this job, so a new SQLAlchemy release that breaks it does | ||
| # not stop the AWS suites of unrelated pull requests. The Release workflow | ||
| # requires it, as it requires every job of this workflow. | ||
| offline-sqla: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| permissions: | ||
| contents: read | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # Each series runs on the newest Python version for which its releases | ||
| # publish compiled wheels, so the versions differ: SQLAlchemy 2.0 has | ||
| # none for Python 3.15, where only its pure-Python wheel, without the | ||
| # C extensions, would install. Move a series to a newer Python version | ||
| # once its releases publish compiled wheels for it. | ||
| include: | ||
| - sqlalchemy: '2.0' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maintainer-requested change and self-review (both perspectives): The maintainer asked for the job to test the 2.0 and 2.1 series rather than the minimum and the latest release, and for 2.0 to use the newest Python version for which it publishes wheels, with a comment explaining why the Python versions differ.
Validation:
|
||
| python-version: '3.14' | ||
| - sqlalchemy: '2.1' | ||
| python-version: '3.15' | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| enable-cache: true | ||
| # As in the offline job, uv's Python 3.13+ cannot compile Python.h. | ||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10 | ||
| with: | ||
| tool: just | ||
| - run: just test offline-sqla ${{ matrix.sqlalchemy }} | ||
|
|
||
| # Selects the AWS suites and Python versions. Draft and external-fork pull | ||
| # requests run none. A ready pull request runs the PyAthena suite only when | ||
| # the package, the tests, setup.cfg, the dependencies, or this workflow | ||
|
|
@@ -168,7 +211,8 @@ jobs: | |
| EVENT_NAME: ${{ github.event_name }} | ||
| REQUESTED_VERSIONS: ${{ inputs.python-versions }} | ||
| # Every supported version, oldest first; keep in sync with the | ||
| # pyproject.toml classifiers and the offline job's version. | ||
| # pyproject.toml classifiers, the offline job's version, and the | ||
| # offline-sqla job's matrix. | ||
| PYTHON_VERSIONS: '["3.11", "3.12", "3.13", "3.14", "3.15"]' | ||
| run: | | ||
| case "$EVENT_NAME" in | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,6 +161,17 @@ When a change affects a request to AWS, or how PyAthena reads what AWS returns, | |
| uv run --env-file .env pytest -n 1 -m aws tests/pyathena/test_cursor.py | ||
| ``` | ||
|
|
||
| `just test offline` runs the SQLAlchemy tests on the locked SQLAlchemy. | ||
| `just test offline-sqla <series-or-version>` runs the SQLAlchemy tests that need no AWS (`tests/pyathena/sqlalchemy/` and `tests/pyathena/aio/sqlalchemy/`) on another release, in the same environment, and collects the compliance suites (`tests/sqlalchemy/`, synchronous and `--dburi async`), which imports them without contacting AWS: | ||
|
|
||
| ```bash | ||
| just test offline-sqla 2.0 # the latest 2.0 release that the sqlalchemy extras allow | ||
| just test offline-sqla 2.1 # the latest 2.1 release | ||
| just test offline-sqla 2.1.9 # a given release | ||
| ``` | ||
|
|
||
| uv resolves a series from `pyproject.toml`, and the recipe prints the SQLAlchemy version that it runs. | ||
|
|
||
| ### S3 null-version moves | ||
|
|
||
| The null-version move regression tests create three dedicated temporary buckets: | ||
|
|
@@ -271,6 +282,7 @@ Retain dtype and schema checks, option contexts, and resource cleanup where appl | |
|
|
||
| The Test workflow runs for pull requests that change files other than `docs/` and Markdown. | ||
| It runs the offline checks (`just lint`, and `just test offline` on the newest supported Python version) on each of them, including Drafts and external forks. | ||
| It also runs `just test offline-sqla 2.0` and `just test offline-sqla 2.1`, for each supported SQLAlchemy series, each on the newest Python version for which that series publishes compiled wheels; the AWS suites do not wait for these, and the Release workflow requires them. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up 5 (Codex, session The reviewer confirmed that three of the four follow-up 4 findings are resolved. Remaining: the GitHub Actions section of the testing guide showed
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up 6 (Codex, session |
||
| The AWS suites start only after the offline checks pass, and run as follows: | ||
|
|
||
| | Trigger | PyAthena suite | SQLAlchemy tests | Spark tests | Python versions | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,31 +35,37 @@ lint: license-headers | |
| license-headers: | ||
| uv run python scripts/check_license_headers.py | ||
|
|
||
| # Run tests: just test (pyathena|offline|sqla|sqla-async) | ||
| test target="help": | ||
| @just _test-{{ if target =~ "^-" { "help" } else { target } }} | ||
| # Run tests: just test (pyathena|offline|offline-sqla SERIES|VERSION|sqla|sqla-async) | ||
| [positional-arguments] | ||
| test target="help" *args: | ||
| @shift && just _test-{{ if target =~ "^-" { "help" } else { target } }} "$@" | ||
|
|
||
| _test-help: | ||
| @echo "Usage: just test <target>" | ||
| @echo "" | ||
| @echo "Targets:" | ||
| @echo " pyathena Run the PyAthena tests, including AWS integration tests (runs lint first)" | ||
| @echo " offline Run the PyAthena tests that need no AWS, with no AWS credentials" | ||
| @echo " offline-sqla SERIES|VERSION" | ||
| @echo " Run the SQLAlchemy tests that need no AWS and collect the compliance" | ||
| @echo " suites on the latest release of a series, such as 2.0, or a version" | ||
| @echo " sqla Run SQLAlchemy dialect tests" | ||
| @echo " sqla-async Run SQLAlchemy async dialect tests" | ||
|
|
||
| _test-pyathena: lint | ||
| uv run pytest -n 8 {{PYTEST_RERUN}} --cov pyathena --cov-report html --cov-report term tests/pyathena/ | ||
|
|
||
| # Sync the environment first, as uv run does, with the developer's settings. | ||
| # Then unset every AWS and fsspec setting and HTTP_PROXY, HTTPS_PROXY, and | ||
| # ALL_PROXY in either case, set NO_PROXY and no_proxy to '*', and give the four | ||
| # settings that tests/__init__.py requires placeholder values. A request | ||
| # made by accident carries credentials that no account accepts, and the clients | ||
| # that read AWS_ENDPOINT_URL send it to a reserved name that does not resolve | ||
| # (RFC 6761), with AWS_MAX_ATTEMPTS=1 and POLARS_CLOUD_MAX_RETRIES=0. uv must not | ||
| # load a .env file back. | ||
| _test-offline: | ||
| # Run a command with no AWS settings, for the tests that need no AWS. Sync the | ||
| # environment first, as uv run does, with the developer's settings. Then unset | ||
| # every AWS and fsspec setting and HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY in | ||
| # either case, set NO_PROXY and no_proxy to '*', and give the four settings that | ||
| # tests/__init__.py requires placeholder values. A request made by accident | ||
| # carries credentials that no account accepts, and the clients that read | ||
| # AWS_ENDPOINT_URL send it to a reserved name that does not resolve (RFC 6761), | ||
| # with AWS_MAX_ATTEMPTS=1 and POLARS_CLOUD_MAX_RETRIES=0. uv must not load a | ||
| # .env file back. | ||
| [positional-arguments] | ||
| _offline *command: | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| uv run --no-env-file true | ||
|
|
@@ -73,7 +79,37 @@ _test-offline: | |
| export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null BOTO_CONFIG=/dev/null | ||
| export AWS_EC2_METADATA_DISABLED=true FSSPEC_CONFIG_DIR=/dev/null | ||
| export AWS_ENDPOINT_URL=https://offline.invalid AWS_MAX_ATTEMPTS=1 POLARS_CLOUD_MAX_RETRIES=0 | ||
| uv run --no-sync --no-env-file pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/ | ||
| "$@" | ||
|
|
||
| _test-offline: | ||
| @just _offline uv run --no-sync --no-env-file pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/ | ||
|
|
||
| # The SQLAlchemy tests that need no AWS, and the collection of the compliance | ||
| # suites (which imports them without contacting AWS), on another SQLAlchemy: | ||
| # a series such as 2.0 runs its latest release that the extras allow, resolved | ||
| # by uv, and any other value is a version. The packages are resolved and cached | ||
| # before _offline removes the proxy settings, and the runs inside it use that | ||
| # cache only (--offline), so the recipe needs uv's cache. | ||
| [positional-arguments] | ||
| _test-offline-sqla version: | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| if [[ "$1" =~ ^([0-9]+)\.([0-9]+)$ ]]; then | ||
| series="sqlalchemy>=$1,<${BASH_REMATCH[1]}.$((BASH_REMATCH[2] + 1))" | ||
| version=$(uv pip compile pyproject.toml --extra sqlalchemy --extra aiosqlalchemy \ | ||
| --constraint <(echo "$series") --resolution highest \ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent follow-up 4 (Codex,
The reviewer also ran both series in isolation. Each passed 734 tests and collected both compliance suites, and the other packages matched the lock. Validation: |
||
| --no-deps --no-header --no-annotate --quiet \ | ||
| | sed -n 's/^sqlalchemy==//p') | ||
| else | ||
| version="$1" | ||
| fi | ||
| with="sqlalchemy[asyncio]==$version" | ||
| echo "SQLAlchemy $version" | ||
| uv run --no-env-file --with "$with" true | ||
| run=(uv run --offline --no-sync --no-env-file --with "$with") | ||
| just _offline "${run[@]}" pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/sqlalchemy/ tests/pyathena/aio/sqlalchemy/ | ||
| just _offline "${run[@]}" pytest -n 0 -p no:rerunfailures --collect-only -qq tests/sqlalchemy/ | ||
| just _offline "${run[@]}" pytest -n 0 -p no:rerunfailures --collect-only -qq tests/sqlalchemy/ --dburi async | ||
|
|
||
| _test-sqla: | ||
| uv run pytest -n 8 {{PYTEST_RERUN}} --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review round two (claims, operations, evidence): CLEAN
Base
b2620f4b5ba52a23b809f5c5faebc646c0d04ddd, head522df7f1030135dd619141265afd7e56de595b07. Claims checked:min/latestfrompyproject.toml":uv pip compile --resolution lowest-direct|highestgives 2.0.52 and 2.1.9, and the recipe prints them.ImportError: DeprecatedCompoundSelectTest(checked earlier in this session), and pytest exits non-zero, which fails the recipe underset -e.NameDenormalizeTestis the only failure, and it is now skipped with its reason: 2 passed and 6 skipped on both drivers.needs:link to the AWS jobs, so a new SQLAlchemy release that breaks the job does not stop the AWS suites of unrelated PRs. Theminrow uses Python 3.11, the oldest supported version; the locally verified rows use 3.15.