CI #1129
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: | |
| paths-ignore: | |
| - 'docs/**' | |
| - '**/*.rst' | |
| - '**/*.md' | |
| branches: | |
| - main | |
| - '[0-9].[0-9]' | |
| pull_request: | |
| branches: | |
| - main | |
| - '[0-9].[0-9]' | |
| schedule: | |
| - cron: '0 1 * * *' # nightly build | |
| concurrency: | |
| group: ${{ github.event.pull_request.number || github.ref }}-integration | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| jobs: | |
| dependency-audit: | |
| name: Dependency audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: pypa/[email protected] | |
| with: | |
| inputs: . | |
| ignore-vulns: | | |
| GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. | |
| lint: | |
| name: Code linters | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.13 | |
| cache: 'pip' | |
| - name: run code linters | |
| run: | | |
| pip install --group dev | |
| make linters | |
| get-date: | |
| name: Get current date for cache | |
| outputs: | |
| current_date: ${{ steps.date.outputs.current_date }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set current date | |
| id: date | |
| run: echo "current_date=$(date -u +'%Y%m%d')" >> $GITHUB_OUTPUT | |
| populate-cache: | |
| runs-on: ubuntu-latest | |
| needs: [get-date, dependency-audit, lint] | |
| timeout-minutes: 60 | |
| name: Update docker cache | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Cache docker images | |
| id: custom-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ./custom-cache/ | |
| key: custom-cache-${{ needs.get-date.outputs.current_date }} | |
| - if: ${{ steps.custom-cache.outputs.cache-hit != 'true' }} | |
| name: Update Cache | |
| run: | | |
| mkdir -p ./custom-cache/ | |
| docker compose --profile all build | |
| docker pull valkey/valkey:latest | |
| docker save valkey-py-stunnel:latest valkey-py-cluster:latest valkey/valkey:latest -o ./custom-cache/all.tar | |
| run-tests: | |
| runs-on: ubuntu-latest | |
| needs: [populate-cache, get-date] | |
| timeout-minutes: 60 | |
| strategy: | |
| max-parallel: 15 | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.11.1', '3.12', '3.13', '3.14-dev', 'pypy-3.10', 'pypy-3.11'] | |
| test-type: ['standalone', 'cluster'] | |
| connection-type: ['libvalkey', 'plain'] | |
| protocol-version: ['2','3'] | |
| env: | |
| ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
| name: Python ${{ matrix.python-version }} RESP${{ matrix.protocol-version }} ${{matrix.test-type}}-${{matrix.connection-type}} tests | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Cache docker images | |
| id: custom-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ./custom-cache/ | |
| fail-on-cache-miss: true | |
| key: custom-cache-${{ needs.get-date.outputs.current_date }} | |
| - name: Use Cache | |
| run: docker image load -i ./custom-cache/all.tar | |
| - name: run tests | |
| run: | | |
| pip install --group dev | |
| pip install . | |
| if [ "${{matrix.connection-type}}" == "libvalkey" ]; then | |
| pip install "libvalkey>=4.0.1" | |
| fi | |
| make devenv | |
| if [[ "${{matrix.test-type}}" == "standalone" ]]; then | |
| ./util/wait-for-it.sh localhost:6379 | |
| else | |
| ./util/wait-for-it.sh localhost:16379 | |
| fi | |
| make ${{matrix.test-type}}-tests PROTOCOL=${{ matrix.protocol-version }} | |
| # TODO: remove check for 3.14 once it's fixed | |
| # https://github.com/MagicStack/uvloop/issues/637 | |
| if [[ "${{matrix.python-version}}" != pypy-* && "${{matrix.python-version}}" != "3.14-dev" ]]; then | |
| make ${{matrix.test-type}}-tests USE_UVLOOP=1 PROTOCOL=${{ matrix.protocol-version }} | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| if: success() || failure() | |
| with: | |
| name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-RESP${{ matrix.protocol-version }} | |
| path: '${{matrix.test-type}}*results.xml' | |
| - name: Upload codecov coverage | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| build_and_test_package: | |
| name: Validate building and installing the package | |
| runs-on: ubuntu-latest | |
| needs: [run-tests, get-date, populate-cache] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| extension: ['tar.gz', 'whl'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.13 | |
| - name: Cache docker images | |
| id: custom-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ./custom-cache/ | |
| fail-on-cache-miss: true | |
| key: custom-cache-${{ needs.get-date.outputs.current_date }} | |
| - name: Use Cache | |
| run: docker image load -i ./custom-cache/all.tar | |
| - name: Run installed unit tests | |
| run: | | |
| bash .github/workflows/install_and_test.sh ${{ matrix.extension }} | |
| install_package_from_commit: | |
| name: Install package from commit hash | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.11.1', '3.12', '3.13', '3.14-dev', 'pypy-3.10', 'pypy-3.11'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: install from pip | |
| run: | | |
| pip install --quiet git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git@${GITHUB_SHA} |