Skip to content

Publish Preset build 1.1.11.1 to the internal package index (do not merge until Jenkins onboarding) - #2

Closed
aminghadersohi wants to merge 1 commit into
workflow-a-sqlalchemy2-reflection-securityfrom
workflow-a-publication-path
Closed

aminghadersohi wants to merge 1 commit into
workflow-a-sqlalchemy2-reflection-securityfrom
workflow-a-publication-path

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Publishes the Preset build of this fork to the internal package index (S3-backed, s3://preset-pypi).

Stacked on #1, which stays byte-identical to the reviewed upstream #100 head (ca7ace9e). This PR adds exactly two things on top: the Jenkinsfile and the version bump.

Do not merge until #1 and #2 are reviewed and Jenkins multibranch onboarding is done. Nothing has been published, tagged, or uploaded.

Version: 1.1.11.1

Adopts the four-component convention already established in this bucket by PyHive — upstream 0.7.0 became Preset pyhive-0.7.0.1 and 0.7.0.2. The Preset build of upstream 1.1.11 is therefore 1.1.11.1, declared explicitly in sqlalchemy_drill/__init__.py so the published version is auditable in git rather than synthesised during the build.

1.1.11.1 sorts above a hypothetical upstream 1.1.11 and below 1.1.12. That is precisely why it is consumed only via an immutable direct artifact URL and never offered to a resolver as a candidate for the plain sqlalchemy-drill name — a future upstream release stays free to win.

One residual worth naming: the bucket is a flat index, so an object placed in it is visible to anyone who points a resolver at the host. Direct-URL pinning protects Shell, but it does not by itself stop a third party from resolving 1.1.11.1 if they add this host as an index. The protection is the consumption pattern, not the bucket.

Publishing mechanism

Not a Warehouse/devpi/Nexus instance — a flat S3 bucket behind nginx (/simple/ 404s). There is no trusted-publishing (OIDC / PEP 740) path available, because there is no index to establish a trusted publisher against. Publication is s3:PutObject.

This follows the existing Preset publishers (claude-commands, service-lib-py, api-clients, superset-s3-audit, …): Jenkins binds the existing ci-user credential at runtime via AmazonWebServicesCredentialsBinding and runs aws s3 sync ./dist s3://preset-pypi. The IAM grant is already in preset-io/infra (pypi-s3.tf): ci_user holds s3:* on arn:aws:s3:::preset-pypi. No credential material is in this repo — only variable names.

Two fixes to the inherited pattern

  1. Overwrite guard was broken by a naming mismatch. The pattern copied from claude-commands checks ${LIB_NAME}-${version}.tar.gz, i.e. sqlalchemy-drill-1.1.11.1.tar.gz. setuptools actually emits the underscored distribution name, sqlalchemy_drill-1.1.11.1.tar.gz. The guard would have requested a path that never exists, always 404'd, and silently permitted an overwrite of a published artifact. LIB_NAME (bucket folder / requirement name) and DIST_NAME (artifact filename) are now separate.
  2. Publishes the wheel only, immutably — see below.

Artifact validation

Built from this exact tree at 1.1.11.1:

Artifacts built sqlalchemy_drill-1.1.11.1-py3-none-any.whl, sqlalchemy_drill-1.1.11.1.tar.gz
Artifacts published the wheel only
Version agreement wheel 1.1.11.1 = sdist 1.1.11.1 = __init__.py 1.1.11.1
twine check --strict PASSED, both artifacts
tools/check_dist.py passed — wheel top-level is ['sqlalchemy_drill'] only, no test package; sdist has all 20 required paths
Metadata Metadata-Version: 2.4, License: MIT, wheel tag py3-none-any, Root-Is-Purelib: true
Attribution upstream Home-page and original author list retained

Wheel only — and why

Decision: publish and consume the pure-Python wheel. The sdist is not published.

Two builds of identical source produced different hashes. Investigating:

  • Wheel is byte-reproducible once SOURCE_DATE_EPOCH is pinned — verified identical sha256 across rebuilds.
  • Sdist is not reproducible even with SOURCE_DATE_EPOCH (setuptools bakes in member ordering and mtimes).

Only an artifact that can be rebuilt and compared against what is being served is fit for a consumer to pin, so only the wheel is uploaded. The wheel is also pure-python (py3-none-any), so a direct-URL consumer installs it with no build step.

The sdist is still built, deliberately: tools/check_dist.py validates the wheel and sdist as a pair, and that gate is worth keeping intact. It is simply never uploaded. Publishing and building are separate concerns here.

The build pins SOURCE_DATE_EPOCH to the commit timestamp, so the published wheel is reproducible from its exact revision.

Stable releases come only from merged history

  • master → stable 1.1.11.1. Only reviewed, merged Preset history produces a stable version.
  • PR branches → 1.1.11.1+PR-<n>.<shortsha>, a PEP 440 local version that is explicitly not a stable release.

This is asserted in the build, not left to convention: a non-master branch that would emit the bare stable version fails the job, and a PR build that somehow produced a non-local version fails too.

Immutability is atomic, not best-effort

aws s3 sync is not used — it replaces an object whose content changed. The upload is:

aws s3api put-object --bucket preset-pypi \
  --key sqlalchemy-drill/<wheel> --body <wheel> --if-none-match '*'

S3 rejects that with 412 if the key already exists, so a published artifact can never be replaced. That closes the check-then-write race a curl -I guard alone leaves open (the readable pre-flight check is kept, but only as a fast, clear failure).

Prerequisite for the Jenkins admin: --if-none-match requires AWS CLI v2.18+ in the preset/ci image. If the image is older, the upload step fails loudly and nothing is published — that is intended. Please do not work around it by falling back to aws s3 sync, which would silently permit an overwrite.

The SHA256 Shell should pin

After upload the job re-downloads the artifact actually being served, digests that, and fails if it differs from what was built. That digest is printed in the log and archived as published.sha256 (fingerprinted).

That archived value — not any locally computed one — is what Shell pins.

CI

10/10 checks green. CodeQL does not appear on this PR, and that is expected rather than missing: codeql.yml is scoped to pull_request: branches: [master], and this PR targets the workflow-a-… branch. CodeQL passed on #1 against the same code content.

Shell integration plan (for a follow-up PR in preset-io/superset-shell — not done here)

Current state: requirements.txt:1480 pins sqlalchemy-drill==1.1.2 from public PyPI, and config/sqlalchemy-driver-manifest.json → connectors[11] records locked_version: "1.1.2", status: "upgrade-required", with a note that the deployed version predates SQLAlchemy 2 import_dbapi support.

requirements.txt is autogenerated (uv pip compile setup.py --output-file requirements.txt --no-emit-index-url) and guarded by scripts/check_requirements_parity.py, so it must not be hand-edited. Exact sequence:

  1. setup.py — add a URL constant beside the existing ones (API_CLIENTS_URL, SERVICE_LIB_URL, …):
    SQLALCHEMY_DRILL_URL = "<internal-index-base>/sqlalchemy-drill/sqlalchemy_drill-1.1.11.1-py3-none-any.whl"
    and replace the sqlalchemy-drill==1.1.2 requirement with f"sqlalchemy-drill @ {SQLALCHEMY_DRILL_URL}".
  2. Regenerate the lock with the uv command above; do not edit requirements.txt by hand. Expect line 1480 to become a sqlalchemy-drill @ https://… direct reference, matching the pyhive @ <internal-index-base>/PyHive/pyhive-0.7.0.1.tar.gz precedent at line 1152.
  3. config/sqlalchemy-driver-manifest.json, connectors[11].packages[0] — set locked_version to the same full URL (this is exactly how the hive and presto connectors already record their Preset-built PyHive). Then update the qualification fields, which currently understate what is now known: sqlalchemy_claim → ==2.0.52 verified, runtime_verified → true, evidence_tier → live REST integration rather than resolve/import only, status → resolved, and refresh notes.
  4. Run the parity test (tests/scripts/test_requirements_parity.py) plus Shell's own suite.
  5. Record the published wheel's sha256 — taken from the job's archived published.sha256, not rebuilt locally — in the PR description for provenance.

Steps 1–5 are blocked until the wheel is actually published, since the URL must resolve.

Exact Jenkins-admin action required

A Jenkins administrator must create a multibranch pipeline job for preset-io/sqlalchemy-drill, configured like the existing claude-commands / service-lib-py jobs:

  • Branch source: GitHub, preset-io/sqlalchemy-drill, discovering branches and PRs.
  • Script path: Jenkinsfile (repo root).
  • Credential: the existing ci-user — already present in Jenkins and already granted s3:* on arn:aws:s3:::preset-pypi. No new secret needs to be created.

Nothing else is blocked on credentials. Once the job exists, a PR build publishes the pre-release 1.1.11.1+PR-<n>.<sha> and a master build publishes stable 1.1.11.1, both as wheel-only immutable uploads.


Note on this PR's history. An earlier revision of this description, its title, and one commit message named the internal index host directly. That has been removed from every current surface and the branch history was rewritten. Residual copies may persist in GitHub's edit history and in orphaned commits; a purge request is being handled separately. Please use generic wording for the index host in any review comment here.

@aminghadersohi
aminghadersohi force-pushed the workflow-a-publication-path branch from 635d9ba to 43dc1d8 Compare September 15, 2026 23:59
@aminghadersohi
aminghadersohi changed the base branch from master to workflow-a-sqlalchemy2-reflection-security September 15, 2026 23:59
@aminghadersohi

Copy link
Copy Markdown
Collaborator Author

Re-based this onto workflow-a-sqlalchemy2-reflection-security (PR #1) and retargeted the base.

I had originally branched it from master, and CI went red. To be clear about what that failure was: the diff here is one file (Jenkinsfile, +130) and touches no tested code. master still carries the old test.yml, whose single test job runs test/test_dbapi_compliance.py against a live Drill server that does not exist on a runner — it died with requests.exceptions.ConnectionError: Connection reset by peer. That is a pre-existing master baseline failure, and adding the testcontainers fixture is one of the things PR #1 fixes.

Stacking on #1 is also just the right shape: the publication path should sit on top of the code it publishes. Now green — 11/11 checks including CodeQL.

@aminghadersohi
aminghadersohi force-pushed the workflow-a-publication-path branch from 43dc1d8 to a9c2f98 Compare September 16, 2026 00:06
@aminghadersohi aminghadersohi changed the title Internal publication path for pypi.devops.preset.zone (proposal — do not merge yet) Publish Preset build 1.1.11.1 to pypi.devops.preset.zone (do not merge until Jenkins onboarding) Sep 16, 2026
@aminghadersohi

Copy link
Copy Markdown
Collaborator Author

Reviewer notes on who I tagged and why:

  • @Antonio-RiveroMartnez — you own the claude-commands Jenkinsfile this is modelled on. The part most worth your eyes is the overwrite-guard fix: the inherited pattern checks ${LIB_NAME}-${version}.tar.gz, but setuptools emits the underscored sqlalchemy_drill-…. As written in the original, that curl -I -f can never succeed, so the "already exists, bail out" branch is unreachable and a republish would overwrite silently. That same bug likely exists in the other publishers wherever the project name and distribution name differ by a dash/underscore — worth a sweep.
  • @rusackas — you opened the upstream CI request on Fix SQLAlchemy 2 reflection and validate release artifacts JohnOmernik/sqlalchemy-drill#100; this is the Preset-side fallback for the same work, plus the Shell integration plan.
  • @mistercrunch — repo admin, and the version-policy call (1.1.11.1, direct-URL-only consumption) is the kind of thing worth a second opinion.

I could not request review from @craig-rueda or @maxim-preset — they authored/last touched pypi-s3.tf in preset-io/infra but are not collaborators on this repo, so GitHub rejects the request. Someone with org rights may want to loop one of them in on the bucket-exposure observation in #1.

Two things I deliberately did not decide:

  1. Whether to publish the sdist at all. I publish both, but only the wheel is byte-reproducible (the sdist is not, even with SOURCE_DATE_EPOCH), so only the wheel is meaningfully verifiable.
  2. Whether master here should ever publish. Today it would publish bare 1.1.11.1 on merge. If you'd rather keep this PR-builds-only until upstream Fix SQLAlchemy 2 reflection and validate release artifacts JohnOmernik/sqlalchemy-drill#100 lands, say so and I'll gate the master branch out.

@aminghadersohi
aminghadersohi force-pushed the workflow-a-publication-path branch from a9c2f98 to 6d87d7b Compare September 16, 2026 00:14
@aminghadersohi

Copy link
Copy Markdown
Collaborator Author

Updated for the wheel-only decision. Summary of what changed and two things reviewers should push back on if I got them wrong:

Wheel-only publish, but still a two-artifact build. tools/check_dist.py validates the wheel and sdist as a pair and fails if it doesn't find exactly one of each. I kept building both so that gate stays intact, and simply never upload the sdist. Weakening the gate to accept a lone wheel would have traded real validation for tidiness, so I didn't. If you'd rather the sdist not be built at all, that means relaxing check_dist.py — worth a deliberate decision, not a side effect.

Stable only from merged history. master publishes bare 1.1.11.1; PR branches publish 1.1.11.1+PR-<n>.<sha>. The build asserts this — a non-master branch that would emit the bare version fails the job outright, rather than relying on the branch logic being read correctly by the next person to edit it.

Immutability is now atomic. Dropped aws s3 sync entirely (it replaces changed objects) in favour of aws s3api put-object --if-none-match '*', which S3 rejects with 412 if the key exists. The curl -I pre-check is kept, but only for a fast readable failure — on its own it's a check-then-write race.

One prerequisite I cannot verify from here: --if-none-match needs AWS CLI v2.18+ in the preset/ci image. I have no way to inspect that image, so please confirm before onboarding. If it's older the upload fails loudly and nothing publishes, which is the correct outcome — but please don't resolve it by reverting to aws s3 sync.

Reproducibility. The build now pins SOURCE_DATE_EPOCH to the commit timestamp. I verified locally that this makes the wheel byte-identical across rebuilds (same sha256 twice); the sdist stays non-reproducible even with it, which is the whole reason for the wheel-only decision.

The SHA256 for Shell is captured by re-downloading the artifact actually being served, digesting that, and failing if it differs from what was built. It's archived as published.sha256. Pin that value — not one computed locally, including not the ones in my earlier comments.

CI: 10/10 green. CodeQL doesn't run here because codeql.yml is scoped to pull_request: branches: [master] and this targets the workflow-a-… base; it passed on #1 over the same code.

@aminghadersohi aminghadersohi changed the title Publish Preset build 1.1.11.1 to pypi.devops.preset.zone (do not merge until Jenkins onboarding) Publish Preset build 1.1.11.1 to the internal package index (do not merge until Jenkins onboarding) Sep 16, 2026
Publishes the Preset build of this fork to the internal package index through
Jenkins, following the existing Preset publishers (claude-commands,
service-lib-py, api-clients).  Jenkins binds the 'ci-user' AWS credential at
runtime; no credential material is stored in the repo.

Every index operation goes through the AWS API against the backing bucket
rather than the index's public HTTP front door.  That keeps the deployment
hostname out of this repository, and it is also the more correct check: the
bucket is authoritative and is not subject to caching in front of the index.

Publishes the pure-Python wheel only.  The sdist is still built, because
tools/check_dist.py validates the wheel and sdist as a pair and that gate is
worth keeping intact, but it is never uploaded: the wheel is byte-identical
across rebuilds once SOURCE_DATE_EPOCH is pinned to the commit, whereas the
sdist is not reproducible even with it.  Only an artifact that can be rebuilt
and compared is fit for a consumer to pin.

Adopts the four-component convention already present in the bucket (upstream
PyHive 0.7.0 -> Preset 0.7.0.1/0.7.0.2), so the Preset build of upstream
1.1.11 is declared as 1.1.11.1 in sqlalchemy_drill/__init__.py.

A stable version is published only from master, i.e. only from reviewed and
merged history.  PR builds publish 1.1.11.1+PR-<n>.<shortsha>, and the build
asserts that a non-master branch can never emit the bare stable version rather
than leaving it to convention.

Uploads are immutable.  'aws s3 sync' is not used, because it replaces an
object whose content changed; the upload is an 'aws s3api put-object
--if-none-match *', which S3 rejects with 412 if the key exists, so the
no-overwrite guarantee is atomic instead of a check-then-write race.  After
upload the stored object is read back and digested, and the build fails if it
differs from what was built.  That digest is archived and is the value a
consumer pins.

The existence check uses the real artifact name.  setuptools emits the
underscored distribution name (sqlalchemy_drill-<version>...) while the bucket
prefix and Shell requirement use the dashed project name, so LIB_NAME and
DIST_NAME are separate; conflating them would have made the check probe a key
that never exists and silently permit an overwrite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant