forked from psycopg/psycopg
-
Notifications
You must be signed in to change notification settings - Fork 5
105 lines (90 loc) · 3.13 KB
/
tests.yml
File metadata and controls
105 lines (90 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Tests without SSL
on:
push:
branches:
- "*"
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-22.04
services:
opengauss:
image: opengauss/opengauss-server:latest
ports:
- 5432:5432
env:
GS_USERNAME: root
GS_USER_PASSWORD: Passwd@123
GS_PASSWORD: Passwd@123
options: >-
--privileged=true
--name opengauss-custom
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: pip
- name: Create and activate virtual environment
run: |
python -m venv venv
echo "VENV_PATH=$GITHUB_WORKSPACE/venv/bin" >> $GITHUB_ENV
source venv/bin/activate
- name: Install gaussdb libpq driver
run: |
sudo apt update
sudo apt install -y wget unzip
wget -O /tmp/GaussDB_driver.zip https://dbs-download.obs.cn-north-1.myhuaweicloud.com/GaussDB/1730887196055/GaussDB_driver.zip
unzip /tmp/GaussDB_driver.zip -d /tmp/ && rm -rf /tmp/GaussDB_driver.zip
\cp /tmp/GaussDB_driver/Centralized/Hce2_X86_64/GaussDB-Kernel*64bit_Python.tar.gz /tmp/
tar -zxvf /tmp/GaussDB-Kernel*64bit_Python.tar.gz -C /tmp/ && rm -rf /tmp/GaussDB-Kernel*64bit_Python.tar.gz && rm -rf /tmp/_GaussDB && rm -rf /tmp/GaussDB_driver
echo /tmp/lib | sudo tee /etc/ld.so.conf.d/gauss-libpq.conf
sudo sed -i '1s|^|/tmp/lib\n|' /etc/ld.so.conf
sudo ldconfig
ldconfig -p | grep pq
- name: Install dependencies
run: |
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ./tools/isort-gaussdb/
pip install "./gaussdb[dev,test]"
pip install ./gaussdb_pool
- name: Wait for openGauss to be ready
env:
GSQL_PASSWORD: Passwd@123
run: |
source venv/bin/activate
for i in {1..30}; do
pg_isready -h localhost -p 5432 -U root && break
sleep 10
done
if ! pg_isready -h localhost -p 5432 -U root; 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 ;\"'"
- name: Create report directory
run: |
mkdir -p reports
- name: Run tests
env:
PYTHONPATH: ./gaussdb:./gaussdb_pool
GAUSSDB_IMPL: python
GAUSSDB_TEST_DSN: "host=127.0.0.1 port=5432 dbname=test user=root password=Passwd@123 "
run: |
source venv/bin/activate
pytest -s -v -W ignore::pytest.PytestUnraisableExceptionWarning
- name: Cleanup
if: always()
run: |
docker stop opengauss-custom
docker rm opengauss-custom