Skip to content

Commit

Permalink
Merge branch 'main' into perf/remove-implicit-ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
janpio authored Nov 1, 2023
2 parents 290d2c4 + 82dc77d commit 40d6538
Show file tree
Hide file tree
Showing 302 changed files with 9,157 additions and 6,614 deletions.
46 changes: 43 additions & 3 deletions .buildkite/engineer
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
#!/usr/bin/env bash

set -e

if [[ -z "$2" ]]; then
printf "Error: the name of the pipeline must be provided.\nExample: './engineer pipeline test'" 1>&2
exit 1
else
echo "We are in the $2 pipeline."
fi

# Checks what's the diff with the previous commit
# This is used to detect if the previous commit was empty
GIT_DIFF=$(git diff --name-only HEAD HEAD~1 -- .)

# Checks what's the diff with the previous commit,
# excluding some paths that do not need a run,
# because they do not affect tests running in Buildkite.
GIT_DIFF_WITH_IGNORED_PATHS=$(git diff --name-only HEAD HEAD~1 -- . ':!.github' ':!query-engine/driver-adapters/js' ':!query-engine/query-engine-wasm' ':!renovate.json' ':!*.md' ':!LICENSE' ':!CODEOWNERS';)

# $2 is either "test" or "build", depending on the pipeline
# Example: ./.buildkite/engineer pipeline test
# We only want to check for changes and skip in the test pipeline.
if [[ "$2" == "test" ]]; then
# If GIT_DIFF is empty then the previous commit was empty
# We assume it's intended and we continue with the run
# Example use: to get a new engine hash built with identical code
if [ -z "${GIT_DIFF}" ]; then
echo "The previous commit is empty, this run will continue..."
else
# Checking if GIT_DIFF_WITH_IGNORED_PATHS is empty
# If it's empty then it's most likely that there are changes but they are in ignored paths.
# So we do not start Buildkite
if [ -z "${GIT_DIFF_WITH_IGNORED_PATHS}" ]; then
echo "No changes found for the previous commit in paths that are not ignored, this run will now be skipped."
exit 0
else
# Note that printf works better for displaying line returns in CI
printf "Changes found for the previous commit in paths that are not ignored: \n\n%s\n\nThis run will continue...\n" "${GIT_DIFF_WITH_IGNORED_PATHS}"
fi
fi
fi

# Check OS
if [[ "$OSTYPE" == "linux-gnu" ]]; then
OS=linux-amzn
elif [[ "$OSTYPE" == "darwin"* ]]; then
Expand All @@ -12,8 +54,7 @@ fi
# Check if the system has engineer installed, if not, use a local copy.
if ! type "engineer" &> /dev/null; then
# Setup Prisma engine build & test tool (engineer).
set -e
curl --fail -sSL "https://prisma-engineer.s3-eu-west-1.amazonaws.com/1.59/latest/$OS/engineer.gz" --output engineer.gz
curl --fail -sSL "https://prisma-engineer.s3-eu-west-1.amazonaws.com/1.60/latest/$OS/engineer.gz" --output engineer.gz
gzip -d engineer.gz
chmod +x engineer

Expand All @@ -22,6 +63,5 @@ if ! type "engineer" &> /dev/null; then
rm -rf ./engineer
else
# Already installed on the system
set -e
engineer "$@"
fi
11 changes: 10 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export QE_LOG_LEVEL=debug # Set it to "trace" to enable query-graph debugging lo
# export PRISMA_RENDER_DOT_FILE=1 # Uncomment to enable rendering a dot file of the Query Graph from an executed query.
# export FMT_SQL=1 # Uncomment it to enable logging formatted SQL queries

### Uncomment to run driver adapters tests. See query-engine-driver-adapters.yml workflow for how tests run in CI.
# export EXTERNAL_TEST_EXECUTOR="$(pwd)/query-engine/driver-adapters/js/connector-test-kit-executor/script/start_node.sh"
# export DRIVER_ADAPTER=pg # Set to pg, neon or planetscale
# export PRISMA_DISABLE_QUAINT_EXECUTORS=1 # Disable quaint executors for driver adapters
# export DRIVER_ADAPTER_URL_OVERRIDE ="postgres://USER:PASSWORD@DATABASExxxx" # Override the database url for the driver adapter tests

# Mongo image requires additional wait time on arm arch for some reason.
if uname -a | grep -q 'arm64'; then
export INIT_WAIT_SEC="10"
Expand All @@ -36,7 +42,9 @@ fi

