|
| 1 | +name: Release checks |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + merge_group: |
| 6 | + types: [checks_requested] |
| 7 | + workflow_dispatch: {} |
| 8 | + |
| 9 | +env: |
| 10 | + SCCACHE_GHA_ENABLED: "true" |
| 11 | + RUSTC_WRAPPER: "sccache" |
| 12 | + # Pinned version for the uv package manager |
| 13 | + UV_VERSION: "0.7.5" |
| 14 | + # The highest and lowest supported Python versions, used for testing |
| 15 | + PYTHON_HIGHEST: "3.13" |
| 16 | + PYTHON_LOWEST: "3.10" |
| 17 | + |
| 18 | +jobs: |
| 19 | + # Check if changes were made to the relevant files. |
| 20 | + # Always returns true if running on the default branch, to ensure all changes are throughly checked. |
| 21 | + changes: |
| 22 | + name: Check for changes |
| 23 | + runs-on: ubuntu-latest |
| 24 | + # Required permissions |
| 25 | + permissions: |
| 26 | + pull-requests: read |
| 27 | + # Set job outputs to values from filter step |
| 28 | + # These outputs are always true when running after a merge to main, or if the PR has a `run-ci-checks` label. |
| 29 | + outputs: |
| 30 | + rust-release: ${{ steps.source-branch.outputs.rust == 'true' }} |
| 31 | + python-release: ${{ steps.source-branch.outputs.py == 'true' }} |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - name: Override label |
| 35 | + id: source-branch |
| 36 | + run: | |
| 37 | + if [ "${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'release-please-') }}" == "true" ]; then |
| 38 | + echo "This is a python release PR" |
| 39 | + echo "py=true" >> $GITHUB_OUTPUT |
| 40 | + elif [ "${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'release-plz-') }}" == "true" ]; then |
| 41 | + echo "This is a rust release PR" |
| 42 | + echo "rust=true" >> $GITHUB_OUTPUT |
| 43 | + elif [ "${{ github.event_name != 'pull_request' }}" == "true" ]; then |
| 44 | + echo "Manual trigger" |
| 45 | + echo "py=true" >> $GITHUB_OUTPUT |
| 46 | + echo "rust=true" >> $GITHUB_OUTPUT |
| 47 | + else |
| 48 | + echo "Not a release PR" |
| 49 | + fi |
| 50 | +
|
| 51 | + py-release: |
| 52 | + name: Check `tket2-py` release |
| 53 | + needs: changes |
| 54 | + if: ${{ needs.changes.outputs.python-release == 'true' }} |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - uses: mozilla-actions/sccache-action@v0.0.9 |
| 59 | + - name: Set up uv |
| 60 | + uses: astral-sh/setup-uv@v6 |
| 61 | + with: |
| 62 | + version: ${{ env.UV_VERSION }} |
| 63 | + enable-cache: true |
| 64 | + - name: Install Python ${{ env.PYTHON_HIGHEST }} |
| 65 | + run: uv python install ${{ env.PYTHON_HIGHEST }} |
| 66 | + - name: Setup `tke2-py` with only pypi deps |
| 67 | + run: | |
| 68 | + uv sync --no-sources --no-install-workspace \ |
| 69 | + --python ${{ env.PYTHON_HIGHEST }} |
| 70 | + uv pip install --no-sources tket2-exts |
| 71 | + uv pip install --no-sources tket2-eccs |
| 72 | + uv run --no-sync maturin develop |
| 73 | + echo "\nDone! Installed dependencies:" |
| 74 | + uv pip list |
| 75 | + - name: Lint with ruff |
| 76 | + run: uv run --no-sync ruff check |
| 77 | + - name: Run python tests |
| 78 | + run: uv run --no-sync pytest |
0 commit comments