Skip to content

attempt to fix npm publish #55

attempt to fix npm publish

attempt to fix npm publish #55

name: compatibility.yaml
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 ${{ matrix.os }}
environment: e2e-${{ matrix.os }}
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 linux distro ${{ matrix.distro }}
environment: e2e-linux-distros
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
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
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"
'