Skip to content

Commit 9384574

Browse files
authored
test: add GitHub action for unit test (#24)
1 parent ef16be5 commit 9384574

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request_target:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
name: Test
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
20+
with:
21+
enable-cache: true
22+
- name: Install dependencies
23+
run: uv sync --all-extras --dev
24+
- name: Run Lint
25+
run: uv tool run ruff check
26+
- name: Run Format
27+
run: uv tool run ruff format
28+
- name: Run Test
29+
run: uv run pytest tests
30+

examples/text2sql/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ class QuestionSQLResponse(BaseModel):
6767
table_definitions = []
6868
current_database = db._db_engine.url.database
6969
for table_name in db.table_names():
70-
table_definitions.append(
71-
db.query(f"SHOW CREATE TABLE `{table_name}`").to_rows()[0]
72-
)
70+
table_definitions.append(db.query(f"SHOW CREATE TABLE `{table_name}`").to_rows()[0])
7371

7472

7573
def on_submit():
@@ -98,7 +96,7 @@ def on_submit():
9896
)
9997
st.session_state.past.append(user_input)
10098

101-
if 'insert' in response.sql.lower() or 'update' in response.sql.lower():
99+
if "insert" in response.sql.lower() or "update" in response.sql.lower():
102100
st.error(
103101
"The generated SQL is not a SELECT statement, please check it carefully before running it."
104102
)

0 commit comments

Comments
 (0)