Skip to content

Commit 2cd00d5

Browse files
authored
Merge pull request #5 from zhanghaitao3/master
Implement CI/CD Pipeline
2 parents a77fc30 + 284ec53 commit 2cd00d5

File tree

4 files changed

+54
-159
lines changed

4 files changed

+54
-159
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,15 @@
11
name: Release
22

33
on:
4-
pull_request:
5-
branches:
6-
- "master"
7-
- "ci"
8-
- "[0-9]+.[0-9x]+*"
9-
paths:
10-
- "async_gaussdb/_version.py"
4+
push:
5+
tags:
6+
- "*"
117

12-
jobs:
13-
validate-release-request:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Validate release PR
17-
uses: edgedb/action-release/validate-pr@master
18-
id: checkver
19-
with:
20-
require_team: Release Managers
21-
require_approval: no
22-
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
23-
version_file: async_gaussdb/_version.py
24-
version_line_pattern: |
25-
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
26-
27-
- name: Stop if not approved
28-
if: steps.checkver.outputs.approved != 'true'
29-
run: |
30-
echo ::error::PR is not approved yet.
31-
exit 1
32-
33-
- name: Store release version for later use
34-
env:
35-
VERSION: ${{ steps.checkver.outputs.version }}
36-
run: |
37-
mkdir -p dist/
38-
echo "${VERSION}" > dist/VERSION
39-
40-
- uses: actions/upload-artifact@v4
41-
with:
42-
name: dist-version
43-
path: dist/VERSION
8+
permissions:
9+
contents: write
4410

11+
jobs:
4512
build-sdist:
46-
needs: validate-release-request
4713
runs-on: ubuntu-latest
4814

