Skip to content

Commit

Permalink
Merge branch 'main' into qe-always-create-a-span-for-prisma-engine-re…
Browse files Browse the repository at this point in the history
…gardless-of-itx
  • Loading branch information
aqrln authored Jan 19, 2024
2 parents 1edac4a + ec17f10 commit e0314e8
Show file tree
Hide file tree
Showing 705 changed files with 21,005 additions and 15,121 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.66/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
88 changes: 88 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[store]
# The directory under the workspace root at which nextest-related files are
# written. Profile-specific storage is currently written to dir/<profile-name>.
dir = "target/nextest"

# This section defines the default nextest profile. Custom profiles are layered
# on top of the default profile.
[profile.default]
# "retries" defines the number of times a test should be retried. If set to a
# non-zero value, tests that succeed on a subsequent attempt will be marked as
# flaky. Can be overridden through the `--retries` option.
# Examples
# * retries = 3
# * retries = { backoff = "fixed", count = 2, delay = "1s" }
# * retries = { backoff = "exponential", count = 10, delay = "1s", jitter = true, max-delay = "10s" }
retries = { backoff = "fixed", count = 5, delay = "1s", jitter = true }

# The number of threads to run tests with. Supported values are either an integer or
# the string "num-cpus". Can be overridden through the `--test-threads` option.
test-threads = "num-cpus"

# The number of threads required for each test. This is generally used in overrides to
# mark certain tests as heavier than others. However, it can also be set as a global parameter.
threads-required = 1

# Show these test statuses in the output.
#
# The possible values this can take are:
# * none: no output
# * fail: show failed (including exec-failed) tests
# * retry: show flaky and retried tests
# * slow: show slow tests
# * pass: show passed tests
# * skip: show skipped tests (most useful for CI)
# * all: all of the above
#
# Each value includes all the values above it; for example, "slow" includes
# failed and retried tests.
#
# Can be overridden through the `--status-level` flag.
status-level = "all"

# Similar to status-level, show these test statuses at the end of the run.
final-status-level = "flaky"

# "failure-output" defines when standard output and standard error for failing tests are produced.
# Accepted values are
# * "immediate": output failures as soon as they happen
# * "final": output failures at the end of the test run
# * "immediate-final": output failures as soon as they happen and at the end of
# the test run; combination of "immediate" and "final"
# * "never": don't output failures at all
#
# For large test suites and CI it is generally useful to use "immediate-final".
#
# Can be overridden through the `--failure-output` option.
failure-output = "immediate-final"

# "success-output" controls production of standard output and standard error on success. This should
# generally be set to "never".
success-output = "never"

# Cancel the test run on the first failure. For CI runs, consider setting this
# to false.
fail-fast = false

# Treat a test that takes longer than the configured 'period' as slow, and print a message.
# See <https://nexte.st/book/slow-tests> for more information.
#
# Optional: specify the parameter 'terminate-after' with a non-zero integer,
# which will cause slow tests to be terminated after the specified number of
# periods have passed.
# Example: slow-timeout = { period = "60s", terminate-after = 2 }
slow-timeout = { period = "60s" }

# Treat a test as leaky if after the process is shut down, standard output and standard error
# aren't closed within this duration.
#
# This usually happens in case of a test that creates a child process and lets it inherit those
# handles, but doesn't clean the child process up (especially when it fails).
#
# See <https://nexte.st/book/leaky-tests> for more information.
leak-timeout = "100ms"

# This profile is activated if MIRI_SYSROOT is set.
[profile.default-miri]
# Miri tests take up a lot of memory, so only run 1 test at a time by default.
test-threads = 1
21 changes: 9 additions & 12 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export RUST_LOG=info
export PRISMA_DML_PATH=$(pwd)/dev_datamodel.prisma
export PRISMA2_BINARY_PATH="/usr/local/lib/node_modules/prisma2/"
export PRISMA_BINARY_PATH=$(pwd)/target/release/query-engine
export PRISMA_ENGINE_PROTOCOL="graphql"

### QE config vars, set to testing values ###
export SQLITE_MAX_VARIABLE_NUMBER=250000 # This must be in sync with the setting in the engineer build CLI
Expand All @@ -20,10 +19,10 @@ export SIMPLE_TEST_MODE="yes" # Reduces the amount of generated `relation_link_t
### QE specific logging vars ###
export QE_LOG_LEVEL=debug # Set it to "trace" to enable query-graph debugging logs
# 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
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 EXTERNAL_TEST_EXECUTOR="napi"
# 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
Expand All @@ -35,6 +34,12 @@ else
export INIT_WAIT_SEC="2"
fi

# Source the gitignored .envrc.local if it exists.
if test -f .envrc.local; then
watch_file .envrc.local
source .envrc.local
fi

# (Example env vars if you're not using the make commands, i.e. the config files, to set up query engine tests)
# export TEST_RUNNER="direct"
# export TEST_CONNECTOR="postgres"
Expand All @@ -47,15 +52,7 @@ fi
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
nix_direnv_watch_file nix/shell.nix nix/all-engines.nix nix/args.nix
fi
watch_file nix/shell.nix nix/all-engines.nix nix/args.nix
use flake
fi
fi

# Source the gitignored .envrc.local if it exists.
if test -f .envrc.local; then
watch_file .envrc.local
source .envrc.local
fi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build Engines for Apple Intel
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -39,7 +40,7 @@ jobs:
- run: |
cargo build --release -p query-engine -p query-engine-node-api -p schema-engine-cli -p prisma-fmt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: binaries
path: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build Engines for Apple Silicon
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -41,7 +42,7 @@ jobs:
- run: |
cargo build --target=aarch64-apple-darwin --release -p query-engine -p query-engine-node-api -p schema-engine-cli -p prisma-fmt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: binaries
path: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build Engines for Windows
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -36,7 +37,7 @@ jobs:

- run: cargo build --release

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: binaries
path: |
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/build-prisma-schema-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prisma Schema (WASM)
on:
push:
branches:
- main
pull_request:
paths-ignore:
- "!.github/workflows/build-prisma-schema-wasm.yml"
- ".github/**"
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24

- run: nix build .#prisma-schema-wasm
- run: nix flake check
25 changes: 0 additions & 25 deletions .github/workflows/build-wasm.yml

This file was deleted.

26 changes: 12 additions & 14 deletions .github/workflows/benchmark.yml → .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
name: Benchmark
name: "QE: Codespeed benchmarks"
on:
push:
branches:
- main
pull_request:
paths-ignore:
- '.github/**'
- '!.github/workflows/benchmark.yml'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
- 'CODEOWNERS'
- 'renovate.json'
- ".github/**"
- "!.github/workflows/benchmark.yml"
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"

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

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

run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -29,14 +27,14 @@ jobs:
- name: Install cargo-codspeed
run: cargo install cargo-codspeed

- name: 'Build the benchmark targets: schema'
- name: "Build the benchmark targets: schema"
run: cargo codspeed build -p schema

- name: 'Build the benchmark targets: request-handlers'
- name: "Build the benchmark targets: request-handlers"
run: cargo codspeed build -p request-handlers

- name: Run the benchmarks
uses: CodSpeedHQ/action@v1
uses: CodSpeedHQ/action@v2
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
40 changes: 0 additions & 40 deletions .github/workflows/compilation.yml

This file was deleted.

Loading

0 comments on commit e0314e8

Please sign in to comment.