Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 48 additions & 25 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
# This workflows will upload a Python Package using flit when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package
name: Publish the release to PyPI

on:
release:
types: [created]
branches:
- master

jobs:
deploy:
build:

name: Upload to PyPI

permissions:
id-token: write

if: github.repository_owner == 'bluesky'
runs-on: ubuntu-latest

env:
python_env: py313

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine setuptools
- name: Build and publish
env:
TWINE_USERNAME: __token__
# The PYPI_PASSWORD must be a pypi token with the "pypi-" prefix with sufficient permissions to upload this package
# https://pypi.org/help/#apitoken
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0

- uses: prefix-dev/setup-pixi@v0.10.0

- name: Install dev dependencies
run: |
set -vxeuo pipefail
pixi install --environment=${{ env.python_env }}
pixi list --environment=${{ env.python_env }}
pixi run --environment=${{ env.python_env }} pip list
pixi run --environment=${{ env.python_env }} conda list

- name: Build sdist and wheel
run: >
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) &&
pixi run --environment=${{ env.python_env }} python -m build

- name: Check for packaging errors
run: pixi run --environment=${{ env.python_env }} twine check --strict dist/*

- name: Install produced wheel
run: pixi run --environment=${{ env.python_env }} pip install dist/*.whl

- name: Test module is importable using the installed wheel
# If more than one module in src/ replace with module name to test
run: pixi run --environment=${{ env.python_env }} python -c "import $(ls --hide='*.egg-info' src | head -1)"

- name: Publish to PyPI using trusted publishing
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
8 changes: 4 additions & 4 deletions src/bluesky_httpserver/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
_user_group = "primary"


def _wait_for_http_server_ready(*, timeout=10, request_prefix="/api"):
def _wait_for_http_server_ready(*, http_server_host, http_server_port, timeout=10, request_prefix="/api"):
"""Wait until HTTP server accepts connections and responds to /status."""
t_stop = ttime.time() + timeout
url = f"http://{SERVER_ADDRESS}:{SERVER_PORT}{request_prefix}/status"
url = f"http://{http_server_host}:{http_server_port}{request_prefix}/status"
while ttime.time() < t_stop:
try:
response = requests.get(url, timeout=0.5)
Expand All @@ -57,7 +57,7 @@ class Starter(ProcessStarter):
# args = f"start-bluesky-httpserver --host={SERVER_ADDRESS} --port {SERVER_PORT}".split()

xprocess.ensure("fastapi_server", Starter)
_wait_for_http_server_ready()
_wait_for_http_server_ready(http_server_host=SERVER_ADDRESS, http_server_port=SERVER_PORT)

yield

Expand All @@ -84,7 +84,7 @@ class Starter(ProcessStarter):
args = f"uvicorn --host={http_server_host} --port {http_server_port} {bqss.__name__}:app".split()

xprocess.ensure("fastapi_server", Starter)
_wait_for_http_server_ready()
_wait_for_http_server_ready(http_server_host=http_server_host, http_server_port=http_server_port)

yield start

Expand Down
Loading