4915
env:
@@ -71,7 +37,6 @@ jobs:
7137
path: dist/*.tar.*
7238

7339
build-wheels-matrix:
74-
needs: validate-release-request
7540
runs-on: ubuntu-latest
7641
outputs:
7742
include: ${{ steps.set-matrix.outputs.include }}
@@ -119,7 +84,7 @@ jobs:
11984
if: runner.os == 'Linux'
12085
uses: docker/setup-qemu-action@v2
12186

122-
- uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3
87+
- uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b
12388
with:
12489
only: ${{ matrix.only }}
12590
env:
@@ -214,8 +179,8 @@ jobs:
214179
id: relver
215180
run: |
216181
set -e
217-
echo "version=$(cat dist/VERSION)" >> $GITHUB_OUTPUT
218-
rm dist/VERSION
182+
# 从标签中提取版本
183+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
219184
220185
- name: Merge and tag the PR
221186
uses: edgedb/action-release/merge@master
@@ -233,8 +198,8 @@ jobs:
233198
with:
234199
tag_name: v${{ steps.relver.outputs.version }}
235200
release_name: v${{ steps.relver.outputs.version }}
236-
target: ${{ github.event.pull_request.base.ref }}
237-
body: ${{ github.event.pull_request.body }}
201+
target: ${{ github.ref }} # 使用提交的标签作为目标
202+
body: "Release v${{ steps.relver.outputs.version }}"
238203

239204
- run: |
240205
ls -al dist/

.github/workflows/tests.yml

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
21-
os: [ubuntu-latest, macos-latest, windows-latest]
21+
os: [ubuntu-latest]
2222
loop: [asyncio, uvloop]
2323
exclude:
2424
# uvloop does not support windows
@@ -33,6 +33,18 @@ jobs:
3333

3434
env:
3535
PIP_DISABLE_PIP_VERSION_CHECK: 1
36+
services:
37+
opengauss:
38+
image: opengauss/opengauss-server:latest
39+
ports:
40+
- 5432:5432
41+
env:
42+
GS_USERNAME: testuser
43+
GS_USER_PASSWORD: Test@123
44+
GS_PASSWORD: Test@123
45+
options: >-
46+
--privileged=true
47+
--name opengauss-custom
3648
3749
steps:
3850
- uses: actions/checkout@v4
@@ -50,11 +62,6 @@ jobs:
5062
version_line_pattern: |
5163
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
5264
53-
- name: Setup PostgreSQL
54-
if: "!steps.release.outputs.is_release && matrix.os == 'macos-latest'"
55-
run: |
56-
brew install postgresql
57-
5865
- name: Set up Python ${{ matrix.python-version }}
5966
uses: actions/setup-python@v5
6067
if: "!steps.release.outputs.is_release"
@@ -67,80 +74,45 @@ jobs:
6774
[ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh
6875
python -m pip install -U pip setuptools wheel
6976
python -m pip install -e .[test]
77+
78+
- name: Wait for openGauss to be ready
79+
env:
80+
GSQL_PASSWORD: Test@123
81+
run: |
82+
for i in {1..30}; do
83+
pg_isready -h localhost -p 5432 -U testuser && break
84+
sleep 10
85+
done
86+
if ! pg_isready -h localhost -p 5432 -U testuser; then
87+
echo "openGauss is not ready"
88+
exit 1
89+
fi
90+
91+
- name: Create test database
92+
run: |
93+
docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"CREATE DATABASE test ;CREATE user user ;\"'"
7094
7195
- name: Test
7296
if: "!steps.release.outputs.is_release"
7397
env:
7498
LOOP_IMPL: ${{ matrix.loop }}
99+
PGHOST: "127.0.0.1"
100+
PGPORT: 5432
101+
PGUSER: "testuser"
102+
PGPASSWORD: "Test@123"
103+
PGDATABASE: "test"
75104
run: |
76105
if [ "${LOOP_IMPL}" = "uvloop" ]; then
77106
env USE_UVLOOP=1 python -m unittest -v tests.suite
78107
else
79108
python -m unittest -v tests.suite
80109
fi
81110
82-
test-postgres:
83-
strategy:
84-
matrix:
85-
postgres-version: ["9.5", "9.6", "10", "11", "12", "13", "14", "15", "16", "17"]
86-
87-
runs-on: ubuntu-latest
88-
89-
env:
90-
PIP_DISABLE_PIP_VERSION_CHECK: 1
91-
92-
steps:
93-
- uses: actions/checkout@v4
94-
with:
95-
fetch-depth: 50
96-
submodules: true
97-
98-
- name: Check if release PR.
99-
uses: edgedb/action-release/validate-pr@master
100-
id: release
101-
with:
102-
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
103-
missing_version_ok: yes
104-
version_file: async_gaussdb/_version.py
105-
version_line_pattern: |
106-
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
107-
108-
- name: Set up PostgreSQL
109-
if: "!steps.release.outputs.is_release"
110-
env:
111-
PGVERSION: ${{ matrix.postgres-version }}
112-
DISTRO_NAME: focal
113-
run: |
114-
sudo env DISTRO_NAME="${DISTRO_NAME}" PGVERSION="${PGVERSION}" \
115-
.github/workflows/install-postgres.sh
116-
echo PGINSTALLATION="/usr/lib/postgresql/${PGVERSION}/bin" \
117-
>> "${GITHUB_ENV}"
118-
119-
- name: Set up Python ${{ matrix.python-version }}
120-
uses: actions/setup-python@v5
121-
if: "!steps.release.outputs.is_release"
122-
with:
123-
python-version: "3.x"
124-
125-
- name: Install Python Deps
126-
if: "!steps.release.outputs.is_release"
127-
run: |
128-
[ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh
129-
python -m pip install -U pip setuptools wheel
130-
python -m pip install -e .[test]
131-
132-
- name: Test
133-
if: "!steps.release.outputs.is_release"
134-
env:
135-
PGVERSION: ${{ matrix.postgres-version }}
136-
run: |
137-
python -m unittest -v tests.suite
138-
139111
# This job exists solely to act as the test job aggregate to be
140112
# targeted by branch policies.
141113
regression-tests:
142114
name: "Regression Tests"
143-
needs: [test-platforms, test-postgres]
115+
needs: [test-platforms]
144116
runs-on: ubuntu-latest
145117

146118
steps:

README.rst

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
async_gaussdb-gaussdb -- A fast GaussDB/openGauss Database Client Library for Python/asyncio
1+
async_gaussdb -- A fast GaussDB/openGauss Database Client Library for Python/asyncio
22
=====================================================================================
33

44
.. image:: https://github.com/MagicStack/async_gaussdb/workflows/Tests/badge.svg
@@ -7,12 +7,12 @@ async_gaussdb-gaussdb -- A fast GaussDB/openGauss Database Client Library for Py
77
.. image:: https://img.shields.io/pypi/v/async_gaussdb.svg
88
:target: https://pypi.python.org/pypi/async_gaussdb
99

10-
**async_gaussdb-gaussdb** is a database interface library designed specifically for
10+
**async_gaussdb** is a database interface library designed specifically for
1111
GaussDB and openGauss databases with Python/asyncio. This fork of async_gaussdb is
1212
optimized for GaussDB/openGauss compatibility, including native SHA256
1313
authentication support and enhanced features for enterprise database environments.
1414

15-
async_gaussdb-gaussdb requires Python 3.8 or later and is specifically designed for
15+
async_gaussdb requires Python 3.8 or later and is specifically designed for
1616
GaussDB and openGauss databases. It includes compatibility fixes and
1717
optimizations for openGauss-specific features and enterprise database requirements.
1818

@@ -24,31 +24,10 @@ optimizations for openGauss-specific features and enterprise database requiremen
2424
* Comprehensive test suite adapted for openGauss
2525

2626

27-
Documentation
28-
-------------
29-
30-
The project documentation can be found
31-
`here <https://magicstack.github.io/async_gaussdb/current/>`_.
32-
33-
34-
Performance
35-
-----------
36-
37-
async_gaussdb-gaussdb maintains the high performance characteristics of the original
38-
async_gaussdb library while being optimized for GaussDB/openGauss environments.
39-
40-
.. image:: https://raw.githubusercontent.com/MagicStack/async_gaussdb/master/performance.png?fddca40ab0
41-
:target: https://gistpreview.github.io/?0ed296e93523831ea0918d42dd1258c2
42-
43-
The above results are a geometric mean of benchmarks obtained with PostgreSQL
44-
`client driver benchmarking toolbench <https://github.com/MagicStack/pgbench>`_
45-
in June 2023 (click on the chart to see full details).
46-
47-
4827
Features
4928
--------
5029

51-
async_gaussdb-gaussdb implements the GaussDB/openGauss server protocol natively and
30+
async_gaussdb implements the GaussDB/openGauss server protocol natively and
5231
exposes its features directly, optimized for enterprise database environments:
5332

5433
* **SHA256 authentication** - Native support for GaussDB/openGauss authentication
@@ -65,7 +44,7 @@ exposes its features directly, optimized for enterprise database environments:
6544
Installation
6645
------------
6746

68-
async_gaussdb-gaussdb is available on PyPI. When not using GSSAPI/SSPI authentication it
47+
async_gaussdb is available on PyPI. When not using GSSAPI/SSPI authentication it
6948
has no dependencies. Use pip to install::
7049

7150
$ pip install async-gaussdb
@@ -137,21 +116,4 @@ This library includes enhanced support for GaussDB and openGauss databases:
137116
asyncio.run(run())
138117
139118
140-
Development with Docker
141-
----------------------
142-
143-
A Dockerfile is provided for development with openGauss:
144-
145-
.. code-block:: bash
146-
147-
# Build the development image
148-
docker build -t async_gaussdb-gaussdb-dev .
149-
150-
# Run the container
151-
docker run -it async_gaussdb-gaussdb-dev
152-
153-
154-
License
155-
-------
156-
157-
async_gaussdb-gaussdb is developed and distributed under the Apache 2.0 license.
119+
asyncpg is developed and distributed under the Apache 2.0 license.

tests/test_connect.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import warnings
2525
import weakref
2626

27-
import distro
28-
2927
import async_gaussdb
3028
from async_gaussdb import _testbase as tb
3129
from async_gaussdb import connection as pg_connection
@@ -390,8 +388,7 @@ async def test_auth_md5_unsupported(self, _):
390388
await self.connect(user='md5_user', password=CORRECT_PASSWORD)
391389

392390

393-
@unittest.skipIf(
394-
distro.id() == "alpine",
391+
@unittest.skip(
395392
"Alpine Linux ships GaussDBSQL without GSS auth support",
396393
)
397394
class TestGssAuthentication(BaseTestAuthentication):
@@ -411,7 +408,6 @@ def setUpClass(cls):
411408
# Add credentials.
412409
cls.realm.addprinc('gaussdb/localhost')
413410
cls.realm.extract_keytab('gaussdb/localhost', cls.realm.keytab)
414-
415411
cls.USERS = [
416412
(cls.realm.user_princ, 'gss', None),
417413
(f'wrong-{cls.realm.user_princ}', 'gss', None),

0 commit comments

Comments
 (0)