rwsdk 1.0.0-beta.2-test.20250930092748 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const SETUP_PLAYGROUND_ENV_TIMEOUT: number;
|
|
2
|
+
export declare const DEPLOYMENT_TIMEOUT: number;
|
|
3
|
+
export declare const DEPLOYMENT_MIN_TRIES: number;
|
|
4
|
+
export declare const DEPLOYMENT_CHECK_TIMEOUT: number;
|
|
5
|
+
export declare const PUPPETEER_TIMEOUT: number;
|
|
6
|
+
export declare const HYDRATION_TIMEOUT: number;
|
|
7
|
+
export declare const DEV_SERVER_TIMEOUT: number;
|
|
8
|
+
export declare const DEV_SERVER_MIN_TRIES: number;
|
|
9
|
+
export declare const SETUP_WAIT_TIMEOUT: number;
|
|
10
|
+
export declare const TEST_MAX_RETRIES: number;
|
|
11
|
+
export declare const TEST_MAX_RETRIES_PER_CODE: number;
|
|
12
|
+
export declare const INSTALL_DEPENDENCIES_RETRIES: number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const SETUP_PLAYGROUND_ENV_TIMEOUT = process.env
|
|
2
|
+
.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT
|
|
3
|
+
? parseInt(process.env.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT, 10)
|
|
4
|
+
: 15 * 60 * 1000;
|
|
5
|
+
export const DEPLOYMENT_TIMEOUT = process.env.RWSDK_DEPLOYMENT_TIMEOUT
|
|
6
|
+
? parseInt(process.env.RWSDK_DEPLOYMENT_TIMEOUT, 10)
|
|
7
|
+
: 5 * 60 * 1000;
|
|
8
|
+
export const DEPLOYMENT_MIN_TRIES = process.env.RWSDK_DEPLOYMENT_MIN_TRIES
|
|
9
|
+
? parseInt(process.env.RWSDK_DEPLOYMENT_MIN_TRIES, 10)
|
|
10
|
+
: 5;
|
|
11
|
+
export const DEPLOYMENT_CHECK_TIMEOUT = process.env
|
|
12
|
+
.RWSDK_DEPLOYMENT_CHECK_TIMEOUT
|
|
13
|
+
? parseInt(process.env.RWSDK_DEPLOYMENT_CHECK_TIMEOUT, 10)
|
|
14
|
+
: 5 * 60 * 1000;
|
|
15
|
+
export const PUPPETEER_TIMEOUT = process.env.RWSDK_PUPPETEER_TIMEOUT
|
|
16
|
+
? parseInt(process.env.RWSDK_PUPPETEER_TIMEOUT, 10)
|
|
17
|
+
: 60 * 1000 * 2;
|
|
18
|
+
export const HYDRATION_TIMEOUT = process.env.RWSDK_HYDRATION_TIMEOUT
|
|
19
|
+
? parseInt(process.env.RWSDK_HYDRATION_TIMEOUT, 10)
|
|
20
|
+
: 5000;
|
|
21
|
+
export const DEV_SERVER_TIMEOUT = process.env.RWSDK_DEV_SERVER_TIMEOUT
|
|
22
|
+
? parseInt(process.env.RWSDK_DEV_SERVER_TIMEOUT, 10)
|
|
23
|
+
: 5 * 60 * 1000;
|
|
24
|
+
export const DEV_SERVER_MIN_TRIES = process.env.RWSDK_DEV_SERVER_MIN_TRIES
|
|
25
|
+
? parseInt(process.env.RWSDK_DEV_SERVER_MIN_TRIES, 10)
|
|
26
|
+
: 5;
|
|
27
|
+
export const SETUP_WAIT_TIMEOUT = process.env.RWSDK_SETUP_WAIT_TIMEOUT
|
|
28
|
+
? parseInt(process.env.RWSDK_SETUP_WAIT_TIMEOUT, 10)
|
|
29
|
+
: 10 * 60 * 1000;
|
|
30
|
+
export const TEST_MAX_RETRIES = process.env.RWSDK_TEST_MAX_RETRIES
|
|
31
|
+
? parseInt(process.env.RWSDK_TEST_MAX_RETRIES, 10)
|
|
32
|
+
: 10;
|
|
33
|
+
export const TEST_MAX_RETRIES_PER_CODE = process.env
|
|
34
|
+
.RWSDK_TEST_MAX_RETRIES_PER_CODE
|
|
35
|
+
? parseInt(process.env.RWSDK_TEST_MAX_RETRIES_PER_CODE, 10)
|
|
36
|
+
: 6;
|
|
37
|
+
export const INSTALL_DEPENDENCIES_RETRIES = process.env
|
|
38
|
+
.RWSDK_INSTALL_DEPENDENCIES_RETRIES
|
|
39
|
+
? parseInt(process.env.RWSDK_INSTALL_DEPENDENCIES_RETRIES, 10)
|
|
40
|
+
: 10;
|
|
@@ -3,7 +3,7 @@ import { PackageManager } from "./types.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* Copy project to a temporary directory with a unique name
|
|
5
5
|
*/
|
|
6
|
-
export declare function copyProjectToTempDir(projectDir: string, resourceUniqueKey: string, packageManager?: PackageManager, monorepoRoot?: string): Promise<{
|
|
6
|
+
export declare function copyProjectToTempDir(projectDir: string, resourceUniqueKey: string, packageManager?: PackageManager, monorepoRoot?: string, installDependenciesRetries?: number): Promise<{
|
|
7
7
|
tempDir: tmp.DirectoryResult;
|
|
8
8
|
targetDir: string;
|
|
9
9
|
workerName: string;
|
|
@@ -8,8 +8,12 @@ import { basename, join, relative, resolve } from "path";
|
|
|
8
8
|
import tmp from "tmp-promise";
|
|
9
9
|
import { $ } from "../../lib/$.mjs";
|
|
10
10
|
import { ROOT_DIR } from "../constants.mjs";
|
|
11
|
+
import { INSTALL_DEPENDENCIES_RETRIES } from "./constants.mjs";
|
|
11
12
|
import { retry } from "./retry.mjs";
|
|
12
13
|
const log = debug("rwsdk:e2e:environment");
|
|
14
|
+
const getTempDir = async () => {
|
|
15
|
+
return tmp.dir({ unsafeCleanup: true });
|
|
16
|
+
};
|
|
13
17
|
const createSdkTarball = async () => {
|
|
14
18
|
const existingTarballPath = process.env.RWSKD_SMOKE_TEST_TARBALL_PATH;
|
|
15
19
|
if (existingTarballPath) {
|
|
@@ -46,12 +50,11 @@ const setTarballDependency = async (targetDir, tarballName) => {
|
|
|
46
50
|
/**
|
|
47
51
|
* Copy project to a temporary directory with a unique name
|
|
48
52
|
*/
|
|
49
|
-
export async function copyProjectToTempDir(projectDir, resourceUniqueKey, packageManager, monorepoRoot) {
|
|
53
|
+
export async function copyProjectToTempDir(projectDir, resourceUniqueKey, packageManager, monorepoRoot, installDependenciesRetries) {
|
|
50
54
|
const { tarballPath, cleanupTarball } = await createSdkTarball();
|
|
51
55
|
try {
|
|
52
56
|
log("Creating temporary directory for project");
|
|
53
|
-
|
|
54
|
-
const tempDir = await tmp.dir({ unsafeCleanup: true });
|
|
57
|
+
const tempDir = await getTempDir();
|
|
55
58
|
// Determine the source directory to copy from
|
|
56
59
|
const sourceDir = monorepoRoot || projectDir;
|
|
57
60
|
// Create unique project directory name
|
|
@@ -130,7 +133,6 @@ export async function copyProjectToTempDir(projectDir, resourceUniqueKey, packag
|
|
|
130
133
|
log("⚙️ Configuring temp project to not use frozen lockfile...");
|
|
131
134
|
const npmrcPath = join(targetDir, ".npmrc");
|
|
132
135
|
await fs.promises.writeFile(npmrcPath, "frozen-lockfile=false\n");
|
|
133
|
-
// For yarn, create .yarnrc.yml to disable PnP and allow lockfile changes
|
|
134
136
|
if (packageManager === "yarn") {
|
|
135
137
|
const yarnrcPath = join(targetDir, ".yarnrc.yml");
|
|
136
138
|
const yarnCacheDir = path.join(os.tmpdir(), "yarn-cache");
|
|
@@ -144,11 +146,19 @@ export async function copyProjectToTempDir(projectDir, resourceUniqueKey, packag
|
|
|
144
146
|
await fs.promises.writeFile(yarnrcPath, yarnConfig);
|
|
145
147
|
log("Created .yarnrc.yml to allow lockfile changes for yarn");
|
|
146
148
|
}
|
|
149
|
+
if (packageManager === "yarn-classic") {
|
|
150
|
+
const yarnrcPath = join(targetDir, ".yarnrc");
|
|
151
|
+
const yarnCacheDir = path.join(os.tmpdir(), "yarn-classic-cache");
|
|
152
|
+
await fs.promises.mkdir(yarnCacheDir, { recursive: true });
|
|
153
|
+
const yarnConfig = `cache-folder "${yarnCacheDir}"`;
|
|
154
|
+
await fs.promises.writeFile(yarnrcPath, yarnConfig);
|
|
155
|
+
log("Created .yarnrc with cache-folder for yarn-classic");
|
|
156
|
+
}
|
|
147
157
|
await setTarballDependency(targetDir, tarballFilename);
|
|
148
158
|
// Install dependencies in the target directory
|
|
149
159
|
const installDir = monorepoRoot ? tempCopyRoot : targetDir;
|
|
150
160
|
await retry(() => installDependencies(installDir, packageManager), {
|
|
151
|
-
retries:
|
|
161
|
+
retries: INSTALL_DEPENDENCIES_RETRIES,
|
|
152
162
|
delay: 1000,
|
|
153
163
|
});
|
|
154
164
|
// Return the environment details
|
|
@@ -185,7 +195,7 @@ async function installDependencies(targetDir, packageManager = "pnpm") {
|
|
|
185
195
|
}
|
|
186
196
|
else if (packageManager === "yarn-classic") {
|
|
187
197
|
log(`Preparing yarn@1.22.19 with corepack...`);
|
|
188
|
-
await $("corepack", ["prepare", "yarn@1.
|
|
198
|
+
await $("corepack", ["prepare", "yarn@1.x", "--activate"], {
|
|
189
199
|
cwd: targetDir,
|
|
190
200
|
stdio: "pipe",
|
|
191
201
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Browser, type Page } from "puppeteer-core";
|
|
2
2
|
import { test } from "vitest";
|
|
3
|
+
import { DEPLOYMENT_CHECK_TIMEOUT, DEPLOYMENT_MIN_TRIES, DEPLOYMENT_TIMEOUT, DEV_SERVER_MIN_TRIES, DEV_SERVER_TIMEOUT, HYDRATION_TIMEOUT, INSTALL_DEPENDENCIES_RETRIES, PUPPETEER_TIMEOUT, SETUP_PLAYGROUND_ENV_TIMEOUT, SETUP_WAIT_TIMEOUT, TEST_MAX_RETRIES, TEST_MAX_RETRIES_PER_CODE } from "./constants.mjs";
|
|
3
4
|
export type { Browser, Page } from "puppeteer-core";
|
|
5
|
+
export { DEPLOYMENT_CHECK_TIMEOUT, DEPLOYMENT_MIN_TRIES, DEPLOYMENT_TIMEOUT, DEV_SERVER_MIN_TRIES, DEV_SERVER_TIMEOUT, HYDRATION_TIMEOUT, INSTALL_DEPENDENCIES_RETRIES, PUPPETEER_TIMEOUT, SETUP_PLAYGROUND_ENV_TIMEOUT, SETUP_WAIT_TIMEOUT, TEST_MAX_RETRIES, TEST_MAX_RETRIES_PER_CODE, };
|
|
4
6
|
interface DevServerInstance {
|
|
5
7
|
url: string;
|
|
6
8
|
stopDev: () => Promise<void>;
|
|
@@ -4,44 +4,12 @@ import path, { basename, dirname, join as pathJoin } from "path";
|
|
|
4
4
|
import puppeteer from "puppeteer-core";
|
|
5
5
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, test, } from "vitest";
|
|
6
6
|
import { launchBrowser } from "./browser.mjs";
|
|
7
|
+
import { DEPLOYMENT_CHECK_TIMEOUT, DEPLOYMENT_MIN_TRIES, DEPLOYMENT_TIMEOUT, DEV_SERVER_MIN_TRIES, DEV_SERVER_TIMEOUT, HYDRATION_TIMEOUT, INSTALL_DEPENDENCIES_RETRIES, PUPPETEER_TIMEOUT, SETUP_PLAYGROUND_ENV_TIMEOUT, SETUP_WAIT_TIMEOUT, TEST_MAX_RETRIES, TEST_MAX_RETRIES_PER_CODE, } from "./constants.mjs";
|
|
7
8
|
import { runDevServer } from "./dev.mjs";
|
|
8
9
|
import { poll, pollValue } from "./poll.mjs";
|
|
9
10
|
import { deleteD1Database, deleteWorker, isRelatedToTest, runRelease, } from "./release.mjs";
|
|
10
11
|
import { setupTarballEnvironment } from "./tarball.mjs";
|
|
11
|
-
|
|
12
|
-
.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT
|
|
13
|
-
? parseInt(process.env.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT, 10)
|
|
14
|
-
: 15 * 60 * 1000;
|
|
15
|
-
const DEPLOYMENT_TIMEOUT = process.env.RWSDK_DEPLOYMENT_TIMEOUT
|
|
16
|
-
? parseInt(process.env.RWSDK_DEPLOYMENT_TIMEOUT, 10)
|
|
17
|
-
: 5 * 60 * 1000;
|
|
18
|
-
const DEPLOYMENT_MIN_TRIES = process.env.RWSDK_DEPLOYMENT_MIN_TRIES
|
|
19
|
-
? parseInt(process.env.RWSDK_DEPLOYMENT_MIN_TRIES, 10)
|
|
20
|
-
: 5;
|
|
21
|
-
const DEPLOYMENT_CHECK_TIMEOUT = process.env.RWSDK_DEPLOYMENT_CHECK_TIMEOUT
|
|
22
|
-
? parseInt(process.env.RWSDK_DEPLOYMENT_CHECK_TIMEOUT, 10)
|
|
23
|
-
: 5 * 60 * 1000;
|
|
24
|
-
const PUPPETEER_TIMEOUT = process.env.RWSDK_PUPPETEER_TIMEOUT
|
|
25
|
-
? parseInt(process.env.RWSDK_PUPPETEER_TIMEOUT, 10)
|
|
26
|
-
: 60 * 1000 * 2;
|
|
27
|
-
const HYDRATION_TIMEOUT = process.env.RWSDK_HYDRATION_TIMEOUT
|
|
28
|
-
? parseInt(process.env.RWSDK_HYDRATION_TIMEOUT, 10)
|
|
29
|
-
: 5000;
|
|
30
|
-
const DEV_SERVER_TIMEOUT = process.env.RWSDK_DEV_SERVER_TIMEOUT
|
|
31
|
-
? parseInt(process.env.RWSDK_DEV_SERVER_TIMEOUT, 10)
|
|
32
|
-
: 5 * 60 * 1000;
|
|
33
|
-
const DEV_SERVER_MIN_TRIES = process.env.RWSDK_DEV_SERVER_MIN_TRIES
|
|
34
|
-
? parseInt(process.env.RWSDK_DEV_SERVER_MIN_TRIES, 10)
|
|
35
|
-
: 5;
|
|
36
|
-
const SETUP_WAIT_TIMEOUT = process.env.RWSDK_SETUP_WAIT_TIMEOUT
|
|
37
|
-
? parseInt(process.env.RWSDK_SETUP_WAIT_TIMEOUT, 10)
|
|
38
|
-
: 10 * 60 * 1000;
|
|
39
|
-
const TEST_MAX_RETRIES = process.env.RWSDK_TEST_MAX_RETRIES
|
|
40
|
-
? parseInt(process.env.RWSDK_TEST_MAX_RETRIES, 10)
|
|
41
|
-
: 10;
|
|
42
|
-
const TEST_MAX_RETRIES_PER_CODE = process.env.RWSDK_TEST_MAX_RETRIES_PER_CODE
|
|
43
|
-
? parseInt(process.env.RWSDK_TEST_MAX_RETRIES_PER_CODE, 10)
|
|
44
|
-
: 6;
|
|
12
|
+
export { DEPLOYMENT_CHECK_TIMEOUT, DEPLOYMENT_MIN_TRIES, DEPLOYMENT_TIMEOUT, DEV_SERVER_MIN_TRIES, DEV_SERVER_TIMEOUT, HYDRATION_TIMEOUT, INSTALL_DEPENDENCIES_RETRIES, PUPPETEER_TIMEOUT, SETUP_PLAYGROUND_ENV_TIMEOUT, SETUP_WAIT_TIMEOUT, TEST_MAX_RETRIES, TEST_MAX_RETRIES_PER_CODE, };
|
|
45
13
|
// Environment variable flags for skipping tests
|
|
46
14
|
const SKIP_DEV_SERVER_TESTS = process.env.RWSDK_SKIP_DEV === "1";
|
|
47
15
|
const SKIP_DEPLOYMENT_TESTS = process.env.RWSDK_SKIP_DEPLOY === "1";
|