Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge-dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dependabot auto-merge
name: auto-merge
on: pull_request

permissions:
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/clippy.yaml

This file was deleted.

269 changes: 269 additions & 0 deletions .github/workflows/compatibility.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
name: Compatibility tests
Comment thread
JasonShin marked this conversation as resolved.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches: [ main ]
workflow_dispatch: { }
schedule:
- cron: "0 0 * * *" # daily at midnight UTC
workflow_run:
workflows: ["Release"]
types:
- completed

jobs:
e2e:
name: E2E tests with Node.js npm package
runs-on: ${{ matrix.os }}
# Skip this job for version bump commits (binary won't exist yet)
if: "!contains(github.event.head_commit.message, 'Release')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
db:
- mysql: 8
- mysql: 5.7
- mysql: 5.6
- postgres: 16
- postgres: 15
- postgres: 14
- postgres: 13
- postgres: 12
# Only run database tests on ubuntu-latest to save CI time
exclude:
- os: macos-latest
db: { mysql: 5.7 }
- os: macos-latest
db: { mysql: 5.6 }
- os: macos-latest
db: { postgres: 15 }
- os: macos-latest
db: { postgres: 14 }
- os: macos-latest
db: { postgres: 13 }
- os: macos-latest
db: { postgres: 12 }
- os: windows-latest
db: { mysql: 5.7 }
- os: windows-latest
db: { mysql: 5.6 }
- os: windows-latest
db: { postgres: 15 }
- os: windows-latest
db: { postgres: 14 }
- os: windows-latest
db: { postgres: 13 }
- os: windows-latest
db: { postgres: 12 }

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Build docker-compose services for integration tests (Linux only)
if: runner.os == 'Linux'
run: docker compose -f docker-compose.yml up -d
env:
MYSQL_VERSION: ${{ matrix.db.mysql }}
PG_VERSION: ${{ matrix.db.postgres }}
MYSQL_MIGRATION_FILE: "${{ matrix.db.mysql == '5.6' && 'mysql_migration_5_6.sql' || 'mysql_migration.sql' }}"

- name: Wait for databases to be ready (Linux only)
if: runner.os == 'Linux'
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '10'

- name: Check docker-compose services (Linux only)
if: runner.os == 'Linux'
run: docker ps -a

- name: Install sqlx-ts from npm
working-directory: ./node
run: npm install

- name: Verify sqlx-ts installation
working-directory: ./node
shell: bash
run: |
./sqlx-ts --version
./sqlx-ts --help

- name: Create test directory
shell: bash
run: mkdir -p tests/staging

- name: Add failure.ts test file (Linux only)
if: runner.os == 'Linux'
shell: bash
run: |
cat << 'EOF' > tests/staging/failure.ts
import { sql } from 'sqlx-ts'

const selectSql4 = sql`
SELECT itemz.*
FROM items;
`
EOF

- name: Run failure test (Linux only)
if: runner.os == 'Linux'
working-directory: ./node
shell: bash
run: |
set +e
./sqlx-ts --config=../.sqlxrc.sample.json ../tests/staging
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo "Expected failure, but command succeeded."
exit 1
fi
echo "Command failed as expected with exit code $EXIT_CODE."

- name: Remove failure test file
if: runner.os == 'Linux'
shell: bash
run: rm -f tests/staging/failure.ts

- name: Add happy.ts test file (Linux only)
if: runner.os == 'Linux'
shell: bash
run: |
cat << 'EOF' > tests/staging/happy.ts
import { sql } from 'sqlx-ts'

const selectSql4 = sql`
SELECT items.*
FROM items;
`
EOF

- name: Run happy test (Linux only)
if: runner.os == 'Linux'
working-directory: ./node
shell: bash
run: ./sqlx-ts --config=../.sqlxrc.sample.json ../tests/staging

- name: Test sqlx-ts on ${{ matrix.os }} (no database)
if: runner.os != 'Linux'
working-directory: ./node
shell: bash
run: |
echo "✅ sqlx-ts successfully installed and runs on ${{ matrix.os }}"
./sqlx-ts --version
./sqlx-ts --help


