| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| # |
| |
| # https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml |
| |
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
| |
| name: Python package |
| |
| on: |
| push: |
| pull_request: |
| workflow_dispatch: |
| |
| jobs: |
| build: |
| |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| matrix: |
| # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json |
| python-version: ["2.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-alpha.7"] |
| |
| steps: |
| - uses: actions/checkout@v3 |
| |
| - name: Set up Python ${{ matrix.python-version }} |
| uses: actions/setup-python@v3 |
| with: |
| python-version: ${{ matrix.python-version }} |
| |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| python -m pip install --user poetry |
| |
| - name: Cache Poetry virtualenv |
| uses: actions/cache@v3 |
| id: cache-home-virtualenvs |
| with: |
| path: ~/.virtualenvs |
| key: poetry-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} |
| restore-keys: | |
| poetry-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} |
| |
| - name: Set Poetry config |
| run: | |
| echo "POETRY_VIRTUALENVS_PATH=${HOME}/.virtualenvs" >> ${GITHUB_ENV} |
| echo "POETRY_VIRTUALENVS_IN-PROJECT=false" >> ${GITHUB_ENV} |
| |
| - name: Set additional Poetry config (py2.7) |
| if: matrix.python-version == '2.7' |
| run: | |
| # https://github.com/python-poetry/poetry/issues/3010 |
| # workaround parallel installation bug in old poetry |
| echo "POETRY_INSTALLER_MAX-WORKERS=1" >> ${GITHUB_ENV} |
| |
| - name: Install Dependencies |
| run: | |
| poetry env use ${{ env.pythonLocation }}/bin/python |
| poetry install --no-root |
| if: steps.cache.outputs.cache-hit != 'true' |
| |
| - name: Lint with flake8 |
| continue-on-error: true |
| run: | |
| # stop the build if there are Python syntax errors or undefined names |
| poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| |
| - name: Lint with ruff |
| continue-on-error: true |
| run: | |
| poetry run ruff check . |
| |
| - name: Start qpidd in docker |
| run: | |
| docker run --rm -d -p 5672:5672 irinabov/docker-qpid-cpp-broker |
| |
| attempts=0 |
| while ! nc -zv localhost 5672; do |
| attempts=$((attempts+1)) |
| if [ $attempts -ge 10 ]; then |
| echo >&2 "qpidd not reachable, giving up" |
| exit 1 |
| fi |
| sleep 3 |
| done |
| |
| - name: Client tests with our bespoke test runner |
| run: | |
| ${{ env.pythonLocation }}/bin/python ./qpid-python-test |
| |
| - name: Test setup.py install |
| run: | |
| ${{ env.pythonLocation }}/bin/python setup.py install --user |
| |
| - name: Broker tests with the 🛞 runner we ❤️ |
| run: | |
| # qpid-python dependency is the current package, it was installed in the prior step |
| ${{ env.pythonLocation }}/bin/python -m pip install --user qpid-tools qpid-qmf --no-deps |
| ${{ env.pythonLocation }}/bin/python qpid-python-test -m qpid_tests |