fix migration safety and Prisma compatibility #133
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.1 | |
| - run: bun install --frozen-lockfile | |
| - run: bun run format:check | |
| - run: bun run lint | |
| - run: bunx tsc --noEmit | |
| - run: bun run build | |
| unit-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.1 | |
| - run: bun install --frozen-lockfile | |
| - run: bun run test:coverage | |
| - uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage/lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| package-compatibility: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| prisma-version: ["5.22.0", "6.19.2", "latest"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.19.0 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.1 | |
| - run: bun install --frozen-lockfile | |
| - run: bun run build-lib | |
| - name: Install packed package | |
| run: | | |
| expected_version=$(node -p "require('./package.json').version") | |
| package_file=$(npm pack --pack-destination "$RUNNER_TEMP") | |
| mkdir "$RUNNER_TEMP/consumer" | |
| cd "$RUNNER_TEMP/consumer" | |
| npm init -y | |
| npm install "$RUNNER_TEMP/$package_file" \ | |
| "prisma@${{ matrix.prisma-version }}" \ | |
| "@prisma/client@${{ matrix.prisma-version }}" | |
| installed_version=$(node -p \ | |
| "require('prisma/package.json').version") | |
| echo "PRISMA_VERSION=$installed_version" >> "$GITHUB_ENV" | |
| node node_modules/prisma-migrations/dist/cli.js \ | |
| --version | grep "$expected_version" | |
| node --input-type=module -e \ | |
| "import('prisma-migrations').then((value) => \ | |
| console.log(typeof value.Migrations))" | |
| - name: Verify Prisma 7 configuration guard | |
| run: | | |
| if [[ "$PRISMA_VERSION" != 7.* ]]; then | |
| exit 0 | |
| fi | |
| cd "$RUNNER_TEMP/consumer" | |
| if node node_modules/prisma-migrations/dist/cli.js status \ | |
| >output.log 2>&1; then | |
| exit 1 | |
| fi | |
| grep "Prisma 7 requires a generated client factory" output.log | |
| provider-compatibility: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| prisma-version: ["5.22.0", "6.19.2", "latest"] | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: test | |
| POSTGRES_PASSWORD: test | |
| POSTGRES_DB: db | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U test" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| mysql: | |
| image: mysql:8.4 | |
| env: | |
| MYSQL_ROOT_PASSWORD: test | |
| MYSQL_DATABASE: db | |
| MYSQL_USER: test | |
| MYSQL_PASSWORD: test | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd "mysqladmin ping -h localhost -ptest" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.19.0 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.1 | |
| - run: bun install --frozen-lockfile | |
| - run: bun run build-lib | |
| - name: Prepare compatibility project | |
| run: | | |
| package_file=$(npm pack --silent --pack-destination "$RUNNER_TEMP") | |
| consumer_dir="$RUNNER_TEMP/provider-consumer" | |
| mkdir "$consumer_dir" | |
| cp tests/e2e/provider-client.ts "$consumer_dir" | |
| cp tests/e2e/provider-compatibility.spec.ts "$consumer_dir" | |
| cp tests/e2e/schema.*.prisma "$consumer_dir" | |
| cd "$consumer_dir" | |
| npm init -y | |
| version="${{ matrix.prisma-version }}" | |
| dependencies=( | |
| "$RUNNER_TEMP/$package_file" | |
| "prisma@$version" | |
| "@prisma/client@$version" | |
| ) | |
| npm install "${dependencies[@]}" | |
| installed_version=$(node -p \ | |
| "require('prisma/package.json').version") | |
| if [[ "$installed_version" == 7.* ]]; then | |
| adapter_dependencies=( | |
| "@prisma/adapter-pg@$installed_version" | |
| "@prisma/adapter-mariadb@$installed_version" | |
| "@prisma/adapter-libsql@$installed_version" | |
| "pg" | |
| ) | |
| npm install "${adapter_dependencies[@]}" | |
| fi | |
| echo "PRISMA_VERSION=$installed_version" >> "$GITHUB_ENV" | |
| - name: Run provider tests | |
| run: | | |
| cd "$RUNNER_TEMP/provider-consumer" | |
| version="$PRISMA_VERSION" | |
| for provider in postgresql mysql sqlite; do | |
| case "$provider" in | |
| postgresql) | |
| database_url="postgresql://test:test@localhost:5432/db" | |
| ;; | |
| mysql) | |
| database_url="mysql://test:test@localhost:3306/db" | |
| ;; | |
| sqlite) | |
| database_url="file:$RUNNER_TEMP/provider-$version.db" | |
| ;; | |
| esac | |
| schema="schema.$provider.prisma" | |
| if [[ "$version" == 7.* ]]; then | |
| schema="schema.v7.$provider.prisma" | |
| fi | |
| cp "$schema" schema.prisma | |
| DATABASE_URL="$database_url" npx prisma generate \ | |
| --schema schema.prisma | |
| DATABASE_URL="$database_url" \ | |
| PRISMA_PROVIDER="$provider" \ | |
| PRISMA_VERSION="$version" \ | |
| bun test provider-compatibility.spec.ts --timeout 120000 | |
| done | |
| e2e-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.19.0 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.1 | |
| - run: bun install --frozen-lockfile | |
| - run: bun run build-lib | |
| - name: Install Prisma 6 for legacy project fixtures | |
| run: >- | |
| bun add --no-save --exact | |
| prisma@6.19.2 @prisma/client@6.19.2 | |
| - name: Generate PostgreSQL client | |
| env: | |
| DATABASE_URL: >- | |
| postgresql://test:test@localhost:5434/prisma_migrations_test | |
| run: bunx prisma generate --schema tests/e2e/schema.prisma | |
| - name: Start PostgreSQL containers | |
| run: | | |
| docker compose -f tests/e2e/docker-compose.yml up -d \ | |
| postgres postgres-cli postgres-bun \ | |
| postgres-codelab-new postgres-codelab-migrate | |
| - name: Wait for PostgreSQL containers | |
| run: | | |
| for port in 5434 5435 5436 5437 5438; do | |
| for attempt in {1..60}; do | |
| if pg_isready -h localhost -p "$port" -U test; then | |
| break | |
| fi | |
| if [ "$attempt" -eq 60 ]; then | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| done | |
| - name: Run end-to-end tests | |
| run: | | |
| bun test tests/e2e/cli-commands.spec.ts --timeout 120000 | |
| bun test tests/e2e/bun-only.spec.ts --timeout 120000 | |
| bun test tests/e2e/codelab-new-project.spec.ts --timeout 120000 | |
| bun test tests/e2e/codelab-migrate-existing.spec.ts --timeout 120000 | |
| bun test tests/e2e/prisma-wrapper-commands.spec.ts --timeout 120000 | |
| bun test tests/e2e/monorepo-commands.spec.ts --timeout 120000 | |
| bun test tests/e2e/safety.spec.ts --timeout 120000 | |
| - name: Stop containers | |
| if: always() | |
| run: docker compose -f tests/e2e/docker-compose.yml down |