From 4166778a33792174322e7e7a0499312384164ae6 Mon Sep 17 00:00:00 2001 From: Derek Anderson Date: Thu, 26 Jun 2025 20:27:22 -0500 Subject: [PATCH] update workflow Signed-off-by: Derek Anderson --- .github/workflows/ci-cd.yml | 53 ++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b12793c..46dfc54 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -42,8 +42,12 @@ jobs: - name: Install SQLite (Windows) if: matrix.os == 'windows-latest' run: | - choco install sqlite - refreshenv + choco install sqlite --no-progress + # Refresh environment and add SQLite to PATH + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + # Add SQLite to PATH for subsequent steps + echo "C:\ProgramData\chocolatey\lib\SQLite\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + shell: powershell - name: Install dependencies run: npm ci @@ -56,9 +60,15 @@ jobs: # Test CLI help node bin/cli.js help - # Create test database + # Create test database with cross-platform commands mkdir -p test-ci - sqlite3 test-ci/test.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO users (name) VALUES ('Test User');" + + # Create test database + if [ "${{ matrix.os }}" = "windows-latest" ]; then + sqlite3.exe test-ci/test.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO users (name) VALUES ('Test User');" + else + sqlite3 test-ci/test.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO users (name) VALUES ('Test User');" + fi # Test backup creation node bin/cli.js create test-ci/test.db --backup-dir test-ci/backups @@ -67,8 +77,10 @@ jobs: node bin/cli.js list test-ci/test.db --backup-dir test-ci/backups # Test backup verification - BACKUP_FILE=$(ls test-ci/backups/*.db | head -1) - node bin/cli.js verify "$BACKUP_FILE" + BACKUP_FILE=$(find test-ci/backups -name "*.db" | head -1) + if [ -n "$BACKUP_FILE" ]; then + node bin/cli.js verify "$BACKUP_FILE" + fi # Cleanup rm -rf test-ci @@ -78,10 +90,33 @@ jobs: run: | # Create sample database for examples mkdir -p data - sqlite3 data/app.db "CREATE TABLE sample (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO sample (name) VALUES ('Sample Data');" - # Run examples (but skip the interactive parts) - timeout 30s node examples/basic-usage.js || true + # Create test database + if [ "${{ matrix.os }}" = "windows-latest" ]; then + sqlite3.exe data/app.db "CREATE TABLE sample (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO sample (name) VALUES ('Sample Data');" + else + sqlite3 data/app.db "CREATE TABLE sample (id INTEGER PRIMARY KEY, name TEXT); INSERT INTO sample (name) VALUES ('Sample Data');" + fi + + # Run examples with timeout (cross-platform) + if [ "${{ matrix.os }}" = "windows-latest" ]; then + # Windows approach - run with a simple timeout mechanism + node -e " + const { spawn } = require('child_process'); + const child = spawn('node', ['examples/basic-usage.js'], { stdio: 'inherit' }); + const timeout = setTimeout(() => { + console.log('Example timeout reached, terminating...'); + child.kill(); + }, 30000); + child.on('exit', (code) => { + clearTimeout(timeout); + console.log('Example finished with code:', code); + process.exit(0); + }); + " || true + else + timeout 30s node examples/basic-usage.js || true + fi # Cleanup rm -rf data