Skip to content

Commit d76c735

Browse files
author
Peng Ren
committed
Refactor workflow
1 parent 8470042 commit d76c735

File tree

2 files changed

+3
-88
lines changed

2 files changed

+3
-88
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_call:
89

910
jobs:
1011
test:

.github/workflows/release.yml

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -48,94 +48,8 @@ jobs:
4848
flake8 pymongosql/ --count --statistics
4949
5050
test:
51-
name: Test Suite
52-
runs-on: ubuntu-latest
53-
strategy:
54-
fail-fast: false
55-
matrix:
56-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
57-
mongodb-version: ['7.0', '8.0']
58-
59-
services:
60-
mongodb:
61-
image: mongo:${{ matrix.mongodb-version }}
62-
env:
63-
MONGO_INITDB_ROOT_USERNAME: admin
64-
MONGO_INITDB_ROOT_PASSWORD: secret
65-
ports:
66-
- 27017:27017
67-
options: >-
68-
--health-cmd "mongosh --eval 'db.runCommand({ping: 1})' --quiet"
69-
--health-interval 30s
70-
--health-timeout 10s
71-
--health-retries 5
72-
73-
steps:
74-
- uses: actions/checkout@v4
75-
76-
- name: Set up Python ${{ matrix.python-version }}
77-
uses: actions/setup-python@v4
78-
with:
79-
python-version: ${{ matrix.python-version }}
80-
81-
- name: Cache pip dependencies
82-
uses: actions/cache@v3
83-
with:
84-
path: ~/.cache/pip
85-
key: ${{ runner.os }}-py${{ matrix.python-version }}-mongo${{ matrix.mongodb-version }}-pip-${{ hashFiles('**/requirements-test.txt', 'pyproject.toml') }}
86-
restore-keys: |
87-
${{ runner.os }}-py${{ matrix.python-version }}-mongo${{ matrix.mongodb-version }}-pip-
88-
89-
- name: Install MongoDB shell
90-
run: |
91-
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
92-
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
93-
sudo apt-get update
94-
sudo apt-get install -y mongodb-mongosh
95-
96-
- name: Install dependencies
97-
run: |
98-
python -m pip install --upgrade pip
99-
pip install -r requirements-test.txt
100-
pip install -e .
101-
102-
- name: Wait for MongoDB to be ready
103-
run: |
104-
echo "Waiting for MongoDB to be ready..."
105-
for i in {1..30}; do
106-
if mongosh --host localhost:27017 --username admin --password secret --authenticationDatabase admin --eval "db.runCommand({ping: 1})" --quiet; then
107-
echo "MongoDB is ready!"
108-
break
109-
fi
110-
echo "Attempt $i: MongoDB not ready yet, waiting..."
111-
sleep 2
112-
done
113-
114-
- name: Set up test database
115-
run: |
116-
echo "Setting up test database..."
117-
python tests/run_test_server.py setup || true
118-
119-
- name: Run tests with coverage
120-
run: |
121-
python -m pytest tests/ -v --cov=pymongosql --cov-report=term-missing --cov-report=xml --cov-report=html
122-
123-
- name: Upload coverage to Codecov
124-
uses: codecov/codecov-action@v4
125-
if: matrix.python-version == '3.11' && matrix.mongodb-version == '8.0'
126-
with:
127-
env_vars: OS,PYTHON
128-
token: ${{ secrets.CODECOV_TOKEN }}
129-
files: ./coverage.xml
130-
flags: unittests
131-
fail_ci_if_error: false
132-
133-
- name: Upload coverage artifacts
134-
uses: actions/upload-artifact@v4
135-
if: matrix.python-version == '3.11' && matrix.mongodb-version == '8.0'
136-
with:
137-
name: coverage-report
138-
path: htmlcov/
51+
name: Run CI Tests
52+
uses: ./.github/workflows/ci.yml
13953

14054
build:
14155
name: Build Distribution

0 commit comments

Comments
 (0)