feat: unify workload orchestration and profiles #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPI | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: pypi-publish | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Test and build distributions | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Check out tagged source | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Install test and build dependencies | |
| run: python -m pip install --upgrade 'pip>=24.3,<26' ".[dev]" | |
| - name: Verify tag matches package version | |
| shell: bash | |
| run: | | |
| package_version="$( | |
| python - <<'PY' | |
| try: | |
| import tomllib | |
| except ModuleNotFoundError: | |
| import tomli as tomllib | |
| with open("pyproject.toml", "rb") as stream: | |
| print(tomllib.load(stream)["project"]["version"]) | |
| PY | |
| )" | |
| if [[ "${GITHUB_REF_NAME}" != "v${package_version}" ]]; then | |
| echo "Tag ${GITHUB_REF_NAME} does not match package version ${package_version}" >&2 | |
| exit 1 | |
| fi | |
| - name: Run unit tests | |
| run: | | |
| ruff check . | |
| ruff format --check . | |
| python -m pytest -q -p no:cacheprovider | |
| - name: Run PostgreSQL 18 integration | |
| env: | |
| WORKLOAD_DOCKER_INTEGRATION: "1" | |
| PYTHONDONTWRITEBYTECODE: "1" | |
| run: python -m pytest -q -p no:cacheprovider tests/test_docker_postgres18.py | |
| - name: Build wheel and source distribution | |
| run: python -m build | |
| - name: Check distribution metadata and README rendering | |
| run: python -m twine check dist/* | |
| - name: Smoke-test the built wheel | |
| shell: bash | |
| run: | | |
| python -m venv "${RUNNER_TEMP}/pg-workload-wheel-smoke" | |
| "${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/python" -m pip install dist/*.whl | |
| "${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" --version | |
| "${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" init \ | |
| --directory "${RUNNER_TEMP}/pg-workload-project" | |
| "${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" profiles \ | |
| --root "${RUNNER_TEMP}/pg-workload-project" | |
| "${RUNNER_TEMP}/pg-workload-wheel-smoke/bin/pg-workload" validate \ | |
| --root "${RUNNER_TEMP}/pg-workload-project" | |
| - name: Upload distributions for publishing | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: python-distributions | |
| path: dist/ | |
| if-no-files-found: error | |
| retention-days: 7 | |
| publish: | |
| name: Publish distributions to PyPI | |
| needs: build | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pg-workload | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download distributions | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| name: python-distributions | |
| path: dist/ | |
| - name: Publish distributions with trusted publishing | |
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 |