feat: context manager protocol #2174
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: "3.10" | |
| - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | |
| # Make sure commit messages follow the conventional commits convention: | |
| # https://www.conventionalcommits.org | |
| commitlint: | |
| name: Lint Commit Messages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6 | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| - "3.14" | |
| - "3.14t" | |
| os: | |
| - ubuntu-latest | |
| extension: | |
| - "skip_cython" | |
| - "use_cython" | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| - name: Install libs | |
| run: sudo apt-get update && sudo apt-get install -y dbus-daemon python3-gi libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 | |
| - uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1 | |
| - name: Set up Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: "poetry" | |
| allow-prereleases: true | |
| - name: Install Dependencies | |
| run: | | |
| if [ "${{ matrix.extension }}" = "skip_cython" ]; then | |
| SKIP_CYTHON=1 poetry install --only=main,dev | |
| else | |
| REQUIRE_CYTHON=1 poetry install --only=main,dev | |
| fi | |
| - name: Test with Pytest | |
| run: dbus-run-session -- poetry run pytest --cov-report=xml --timeout=5 | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| test_big_endian: | |
| name: Big-endian s390x tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| - uses: uraimo/run-on-arch-action@1c358dc49363439f8c563ce8f93005f7fe76b849 # v3 | |
| name: Run commands | |
| id: runcmd | |
| with: | |
| arch: s390x | |
| distro: ubuntu_latest | |
| run: | | |
| apt-get -y update | |
| apt-get -y install git python3-pip python3-venv python3-poetry dbus-daemon python3-gi libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 | |
| git clone --depth 1 $GITHUB_SERVER_URL/$GITHUB_REPOSITORY | |
| cd dbus-fast | |
| git fetch origin --depth 1 $GITHUB_SHA | |
| git checkout $GITHUB_SHA | |
| REQUIRE_CYTHON=1 poetry install --only=main,dev | |
| dbus-run-session -- poetry run pytest --no-cov --timeout=100 | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| - name: Install libs | |
| run: sudo apt-get update && sudo apt-get install -y dbus-daemon python3-gi libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 | |
| - uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1 | |
| - name: Setup Python 3.13 | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: 3.13 | |
| cache: "poetry" | |
| - name: Install Dependencies | |
| run: | | |
| REQUIRE_CYTHON=1 poetry install --only=main,dev | |
| shell: bash | |
| - name: Run benchmarks | |
| uses: CodSpeedHQ/action@972e3437949c89e1357ebd1a2dbc852fcbc57245 # v3 | |
| with: | |
| mode: instrumentation | |
| token: ${{ secrets.CODSPEED_TOKEN }} | |
| run: dbus-run-session -- poetry run pytest --no-cov -vvvvv --codspeed tests/benchmarks | |
| release: | |
| needs: | |
| - test | |
| - lint | |
| - commitlint | |
| runs-on: ubuntu-latest | |
| environment: release | |
| concurrency: release | |
| permissions: | |
| id-token: write | |
| contents: write | |
| outputs: | |
| released: ${{ steps.release.outputs.released }} | |
| newest_release_tag: ${{ steps.release_tag.outputs.newest_release_tag }} | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.head_ref || github.ref_name }} | |
| # Do a dry run of PSR | |
| - name: Test release | |
| uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 | |
| if: github.ref_name != 'main' | |
| with: | |
| no_operation_mode: true | |
| # On main branch: actual PSR + upload to PyPI & GitHub | |
| - name: Release | |
| uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 | |
| id: release | |
| if: github.ref_name == 'main' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1 | |
| if: steps.release.outputs.released == 'true' | |
| - name: Publish package distributions to GitHub Releases | |
| uses: python-semantic-release/upload-to-gh-release@0a92b5d7ebfc15a84f9801ebd1bf706343d43711 # main | |
| if: steps.release.outputs.released == 'true' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install python-semantic-release | |
| run: python3 -m pip install python-semantic-release==7.34.6 | |
| - name: Get Release Tag | |
| id: release_tag | |
| shell: bash | |
| run: | | |
| echo "newest_release_tag=$(semantic-release print-version --current)" >> $GITHUB_OUTPUT | |
| build_wheels: | |
| needs: [release] | |
| if: needs.release.outputs.released == 'true' | |
| name: Build wheels on ${{ matrix.os }} with arch ${{ matrix.arch }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04-arm, ubuntu-latest, macos-latest] | |
| musl: ["", "musllinux"] | |
| exclude: | |
| - os: macos-latest | |
| musl: "musllinux" | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| ref: "v${{ needs.release.outputs.newest_release_tag }}" | |
| fetch-depth: 0 | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@63fd63b352a9a8bdcc24791c9dbee952ee9a8abc # v3.3.0 | |
| env: | |
| CIBW_SKIP: "*p36-* *p37-* *p38-* ${{ matrix.musl == 'musllinux' && '*manylinux*' || '*musllinux*' }}" | |
| CIBW_BEFORE_ALL_LINUX: apt-get install -y gcc || yum install -y gcc || apk add gcc | |
| CIBW_BUILD_VERBOSITY: 3 | |
| REQUIRE_CYTHON: 1 | |
| CIBW_ARCHS_LINUX: ${{ matrix.os == 'ubuntu-24.04-arm' && 'aarch64' || 'auto' }} | |
| - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4 | |
| with: | |
| path: ./wheelhouse/*.whl | |
| name: wheels-${{ matrix.os }}-${{ matrix.musl }} | |
| upload_pypi: | |
| needs: [build_wheels] | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4 | |
| with: | |
| # unpacks default artifact into dist/ | |
| # if `name: artifact` is omitted, the action will create extra parent dir | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |