Skip to content

Commit ea86434

Browse files
committed
Prepare pg-workload for PyPI with synthetic profiles
0 parents  commit ea86434

61 files changed

Lines changed: 8842 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/publish.yml‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: pypi-publish
13+
cancel-in-progress: false
14+
15+
jobs:
16+
build:
17+
name: Test and build distributions
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 45
20+
21+
steps:
22+
- name: Check out tagged source
23+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
24+
25+
- name: Set up Python 3.10
26+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
27+
with:
28+
python-version: "3.10"
29+
30+
- name: Install test and build dependencies
31+
run: python -m pip install --upgrade pip ".[dev]"
32+
33+
- name: Verify tag matches package version
34+
shell: bash
35+
run: |
36+
package_version="$(
37+
python - <<'PY'
38+
try:
39+
import tomllib
40+
except ModuleNotFoundError:
41+
import tomli as tomllib
42+
43+
with open("pyproject.toml", "rb") as stream:
44+
print(tomllib.load(stream)["project"]["version"])
45+
PY
46+
)"
47+
if [[ "${GITHUB_REF_NAME}" != "v${package_version}" ]]; then
48+
echo "Tag ${GITHUB_REF_NAME} does not match package version ${package_version}" >&2
49+
exit 1
50+
fi
51+
52+
- name: Run unit tests
53+
run: |
54+
ruff check .
55+
ruff format --check .
56+
python -m pytest -q -p no:cacheprovider
57+
58+
- name: Run PostgreSQL 18 integration
59+
env:
60+
WORKLOAD_DOCKER_INTEGRATION: "1"
61+
PYTHONDONTWRITEBYTECODE: "1"
62+
run: python -m pytest -q -p no:cacheprovider tests/test_docker_postgres18.py
63+
64+
- name: Build wheel and source distribution
65+
run: python -m build
66+
67+
- name: Check distribution metadata and README rendering
68+
run: python -m twine check dist/*
69+
70+
- name: Smoke-test the built wheel
71+
shell: bash
72+
run: |
73+
python -m venv "${RUNNER_TEMP}/pg-workload-wheel-smoke"
74+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/python" -m pip install dist/*.whl
75+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" --version
76+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" init \
77+
--directory "${RUNNER_TEMP}/pg-workload-project"
78+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" profiles \
79+
--root "${RUNNER_TEMP}/pg-workload-project"
80+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" validate \
81+
--root "${RUNNER_TEMP}/pg-workload-project"
82+
83+
- name: Upload distributions for publishing
84+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
85+
with:
86+
name: python-distributions
87+
path: dist/
88+
if-no-files-found: error
89+
retention-days: 7
90+
91+
publish:
92+
name: Publish distributions to PyPI
93+
needs: build
94+
runs-on: ubuntu-latest
95+
timeout-minutes: 15
96+
environment:
97+
name: pypi
98+
url: https://pypi.org/p/pg-workload
99+
permissions:
100+
id-token: write
101+
102+
steps:
103+
- name: Download distributions
104+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
105+
with:
106+
name: python-distributions
107+
path: dist/
108+
109+
- name: Publish distributions with trusted publishing
110+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1

‎.github/workflows/tests.yml‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
unit:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.10", "3.12"]
16+
steps:
17+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
18+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- run: python -m pip install -e '.[dev]'
22+
- run: ruff check .
23+
- run: ruff format --check .
24+
- run: pytest -q
25+
26+
package:
27+
runs-on: ubuntu-latest
28+
needs: unit
29+
steps:
30+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
31+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
32+
with:
33+
python-version: "3.12"
34+
- run: python -m pip install build twine
35+
- run: python -m build
36+
- run: python -m twine check dist/*
37+
- name: Smoke-test installed wheel and bundled profiles
38+
shell: bash
39+
run: |
40+
python -m venv "${RUNNER_TEMP}/pg-workload-wheel-smoke"
41+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/python" -m pip install dist/*.whl
42+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" --version
43+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" init \
44+
--directory "${RUNNER_TEMP}/pg-workload-project"
45+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" profiles \
46+
--root "${RUNNER_TEMP}/pg-workload-project"
47+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" validate \
48+
--root "${RUNNER_TEMP}/pg-workload-project"
49+
"${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/python" -c \
50+
'import os; from pathlib import Path; root = Path(os.environ["RUNNER_TEMP"]) / "pg-workload-project/data"; assert len(list(root.glob("*/profile.yml"))) >= 7; assert not any(root.rglob("*.csv")); assert not any(root.rglob("*.tar.gz"))'
51+
52+
postgres-18:
53+
runs-on: ubuntu-latest
54+
needs: unit
55+
timeout-minutes: 30
56+
steps:
57+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
58+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
59+
with:
60+
python-version: "3.12"
61+
- run: python -m pip install -e '.[test]'
62+
- name: Run PostgreSQL 18 integration
63+
env:
64+
WORKLOAD_DOCKER_INTEGRATION: "1"
65+
PYTHONDONTWRITEBYTECODE: "1"
66+
run: pytest -q tests/test_docker_postgres18.py

‎.gitignore‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
.pytest_cache/
6+
.ruff_cache/
7+
.coverage
8+
htmlcov/
9+
.venv/
10+
venv/
11+
12+
# Build and release
13+
/build/
14+
/dist/
15+
16+
# Initialized runtime workspace (canonical assets live under src/pg_workload/bundled)
17+
/data/
18+
/schema/
19+
/state/
20+
*.log
21+
*.log.*
22+
*.pid
23+
*.lock
24+
25+
# External datasets and generated archives anywhere else
26+
*.csv
27+
*.csv.gz
28+
*.tar
29+
*.tar.gz
30+
*.zip
31+
pagila-insert-data.sql

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 O2eg
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎MANIFEST.in‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include LICENSE
2+
include README.md
3+
include THIRD_PARTY_NOTICES.md
4+
recursive-include src/pg_workload/bundled *
5+
prune data
6+
prune state
7+
global-exclude __pycache__ *.py[cod] *.log *.lock *.pid

0 commit comments

Comments
 (0)