# Set up env vars and build inputs from flake.nix automatically for nix users.
# If you don't use nix, you can safely ignore this.
if command -v nix &> /dev/null
# You can set the DISABLE_NIX environment variable if you're in an environment
# where nix is pre-installed (e.g. gitpod) but you don't want to use it.
if command -v nix &> /dev/null && [ -z ${DISABLE_NIX+x} ]
then
if nix flake metadata > /dev/null; then
if type nix_direnv_watch_file &> /dev/null; then
Expand All @@ -48,5 +56,6 @@ fi

# Source the gitignored .envrc.local if it exists.
if test -f .envrc.local; then
watch_file .envrc.local
source .envrc.local
fi
4 changes: 3 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- main
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/benchmark.yml'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
Expand All @@ -17,7 +19,7 @@ concurrency:

jobs:
benchmark:
name: "Run benchmarks on Linux"
name: 'Run benchmarks on Linux'

runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ on:
- main
pull_request:
paths-ignore:
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"
- '.github/**'
- '!.github/workflows/build-wasm.yml'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
- 'CODEOWNERS'
- 'renovate.json'

jobs:
build:
name: "prisma-schema-wasm build ${{ github.event.ref }} for commit ${{ github.event.inputs.commit }}"
name: 'prisma-schema-wasm build ${{ github.event.ref }} for commit ${{ github.event.inputs.commit }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: "Release binary compilation test"
name: 'Release binary compilation test'
on:
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/compilation.yml'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
Expand All @@ -14,25 +16,25 @@ concurrency:

jobs:
test-crate-compilation:
name: "Compile top level crates on Linux"
name: 'Compile top level crates on Linux'
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- run: "cargo clean && cargo build --release -p schema-engine-cli"
name: "Compile Migration Engine"
- run: 'cargo clean && cargo build --release -p schema-engine-cli'
name: 'Compile Migration Engine'

- run: "cargo clean && cargo build --release -p prisma-fmt"
name: "Compile prisma-fmt"
- run: 'cargo clean && cargo build --release -p prisma-fmt'
name: 'Compile prisma-fmt'

- run: "cargo clean && cargo build --release -p query-engine"
name: "Compile Query Engine Binary"
- run: 'cargo clean && cargo build --release -p query-engine'
name: 'Compile Query Engine Binary'

- run: "cargo clean && cargo build --release -p query-engine-node-api"
name: "Compile Query Engine Library"
- run: 'cargo clean && cargo build --release -p query-engine-node-api'
name: 'Compile Query Engine Library'

- name: "Check that Cargo.lock did not change"
run: "git diff --exit-code"
- name: 'Check that Cargo.lock did not change'
run: 'git diff --exit-code'
4 changes: 3 additions & 1 deletion .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- main
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/formatting.yml'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
Expand All @@ -19,7 +21,7 @@ jobs:
clippy:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Dwarnings"
RUSTFLAGS: '-Dwarnings'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand Down
35 changes: 14 additions & 21 deletions .github/workflows/publish-prisma-schema-wasm.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build and publish @prisma/prisma-schema-wasm
run-name: npm - release @prisma/prisma-schema-wasm@${{ github.event.inputs.enginesWrapperVersion }} from ${{ github.event.inputs.enginesHash }} on ${{ github.event.inputs.npmDistTag }}

concurrency: build-prisma-schema-wasm
concurrency: publish-prisma-schema-wasm

on:
# usually triggered via GH Actions Workflow in prisma/engines-wrapper repo
Expand All @@ -12,7 +13,7 @@ on:
required: true
npmDistTag:
required: true
default: "latest"
default: 'latest'

jobs:
build:
Expand All @@ -21,7 +22,7 @@ jobs:
steps:
- name: Print input
env:
THE_INPUT: "${{ toJson(github.event.inputs) }}"
THE_INPUT: '${{ toJson(github.event.inputs) }}'
run: |
echo $THE_INPUT
Expand All @@ -30,41 +31,33 @@ jobs:
ref: ${{ github.event.inputs.enginesHash }}
- uses: cachix/install-nix-action@v23

#
# Build
#

- run: nix build .#prisma-schema-wasm

#
# Publish
#
- name: Build
run: nix build .#prisma-schema-wasm

- uses: actions/setup-node@v3
with:
node-version: "14.x"
node-version: '20.x'

