Skip to content

Commit 35aa6d0

Browse files
authored
[Tools] Run Prisma 4.8 on verified Node 24 (#11)
1 parent 84e8824 commit 35aa6d0

13 files changed

Lines changed: 926 additions & 111 deletions

File tree

‎.github/actionlint.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
self-hosted-runner:
2+
labels:
3+
- namespace-profile-gitar
4+
- namespace-profile-gitar-macos

‎.github/workflows/ci.yaml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: CI
22
on:
33
pull_request:
4+
branches: [main]
45
push:
56
branches:
67
- main
@@ -39,11 +40,11 @@ jobs:
3940
- name: Rename existing rust toolchain (Windows)
4041
if: matrix.os == 'windows-latest'
4142
run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
42-
43+
4344
- name: Instal libssl (Ubuntu)
4445
if: matrix.os == 'ubuntu-latest'
4546
run: sudo apt-get install libssl-dev
46-
47+
4748
- name: Install Rust toolchain
4849
uses: actions-rs/toolchain@v1
4950
with:
@@ -54,7 +55,7 @@ jobs:
5455

5556
- name: Cache Dependencies
5657
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
57-
58+
5859
- name: Generate client
5960
working-directory: integration-tests
6061
run: cargo prisma generate

‎.github/workflows/compatibility.yaml‎

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Compatibility binaries
22
on:
33
push:
44
branches: [gitar-0.6.11, gitar-rustls-engines]
5+
pull_request:
6+
branches: [gitar-0.6.11, gitar-rustls-engines]
57
workflow_dispatch:
68
permissions:
79
contents: read
@@ -15,12 +17,15 @@ jobs:
1517
- target: aarch64-apple-darwin
1618
runner: namespace-profile-gitar-macos
1719
features: postgresql,mocking
20+
platform: darwin
1821
- target: x86_64-unknown-linux-gnu
1922
runner: namespace-profile-gitar
2023
features: postgresql,mocking
24+
platform: linux/amd64
2125
- target: aarch64-unknown-linux-gnu
2226
runner: namespace-profile-gitar
2327
features: postgresql,mocking
28+
platform: linux/arm64
2429
runs-on: ${{ matrix.runner }}
2530
steps:
2631
- uses: namespacelabs/nscloud-checkout-action@v8
@@ -60,27 +65,62 @@ jobs:
6065
zip "prisma-cli-$TARGET.zip" "prisma-cli-$TARGET" source-sha.txt
6166
- name: Test archive verification
6267
if: matrix.target == 'aarch64-apple-darwin'
63-
run: cargo test --locked -p prisma-client-rust-cli --no-default-features --features postgresql,mocking --lib binaries::tests
64-
- name: Test x86 binary on Debian 12 with an empty engine cache
65-
if: matrix.target == 'x86_64-unknown-linux-gnu'
68+
run: cargo test --locked -p prisma-client-rust-cli --no-default-features --features postgresql,mocking --lib binaries
69+
- name: Check runner formatting and lints
70+
if: matrix.target == 'aarch64-apple-darwin'
71+
run: |
72+
cargo fmt --check -p prisma-client-rust-cli
73+
cargo clippy --locked -p prisma-client-rust-cli -p prisma-cli \
74+
--no-default-features --features postgresql,mocking --all-targets
75+
- name: Download the previous generator baseline
76+
env:
77+
TARGET: ${{ matrix.target }}
78+
run: |
79+
python3 tests/compatibility/baseline.py "$TARGET"
80+
- name: Test macOS runner with an empty cache
81+
if: matrix.target == 'aarch64-apple-darwin'
6682
run: |
67-
cp artifacts/prisma-cli-x86_64-unknown-linux-gnu tests/compatibility/prisma
68-
docker run --rm -v "$PWD/tests/compatibility:/work" debian:bookworm-slim sh -ec '
69-
apt-get update -qq
70-
apt-get install -y -qq ca-certificates rustfmt
71-
# Fail if the wrapper regresses to invoking OpenSSL for engine selection.
72-
printf "#!/bin/sh\nexit 99\n" > /work/openssl
73-
chmod +x /work/openssl
74-
export PATH=/work:$PATH
75-
export DATABASE_URL=postgresql://postgres@localhost:5432/postgres
76-
prisma generate --schema /work/schema.prisma
77-
test -s /work/prisma.rs
78-
prisma --version
79-
if prisma generate --schema /work/does-not-exist.prisma; then
80-
echo "Invalid Prisma commands must fail"
81-
exit 1
82-
fi
83-
'
83+
python3 tests/compatibility/runner.py target/${{ matrix.target }}/release/prisma \
84+
--baseline baseline/prisma --work-dir runner-results
85+
- uses: docker/setup-qemu-action@v3
86+
if: matrix.target == 'aarch64-unknown-linux-gnu'
87+
with:
88+
platforms: arm64
89+
- name: Test Linux runner with disposable PostgreSQL
90+
if: matrix.target != 'aarch64-apple-darwin'
91+
env:
92+
TARGET: ${{ matrix.target }}
93+
PLATFORM: ${{ matrix.platform }}
94+
run: |
95+
docker network create runner-test
96+
trap 'docker rm -f runner-db; docker network rm runner-test' EXIT
97+
docker run -d --name runner-db --network runner-test --network-alias fixture-db \
98+
-e POSTGRES_PASSWORD=fixture -e POSTGRES_DB=runner_fixture postgres:17
99+
for attempt in $(seq 1 30); do
100+
if docker exec runner-db pg_isready -U postgres; then break; fi
101+
sleep 1
102+
done
103+
docker run --rm --platform "$PLATFORM" --network runner-test \
104+
-v "$PWD:/work" -e TARGET="$TARGET" -w /work debian:bookworm-slim sh -ec '
105+
apt-get update -qq
106+
apt-get install -y -qq ca-certificates openssl rustfmt python3
107+
python3 tests/compatibility/runner.py "target/$TARGET/release/prisma" \
108+
--baseline baseline/prisma --work-dir runner-results \
109+
--database-url postgresql://postgres:fixture@fixture-db:5432/runner_fixture
110+
'
111+
- uses: actions/upload-artifact@v4
112+
if: always()
113+
with:
114+
name: runner-results-${{ matrix.target }}
115+
path: |
116+
runner-results/results.json
117+
runner-results/*.stdout
118+
runner-results/*.stderr
119+
runner-results/schema-*/*.stdout
120+
runner-results/schema-*/*.stderr
121+
runner-results/database/*.stdout
122+
runner-results/database/*.stderr
123+
retention-days: 7
84124
- uses: actions/upload-artifact@v4
85125
with:
86126
name: prisma-cli-${{ matrix.target }}-${{ github.sha }}
@@ -142,3 +182,17 @@ jobs:
142182
if grep -E '^(native-tls|openssl|openssl-sys|postgres-native-tls) v' /tmp/quaint-dependencies.txt; then
143183
exit 1
144184
fi
185+
ci-success:
186+
if: always()
187+
needs: [build, driver-tests, quaint-tests]
188+
runs-on: ubuntu-latest
189+
steps:
190+
- name: Require every compatibility job
191+
env:
192+
JOB_RESULTS: ${{ toJson(needs) }}
193+
run: |
194+
python3 - <<'PYTHON'
195+
import json, os
196+
results = json.loads(os.environ["JOB_RESULTS"])
197+
assert all(job["result"] == "success" for job in results.values()), results
198+
PYTHON

‎Cargo.lock‎

Lines changed: 41 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cli/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ mongodb = ["prisma-client-rust-sdk/mongodb"]
2222

2323
[dependencies]
2424
sha2 = "0.10"
25+
tar = "0.4"
26+
tempfile = "3"
2527
serde_json.workspace = true
2628
serde.workspace = true
2729
serde_path_to_error = "0.1.7"

‎cli/src/binaries/mod.rs‎

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
pub mod platform;
2+
mod runner;
23

34
use directories::BaseDirs;
45
use flate2::read::GzDecoder;
56
use reqwest::blocking as reqwest;
67
use sha2::{Digest, Sha256};
78
use std::collections::BTreeMap;
8-
use std::fs::{create_dir_all, metadata, File};
9+
use std::fs::{create_dir_all, File};
910
use std::io;
1011
use std::io::prelude::*;
1112
use std::path::{Path, PathBuf};
@@ -38,67 +39,37 @@ pub const ENGINES: [Engine; 4] = [
3839
},
3940
];
4041

41-
pub fn prisma_cli_name() -> String {
42-
let variation = platform::name();
43-
let arch = platform::arch();
44-
45-
format!("prisma-cli-{variation}-{arch}")
46-
}
47-
48-
pub fn global_cache_dir() -> PathBuf {
49-
let base_dirs = BaseDirs::new().unwrap();
42+
pub fn global_cache_dir() -> Result<PathBuf, String> {
43+
if let Some(path) = std::env::var_os("PRISMA_CLI_CACHE_DIR") {
44+
let path = PathBuf::from(path);
45+
if !path.is_absolute() {
46+
return Err("PRISMA_CLI_CACHE_DIR must be absolute".into());
47+
}
48+
return Ok(path);
49+
}
50+
let base_dirs = BaseDirs::new().ok_or("Cannot resolve the Prisma cache directory")?;
5051
let cache_dir = base_dirs.cache_dir();
5152

52-
cache_dir
53+
Ok(cache_dir
5354
.join(BASE_DIR_NAME)
5455
.join("cli")
55-
.join(PRISMA_CLI_VERSION)
56+
.join(PRISMA_CLI_VERSION))
5657
}
5758

58-
pub fn fetch_native(to_dir: &PathBuf) -> Result<(), String> {
59+
pub fn fetch_native(to_dir: &Path) -> Result<runner::Runner, String> {
5960
if !to_dir.is_absolute() {
6061
Err("to_dir must be absolute".to_string())?;
6162
}
6263

63-
download_cli(to_dir)?;
64+
let runner = runner::install(to_dir)?;
6465

6566
for e in &ENGINES {
6667
if std::env::var_os(e.env).is_none() {
6768
download_engine(e.name, to_dir)?;
6869
}
6970
}
7071

71-
Ok(())
72-
}
73-
74-
pub fn download_cli(to_dir: &PathBuf) -> Result<(), String> {
75-
let cli = prisma_cli_name();
76-
77-
let to = platform::check_for_extension(&platform::name(), &to_dir.join(cli).to_str().unwrap());
78-
79-
let url = platform::check_for_extension(
80-
&platform::name(),
81-
&format!(
82-
"https://prisma-photongo.s3-eu-west-1.amazonaws.com/{}-{}-{}-{}.gz",
83-
"prisma-cli",
84-
PRISMA_CLI_VERSION,
85-
platform::name(),
86-
platform::arch()
87-
),
88-
);
89-
90-
match metadata(&to) {
91-
Err(_) => (),
92-
Ok(_) => {
93-
return Ok(());
94-
}
95-
};
96-
97-
println!("Downloading {} to {}", url, to);
98-
99-
download(&url, Path::new(&to), None)?;
100-
101-
Ok(())
72+
Ok(runner)
10273
}
10374

10475
#[derive(serde::Deserialize)]

0 commit comments

Comments
 (0)