Merge pull request #17 from zhanghaitao3/master #19
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: Tests | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - ci | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| test-platforms: | |
| # NOTE: this matrix is for testing various combinations of Python and OS | |
| # versions on the system-installed PostgreSQL version (which is usually | |
| # fairly recent). For a PostgreSQL version matrix see the test-postgres | |
| # job. | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
| os: [ubuntu-latest] | |
| loop: [asyncio, uvloop] | |
| exclude: | |
| # uvloop does not support windows | |
| - loop: uvloop | |
| os: windows-latest | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| PIP_DISABLE_PIP_VERSION_CHECK: 1 | |
| services: | |
| opengauss: | |
| image: opengauss/opengauss-server:latest | |
| ports: | |
| - 5432:5432 | |
| env: | |
| GS_USERNAME: testuser | |
| GS_USER_PASSWORD: Test@123 | |
| GS_PASSWORD: Test@123 | |
| options: >- | |
| --privileged=true | |
| --name opengauss-custom | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 50 | |
| submodules: true | |
| - name: Check if release PR. | |
| uses: edgedb/action-release/validate-pr@master | |
| id: release | |
| with: | |
| github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} | |
| missing_version_ok: yes | |
| version_file: async_gaussdb/_version.py | |
| version_line_pattern: | | |
| __version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"]) | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| if: "!steps.release.outputs.is_release" | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Python Deps | |
| if: "!steps.release.outputs.is_release" | |
| run: | | |
| [ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh | |
| python -m pip install -U pip setuptools wheel | |
| python -m pip install -e .[test] | |
| # 添加 uvloop 安装 | |
| if [ "${{ matrix.loop }}" = "uvloop" ]; then | |
| python -m pip install uvloop | |
| fi | |
| - name: Wait for openGauss to be ready | |
| env: | |
| GSQL_PASSWORD: Test@123 | |
| run: | | |
| for i in {1..30}; do | |
| pg_isready -h localhost -p 5432 -U testuser && break | |
| sleep 10 | |
| done | |
| if ! pg_isready -h localhost -p 5432 -U testuser; then | |
| echo "openGauss is not ready" | |
| exit 1 | |
| fi | |
| - name: Create test database | |
| run: | | |
| docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"CREATE DATABASE test ;CREATE user user ;\"'" | |
| - name: Test | |
| if: "!steps.release.outputs.is_release" | |
| env: | |
| LOOP_IMPL: ${{ matrix.loop }} | |
| PGHOST: "127.0.0.1" | |
| PGPORT: 5432 | |
| PGUSER: "testuser" | |
| PGPASSWORD: "Test@123" | |
| PGDATABASE: "test" | |
| run: | | |
| if [ "${LOOP_IMPL}" = "uvloop" ]; then | |
| env USE_UVLOOP=1 python -m unittest -v tests.suite | |
| else | |
| python -m unittest -v tests.suite | |
| fi | |
| # This job exists solely to act as the test job aggregate to be | |
| # targeted by branch policies. | |
| regression-tests: | |
| name: "Regression Tests" | |
| needs: [test-platforms] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo OK |