Add reusable workflow for python packaging tests #1
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: Reusable Python packaging tests | ||
| on: | ||
| workflow_call: | ||
| additional_apt_packages: | ||
| description: 'Additional APT packages to install' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| working_directory: | ||
| description: 'Working directory to use (default if unspecified)' | ||
| required: false | ||
| type: string | ||
| default: '.' | ||
| cli_test_cmd: | ||
| description: 'CLI test command to run' | ||
| default: '' | ||
| type: string | ||
| jobs: | ||
| name: Python packaging | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Cancel Previous Runs | ||
| uses: styfle/cancel-workflow-action@0.12.1 | ||
| with: | ||
| access_token: ${{ github.token }} | ||
| - uses: actions/checkout@v4.2.2 | ||
| - name: Install additional APT packages | ||
| if: ${{ inputs.additional_apt_packages != '' }} | ||
| run: sudo apt-get update && sudo apt-get install -y ${{ inputs.additional_commands }} | ||
| - uses: actions/setup-python@v5.4.0 | ||
| with: | ||
| python-version: '3.12' | ||
| - name: Install build deps | ||
| run: | | ||
| pip install uv | ||
| uv pip install --system build twine validate-pyproject[all] | ||
| - name: Check package | ||
| working-directory: ${{ inputs.working_directory }} | ||
| run: | | ||
| validate-pyproject pyproject.toml | ||
| python -m build | ||
| python -m twine check --strict dist/* | ||
| - name: Install | ||
| working-directory: ${{ inputs.working_directory }} | ||
| run: python -m pip install dist/*.whl | ||
| - name: Run CLI (if present) | ||
| if: ${{ inputs.cli_test_cmd != '' }} | ||
| run: ${{ inputs.cli_test_cmd }} | ||