Skip to content

Commit 32b56f4

Browse files
committed
Update github workflows to only run PR checks against the management API if they contain relevant changes
1 parent 821d7f2 commit 32b56f4

File tree

2 files changed

+178
-5
lines changed

2 files changed

+178
-5
lines changed

.github/workflows/code-check.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: Coverage tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-coverage:
12+
runs-on: ubuntu-latest
13+
environment: Base
14+
15+
services:
16+
singlestore:
17+
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
18+
ports:
19+
- 3307:3306
20+
- 8081:8080
21+
- 9081:9081
22+
env:
23+
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
24+
ROOT_PASSWORD: "root"
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.10"
36+
cache: "pip"
37+
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install -r requirements.txt
42+
pip install -r test-requirements.txt
43+
44+
- name: Install SingleStore package
45+
run: |
46+
pip install .
47+
48+
- name: Check for changes in monitored directories
49+
id: check-changes
50+
run: |
51+
# Define directories to monitor (space-separated)
52+
MONITORED_DIRS="singlestoredb/management singlestoredb/fusion"
53+
54+
# Determine the base commit to compare against
55+
if [ "${{ github.event_name }}" == "pull_request" ]; then
56+
# For PRs, compare against the target branch (usually master/main)
57+
BASE_COMMIT="origin/${{ github.event.pull_request.base.ref }}"
58+
echo "Pull Request: Comparing against $BASE_COMMIT"
59+
elif [ "${{ github.ref_name }}" == "main" ] || [ "${{ github.ref_name }}" == "master" ]; then
60+
# For pushes to main/master, compare against previous commit
61+
BASE_COMMIT="HEAD~1"
62+
echo "Push to main/master: Comparing against $BASE_COMMIT"
63+
else:
64+
# For pushes to other branches, compare against master/main
65+
if git rev-parse --verify origin/main >/dev/null 2>&1; then
66+
BASE_COMMIT="origin/main"
67+
echo "Push to branch: Comparing against origin/main"
68+
elif git rev-parse --verify origin/master >/dev/null 2>&1; then
69+
BASE_COMMIT="origin/master"
70+
echo "Push to branch: Comparing against origin/master"
71+
else
72+
# Fallback to previous commit if master/main not found
73+
BASE_COMMIT="HEAD~1"
74+
echo "Fallback: Comparing against HEAD~1"
75+
fi
76+
fi
77+
78+
echo "Checking for changes in: $MONITORED_DIRS"
79+
echo "Comparing against: $BASE_COMMIT"
80+
81+
# Check for any changes in monitored directories
82+
CHANGES_FOUND=false
83+
CHANGED_DIRS=""
84+
85+
for DIR in $MONITORED_DIRS; do
86+
if [ -d "$DIR" ]; then
87+
CHANGED_FILES=$(git diff --name-only $BASE_COMMIT HEAD -- "$DIR" || true)
88+
if [ -n "$CHANGED_FILES" ]; then
89+
echo "✅ Changes detected in: $DIR"
90+
echo "Files changed:"
91+
echo "$CHANGED_FILES" | sed 's/^/ - /'
92+
CHANGES_FOUND=true
93+
if [ -z "$CHANGED_DIRS" ]; then
94+
CHANGED_DIRS="$DIR"
95+
else
96+
CHANGED_DIRS="$CHANGED_DIRS,$DIR"
97+
fi
98+
else
99+
echo "❌ No changes in: $DIR"
100+
fi
101+
else
102+
echo "⚠️ Directory not found: $DIR"
103+
fi
104+
done
105+
106+
# Set outputs
107+
if [ "$CHANGES_FOUND" = true ]; then
108+
echo "changes-detected=true" >> $GITHUB_OUTPUT
109+
echo "changed-directories=$CHANGED_DIRS" >> $GITHUB_OUTPUT
110+
echo ""
111+
echo "🎯 RESULT: Changes detected in monitored directories"
112+
else
113+
echo "changes-detected=false" >> $GITHUB_OUTPUT
114+
echo "changed-directories=" >> $GITHUB_OUTPUT
115+
echo ""
116+
echo "🎯 RESULT: No changes in monitored directories"
117+
fi
118+
119+
- name: Run MySQL protocol tests (with management API)
120+
if: steps.check-changes.outputs.changes-detected == 'true'
121+
run: |
122+
pytest -v --cov=singlestoredb --pyargs singlestoredb.tests
123+
env:
124+
COVERAGE_FILE: "coverage-mysql.cov"
125+
SINGLESTOREDB_URL: "root:root@127.0.0.1:3307"
126+
SINGLESTOREDB_PURE_PYTHON: 0
127+
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
128+
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
129+
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
130+
131+
- name: Run MySQL protocol tests (without management API)
132+
if: steps.check-changes.outputs.changes-detected == 'false'
133+
run: |
134+
pytest -v -m 'not management' --cov=singlestoredb --pyargs singlestoredb.tests
135+
env:
136+
COVERAGE_FILE: "coverage-mysql.cov"
137+
SINGLESTOREDB_URL: "root:root@127.0.0.1:3307"
138+
SINGLESTOREDB_PURE_PYTHON: 0
139+
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
140+
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
141+
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
142+
143+
- name: Run MySQL protocol tests (pure Python)
144+
run: |
145+
pytest -v -m 'not management' --cov=singlestoredb --pyargs singlestoredb.tests
146+
env:
147+
COVERAGE_FILE: "coverage-mysql-py.cov"
148+
SINGLESTOREDB_URL: "root:root@127.0.0.1:3307"
149+
SINGLESTOREDB_PURE_PYTHON: 1
150+
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
151+
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
152+
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
153+
154+
- name: Run HTTP protocol tests
155+
run: |
156+
pytest -v -m 'not management' --cov=singlestoredb --pyargs singlestoredb.tests
157+
env:
158+
COVERAGE_FILE: "coverage-http.cov"
159+
SINGLESTOREDB_URL: "http://root:root@127.0.0.1:9081"
160+
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
161+
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
162+
# Can not change databases using HTTP API. The URL below will be
163+
# used to create the database and the generated database name will
164+
# be applied to the above URL.
165+
SINGLESTOREDB_INIT_DB_URL: "root:root@127.0.0.1:3307"
166+
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
167+
168+
- name: Generate report
169+
run: |
170+
coverage combine coverage-mysql.cov coverage-http.cov coverage-mysql-py.cov
171+
coverage report
172+
coverage xml
173+
coverage html

.github/workflows/coverage.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: Coverage tests
22

33
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
4+
schedule:
5+
- cron: "0 1 * * *"
86
workflow_dispatch:
97

108
jobs:
@@ -24,7 +22,9 @@ jobs:
2422
ROOT_PASSWORD: "root"
2523

2624
steps:
27-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
2828

2929
- name: Set up Python
3030
uses: actions/setup-python@v4

0 commit comments

Comments
 (0)