feat(rabbitmq): 添加RabbitMQ增强功能示例和测试 #83
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: test suite | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: [ "3.8", "3.10" ] # 减少测试版本,只保留最低和较新版本 | |
| runs-on: ubuntu-latest | |
| services: | |
| rabbitmq: | |
| image: rabbitmq:3-alpine # 使用更轻量的alpine版本 | |
| options: >- | |
| --health-cmd "rabbitmqctl node_health_check" | |
| --health-interval 5s | |
| --health-timeout 3s | |
| --health-retries 3 | |
| env: | |
| RABBITMQ_DEFAULT_USER: admin | |
| RABBITMQ_DEFAULT_PASS: admin | |
| ports: | |
| - 5672:5672 | |
| steps: | |
| - uses: actions/checkout@v4 # 使用最新版本 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 # 使用最新版本 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: pip-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| pip-${{ runner.os }}-${{ matrix.python-version }}- | |
| - name: Install dependencies directly with pip | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install amqpstorm pytest | |
| python -m pip install -e . | |
| - name: Wait for RabbitMQ | |
| run: | | |
| timeout 30 bash -c 'until nc -z localhost 5672; do sleep 1; done' | |
| - name: Run tests | |
| timeout-minutes: 2 | |
| env: | |
| RABBITMQ_HOST: localhost | |
| RABBITMQ_USERNAME: admin | |
| RABBITMQ_PASSWORD: admin | |
| run: | | |
| python -m pytest tests/ -v --tb=short --disable-warnings |