- name: Set up NPM token
# This is needed to be done manually because of `PACKAGE_DIR` used later
- name: Set up NPM token for publishing later
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- run: |
- name: Update version in package.json & Publish @prisma/prisma-schema-wasm
run: |
# Update version in package.json and return directory for later usage
PACKAGE_DIR=$( nix run .#renderPrismaSchemaWasmPackage ${{ github.event.inputs.enginesWrapperVersion }})
npm publish "$PACKAGE_DIR" --access public --tag ${{ github.event.inputs.npmDistTag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
#
# Failure handlers
#

- name: Set current job url in SLACK_FOOTER env var
if: ${{ failure() }}
run: echo "SLACK_FOOTER=<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Click here to go to the job logs>" >> $GITHUB_ENV

- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/[email protected]
env:
SLACK_TITLE: "prisma-schema-wasm publishing failed :x:"
SLACK_COLOR: "#FF0000"
SLACK_TITLE: 'prisma-schema-wasm publishing failed :x:'
SLACK_COLOR: '#FF0000'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WASM_FAILING }}
9 changes: 4 additions & 5 deletions .github/workflows/quaint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ jobs:
features:
- "--lib --features=all"
- "--lib --no-default-features --features=sqlite"
- "--lib --no-default-features --features=sqlite --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal"
- "--lib --no-default-features --features=sqlite --features=pooled"
- "--lib --no-default-features --features=postgresql"
- "--lib --no-default-features --features=postgresql --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal"
- "--lib --no-default-features --features=postgresql --features=pooled"
- "--lib --no-default-features --features=mysql"
- "--lib --no-default-features --features=mysql --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal"
- "--lib --no-default-features --features=mysql --features=pooled"
- "--lib --no-default-features --features=mssql"
- "--lib --no-default-features --features=mssql --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal"
- "--doc --features=all"
- "--lib --no-default-features --features=mssql --features=pooled"
env:
TEST_MYSQL: "mysql://root:prisma@localhost:3306/prisma"
TEST_MYSQL8: "mysql://root:prisma@localhost:3307/prisma"
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/query-engine-black-box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- main
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/query-engine-black-box.yml'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
Expand All @@ -17,27 +19,27 @@ concurrency:

jobs:
rust-tests:
name: "Test query-engine as a black-box"
name: 'Test query-engine as a black-box'

strategy:
fail-fast: false
matrix:
database:
- name: "postgres15"
- name: 'postgres15'
single_threaded: false
connector: "postgres"
version: "15"
connector: 'postgres'
version: '15'

env:
LOG_LEVEL: "info"
LOG_QUERIES: "y"
RUST_LOG_FORMAT: "devel"
RUST_BACKTRACE: "1"
CLICOLOR_FORCE: "1"
CLOSED_TX_CLEANUP: "2"
SIMPLE_TEST_MODE: "1"
QUERY_BATCH_SIZE: "10"
TEST_RUNNER: "direct"
LOG_LEVEL: 'info'
LOG_QUERIES: 'y'
RUST_LOG_FORMAT: 'devel'
RUST_BACKTRACE: '1'
CLICOLOR_FORCE: '1'
CLOSED_TX_CLEANUP: '2'
SIMPLE_TEST_MODE: '1'
QUERY_BATCH_SIZE: '10'
TEST_RUNNER: 'direct'
TEST_CONNECTOR: ${{ matrix.database.connector }}
TEST_CONNECTOR_VERSION: ${{ matrix.database.version }}

Expand All @@ -46,21 +48,25 @@ jobs:
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
continue-on-error: true
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
if: "${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}"
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: "Start ${{ matrix.database.name }} (${{ matrix.engine_protocol }})"
- name: 'Start ${{ matrix.database.name }} (${{ matrix.engine_protocol }})'
run: make start-${{ matrix.database.name }}

- uses: dtolnay/rust-toolchain@stable

- run: export WORKSPACE_ROOT=$(pwd) && cargo build --package query-engine
- run: export WORKSPACE_ROOT=$(pwd) && cargo build --package query-engine
env:
CLICOLOR_FORCE: 1

- run: export WORKSPACE_ROOT=$(pwd) && cargo test --package black-box-tests -- --test-threads=1
- run: export WORKSPACE_ROOT=$(pwd) && cargo test --package black-box-tests -- --test-threads=1
env:
CLICOLOR_FORCE: 1
Loading

0 comments on commit 40d6538

Please sign in to comment.