e2e-linux-distros:
name: E2E npm package on Linux distros with databases
runs-on: ubuntu-latest
# Skip this job for version bump commits (binary won't exist yet)
if: "!contains(github.event.head_commit.message, 'Release')"
strategy:
fail-fast: false
matrix:
distro:
- ubuntu:20.04
- ubuntu:22.04
- ubuntu:24.04
- debian:11
- debian:12
- alpine:3.18
- alpine:3.19
- fedora:38
- fedora:39
- archlinux:latest
db:
- mysql: 8
- postgres: 16
# Test fewer combinations to save CI time
exclude:
- distro: ubuntu:20.04
db: { postgres: 16 }
- distro: ubuntu:22.04
db: { postgres: 16 }
- distro: debian:11
db: { postgres: 16 }
- distro: debian:12
db: { mysql: 8 }
- distro: alpine:3.18
db: { postgres: 16 }
- distro: alpine:3.19
db: { mysql: 8 }
- distro: fedora:38
db: { postgres: 16 }
- distro: fedora:39
db: { mysql: 8 }

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Build docker-compose services
run: docker compose -f docker-compose.yml up -d
env:
MYSQL_VERSION: ${{ matrix.db.mysql }}
PG_VERSION: ${{ matrix.db.postgres }}
MYSQL_MIGRATION_FILE: "${{ matrix.db.mysql == '5.6' && 'mysql_migration_5_6.sql' || 'mysql_migration.sql' }}"

- name: Wait for databases to be ready
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '10'

- name: Create test file
run: |
mkdir -p tests/staging
cat << 'TESTEOF' > tests/staging/distro-test.ts
import { sql } from 'sqlx-ts'

const selectSql = sql`
SELECT items.*
FROM items;
`
TESTEOF

- name: Test npm install and run in ${{ matrix.distro }} container
run: |
docker run --rm \
--network host \
-v $(pwd):/workspace \
-w /workspace \
${{ matrix.distro }} sh -c '
# Install Node.js based on distro
if command -v apk > /dev/null; then
# Alpine
Comment on lines +244 to +245
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The distro detection logic uses command -v apk which checks for the Alpine package manager, but this doesn't guarantee the system is Alpine Linux. A more robust approach would be to check /etc/os-release or use multiple package manager checks in a specific order. However, for the Alpine distros in the matrix (alpine:3.18, alpine:3.19), this should work correctly.

Suggested change
if command -v apk > /dev/null; then
# Alpine
if [ -f /etc/os-release ] && grep -q '^ID=alpine' /etc/os-release; then
# Alpine (detected via /etc/os-release)

Copilot uses AI. Check for mistakes.
apk add --no-cache nodejs npm bash
elif command -v apt-get > /dev/null; then
# Debian/Ubuntu
apt-get update && apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
elif command -v dnf > /dev/null; then
# Fedora
dnf install -y nodejs npm
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Arch Linux distro (archlinux:latest) in the matrix is not handled in the package manager detection logic. Add an elif branch to handle pacman for Arch Linux installations.

Suggested change
dnf install -y nodejs npm
dnf install -y nodejs npm
elif command -v pacman > /dev/null; then
# Arch Linux
pacman -Sy --noconfirm nodejs npm bash

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For Fedora 38 and 39, the package manager should be dnf, but consider that Fedora 39 and later may have different Node.js versions in their repositories. You might want to use a consistent Node.js version across all distros by using NodeSource or nvm instead of relying on distro-provided packages.

Suggested change
dnf install -y nodejs npm
dnf install -y curl
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
dnf install -y nodejs

Copilot uses AI. Check for mistakes.
fi

# Install sqlx-ts
cd node
npm install

# Verify installation
./sqlx-ts --version
./sqlx-ts --help

# Run integration test
./sqlx-ts --config=../.sqlxrc.sample.json ../tests/staging

echo "✅ sqlx-ts npm package works on ${{ matrix.distro }} with DB"
'
4 changes: 4 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: coverage

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
schedule:
- cron: '0 1 * * *'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy docs/install-script to gh-pages branch for public use
name: gh-pages
on:
push:
branches: [main]
Expand Down
Loading
Loading