-
Notifications
You must be signed in to change notification settings - Fork 22
189 lines (169 loc) · 7.17 KB
/
code-check.yml
File metadata and controls
189 lines (169 loc) · 7.17 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Code checks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test-coverage:
runs-on: ubuntu-latest
environment: Base
services:
singlestore:
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
ports:
- 3307:3306
- 8081:8080
- 9081:9081
env:
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
ROOT_PASSWORD: "root"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Check for changes in monitored directories
id: check-changes
run: |
# Define directories to monitor (space-separated)
MONITORED_DIRS="singlestoredb/management singlestoredb/fusion"
# Determine the base commit to compare against
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For PRs, compare against the target branch (usually master/main)
BASE_COMMIT="origin/${{ github.event.pull_request.base.ref }}"
echo "Pull Request: Comparing against $BASE_COMMIT"
elif [ "${{ github.ref_name }}" == "main" ] || [ "${{ github.ref_name }}" == "master" ]; then
# For pushes to main/master, compare against previous commit
BASE_COMMIT="HEAD~1"
echo "Push to main/master: Comparing against $BASE_COMMIT"
else
# For pushes to other branches, compare against master/main
if git rev-parse --verify origin/main >/dev/null 2>&1; then
BASE_COMMIT="origin/main"
echo "Push to branch: Comparing against origin/main"
elif git rev-parse --verify origin/master >/dev/null 2>&1; then
BASE_COMMIT="origin/master"
echo "Push to branch: Comparing against origin/master"
else
# Fallback to previous commit if master/main not found
BASE_COMMIT="HEAD~1"
echo "Fallback: Comparing against HEAD~1"
fi
fi
# Check if this is a release preparation commit
COMMIT_MSG=$(git log -1 --format='%s' HEAD)
if [[ "$COMMIT_MSG" =~ ^Prepare\ for\ v[0-9]+\.[0-9]+\.[0-9]+\ release$ ]]; then
echo "🚀 Release preparation commit detected: $COMMIT_MSG"
echo "changes-detected=true" >> $GITHUB_OUTPUT
echo "changed-directories=release" >> $GITHUB_OUTPUT
echo ""
echo "🎯 RESULT: Full test suite will run for release preparation"
exit 0
fi
echo "Checking for changes in: $MONITORED_DIRS"
echo "Comparing against: $BASE_COMMIT"
# Check for any changes in monitored directories
CHANGES_FOUND=false
CHANGED_DIRS=""
for DIR in $MONITORED_DIRS; do
if [ -d "$DIR" ]; then
CHANGED_FILES=$(git diff --name-only $BASE_COMMIT HEAD -- "$DIR" || true)
if [ -n "$CHANGED_FILES" ]; then
echo "✅ Changes detected in: $DIR"
echo "Files changed:"
echo "$CHANGED_FILES" | sed 's/^/ - /'
CHANGES_FOUND=true
if [ -z "$CHANGED_DIRS" ]; then
CHANGED_DIRS="$DIR"
else
CHANGED_DIRS="$CHANGED_DIRS,$DIR"
fi
else
echo "❌ No changes in: $DIR"
fi
else
echo "⚠️ Directory not found: $DIR"
fi
done
# Set outputs
if [ "$CHANGES_FOUND" = true ]; then
echo "changes-detected=true" >> $GITHUB_OUTPUT
echo "changed-directories=$CHANGED_DIRS" >> $GITHUB_OUTPUT
echo ""
echo "🎯 RESULT: Changes detected in monitored directories"
else
echo "changes-detected=false" >> $GITHUB_OUTPUT
echo "changed-directories=" >> $GITHUB_OUTPUT
echo ""
echo "🎯 RESULT: No changes in monitored directories"
fi
- name: Trigger smoke tests for release
if: steps.check-changes.outputs.changed-directories == 'release'
run: |
echo "🔥 Triggering smoke tests for release preparation..."
gh workflow run smoke-test.yml
echo "✅ Smoke tests triggered successfully"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run MySQL protocol tests (with management API)
if: steps.check-changes.outputs.changes-detected == 'true'
run: |
pytest -v --cov=singlestoredb --pyargs singlestoredb.tests
env:
COVERAGE_FILE: "coverage-mysql.cov"
SINGLESTOREDB_URL: "root:root@127.0.0.1:3307"
SINGLESTOREDB_PURE_PYTHON: 0
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
- name: Run MySQL protocol tests (without management API)
if: steps.check-changes.outputs.changes-detected == 'false'
run: |
pytest -v -m 'not management' --cov=singlestoredb --pyargs singlestoredb.tests
env:
COVERAGE_FILE: "coverage-mysql.cov"
SINGLESTOREDB_URL: "root:root@127.0.0.1:3307"
SINGLESTOREDB_PURE_PYTHON: 0
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
- name: Run MySQL protocol tests (pure Python)
run: |
pytest -v -m 'not management' --cov=singlestoredb --pyargs singlestoredb.tests
env:
COVERAGE_FILE: "coverage-mysql-py.cov"
SINGLESTOREDB_URL: "root:root@127.0.0.1:3307"
SINGLESTOREDB_PURE_PYTHON: 1
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
- name: Run HTTP protocol tests
run: |
pytest -v -m 'not management' --cov=singlestoredb --pyargs singlestoredb.tests
env:
COVERAGE_FILE: "coverage-http.cov"
SINGLESTOREDB_URL: "http://root:root@127.0.0.1:9081"
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}
SINGLESTOREDB_MANAGEMENT_TOKEN: ${{ secrets.CLUSTER_API_KEY }}
# Can not change databases using HTTP API. The URL below will be
# used to create the database and the generated database name will
# be applied to the above URL.
SINGLESTOREDB_INIT_DB_URL: "root:root@127.0.0.1:3307"
SINGLESTOREDB_FUSION_ENABLE_HIDDEN: "1"
- name: Generate report
run: |
coverage combine coverage-mysql.cov coverage-http.cov coverage-mysql-py.cov
coverage report
coverage xml
coverage html