Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shard integration tests, parallelise attw #4258

Merged
merged 21 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
300 changes: 257 additions & 43 deletions .github/workflows/release-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@ on:
pull_request: {}

jobs:
release:
test:
# only run on all pushes or pull requests from forks
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
package:
shard:
- gel
- planetscale
- singlestore-core
- singlestore-proxy
- singlestore-prefixed
- singlestore-custom
- neon-http
- neon-serverless
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-seed
- drizzle-typebox
- drizzle-valibot
- eslint-plugin-drizzle
- other
runs-on: ubuntu-20.04
permissions:
contents: read
id-token: write
services:
postgres-postgis:
image: postgis/postgis:16-3.4
Expand Down Expand Up @@ -76,6 +81,156 @@ jobs:
--health-retries 5
ports:
- 33306:3306
singlestore:
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
env:
ROOT_PASSWORD: singlestore
ports:
- 33307:3306
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20.19'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: latest
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Build Prisma client
working-directory: drizzle-orm
run: pnpm prisma generate --schema src/prisma/schema.prisma

- name: Build
run: pnpm build

- name: Run tests
env:
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55433/drizzle
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
# NEON_HTTP_CONNECTION_STRING: postgres://postgres:[email protected]:5432/postgres
NEON_HTTP_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
NEON_SERVERLESS_CONNECTION_STRING: postgres://postgres:postgres@localhost:5445/postgres
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
LIBSQL_URL: file:local.db
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}
SINGLESTORE_CONNECTION_STRING: singlestore://root:singlestore@localhost:33307/
working-directory: integration-tests
run: |
if [[ ${{ github.event_name }} != "push" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
export SKIP_EXTERNAL_DB_TESTS=1
fi

case ${{ matrix.shard }} in

gel)
if [[ -z "$SKIP_EXTERNAL_DB_TESTS" ]]; then
pnpm vitest run tests/gel
fi
;;

planetscale)
if [[ -z "$SKIP_EXTERNAL_DB_TESTS" ]]; then
pnpm vitest run \
tests/mysql/mysql-planetscale.test.ts \
tests/relational/mysql.planetscale-v1.test.ts \
tests/relational/mysql.planetscale.test.ts
fi
;;

singlestore-core)
pnpm vitest run tests/singlestore/singlestore.test.ts
;;

singlestore-proxy)
pnpm vitest run tests/singlestore/singlestore-proxy.test.ts
;;

singlestore-prefixed)
pnpm vitest run tests/singlestore/singlestore-prefixed.test.ts
;;

singlestore-custom)
pnpm vitest run tests/singlestore/singlestore-custom.test.ts
;;

neon-http)
if [[ -z "$SKIP_EXTERNAL_DB_TESTS" ]]; then
pnpm vitest run tests/pg/neon-http.test.ts tests/pg/neon-http-batch.test.ts
fi
;;

neon-serverless)
docker compose -f docker-neon.yml up -d
pnpm vitest run tests/pg/neon-serverless.test.ts
docker compose -f docker-neon.yml down
;;

drizzle-orm|drizzle-kit|drizzle-zod|drizzle-seed|drizzle-typebox|drizzle-valibot)
pnpm run test --filter ${{ matrix.shard }}
;;

other)
pnpm vitest run \
--exclude tests/gel \
--exclude tests/mysql/mysql-planetscale.test.ts \
--exclude tests/relational/mysql.planetscale-v1.test.ts \
--exclude tests/relational/mysql.planetscale.test.ts \
--exclude tests/singlestore/singlestore.test.ts \
--exclude tests/singlestore/singlestore-proxy.test.ts \
--exclude tests/singlestore/singlestore-prefixed.test.ts \
--exclude tests/singlestore/singlestore-custom.test.ts \
--exclude tests/pg/neon-http.test.ts \
--exclude tests/pg/neon-http-batch.test.ts \
--exclude tests/pg/neon-serverless.test.ts
;;

esac


attw:
# only run on all pushes or pull requests from forks
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
package:
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-seed
- drizzle-typebox
- drizzle-valibot
- eslint-plugin-drizzle
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -108,6 +263,9 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Install Bun
uses: oven-sh/setup-bun@v2

- name: Check preconditions
id: checks
shell: bash
Expand All @@ -130,57 +288,113 @@ jobs:
} >> $GITHUB_OUTPUT
fi

- name: Build Prisma client
working-directory: drizzle-orm
run: pnpm prisma generate --schema src/prisma/schema.prisma

- name: Build
if: steps.checks.outputs.has_new_release == 'true'
run: pnpm build

- name: Pack
if: steps.checks.outputs.has_new_release == 'true'
working-directory: ${{ matrix.package }}
run: npm run pack

- name: Run @arethetypeswrong/cli
if: steps.checks.outputs.has_new_release == 'true'
working-directory: ${{ matrix.package }}
run: bunx attw package.tgz

release:
# only run on all pushes or pull requests from forks
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
needs:
- test
- attw
strategy:
matrix:
package:
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-seed
- drizzle-typebox
- drizzle-valibot
- eslint-plugin-drizzle
runs-on: ubuntu-20.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '18.18'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: latest
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
(
cd drizzle-orm
pnpm prisma generate --schema src/prisma/schema.prisma
)
pnpm build
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT

- name: Run tests
if: steps.checks.outputs.has_new_release == 'true'
env:
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55433/drizzle
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
LIBSQL_URL: file:local.db
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Check preconditions
id: checks
shell: bash
working-directory: ${{ matrix.package }}
run: |
if [[ ${{ github.event_name }} != "push" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
export SKIP_EXTERNAL_DB_TESTS=1
fi
if [[ "${{ matrix.package }}" == "drizzle-orm" ]]; then
pnpm test --filter ${{ matrix.package }} --filter integration-tests
old_version="$(jq -r .version package.json)"
version="$old_version-$(git rev-parse --short HEAD)"
npm version $version
tag="${{ github.ref_name }}"
is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')"

if [[ "$is_version_published" == "true" ]]; then
echo "\`${{ matrix.package }}$version\` already published, adding tag \`$tag\`" >> $GITHUB_STEP_SUMMARY
npm dist-tag add ${{ matrix.package }}@$version $tag
else
pnpm test --filter ${{ matrix.package }}
{
echo "version=$version"
echo "tag=$tag"
echo "has_new_release=true"
} >> $GITHUB_OUTPUT
fi

- name: Pack
- name: Build Prisma client
working-directory: drizzle-orm
run: pnpm prisma generate --schema src/prisma/schema.prisma

- name: Build
if: steps.checks.outputs.has_new_release == 'true'
working-directory: ${{ matrix.package }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
run: |
npm run pack

- name: Run @arethetypeswrong/cli
run: pnpm build

- name: Pack
if: steps.checks.outputs.has_new_release == 'true'
working-directory: ${{ matrix.package }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
run: |
pnpm attw package.tgz
run: npm run pack

- name: Publish
if: github.event_name == 'push' && steps.checks.outputs.has_new_release == 'true'
Expand Down
3 changes: 3 additions & 0 deletions changelogs/drizzle-orm/0.40.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Updates to `neon-http` for `@neondatabase/[email protected]` - thanks @jawj

Starting from this version, drizzle-orm will be compatible with both `@neondatabase/serverless` <1.0 and >1.0
Loading
Loading