Skip to content

Merge pull request #7 from KidsPOSProject/kids-server-setup-ai #4

Merge pull request #7 from KidsPOSProject/kids-server-setup-ai

Merge pull request #7 from KidsPOSProject/kids-server-setup-ai #4

Workflow file for this run

name: Build and Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Test with Gradle
run: ./gradlew test
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: build/test-results/**/*.xml
optimize-test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run optimization tests
run: ./gradlew testOptimization
- name: Create SQLite test database
run: |
apt-get update && apt-get install -y sqlite3
sqlite3 test.db "CREATE TABLE item (id INTEGER PRIMARY KEY, barcode TEXT, name TEXT, price INTEGER);
CREATE TABLE sale (id INTEGER PRIMARY KEY, storeId INTEGER, staffId INTEGER, quantity INTEGER, amount INTEGER, deposit INTEGER, createdAt TEXT);
CREATE TABLE sale_detail (id INTEGER PRIMARY KEY, saleId INTEGER, itemId INTEGER, price INTEGER, quantity INTEGER);
INSERT INTO item VALUES (1, 'test-barcode', 'Test Item', 100);
INSERT INTO item VALUES (2, 'test-barcode-2', 'Test Item 2', 200);"
- name: Test database optimization
run: |
echo "Running SQLite optimization test..."
sqlite3 test.db "CREATE INDEX idx_item_barcode ON item(barcode);
ANALYZE;
EXPLAIN QUERY PLAN SELECT * FROM item WHERE barcode = 'test-barcode';" > optimization_result.txt
cat optimization_result.txt
if ! grep -q "SEARCH TABLE item USING INDEX idx_item_barcode" optimization_result.txt; then
echo "Optimization test failed: Index not used in query plan"
exit 1
fi