Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade Deno #870

Merged
merged 9 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
# be sure to also update these in other workflows
DENO_DIR: deno_dir
DENO_VERSION: "1.32.1"
DENO_VERSION: "1.40.3"

jobs:
build:
Expand All @@ -30,7 +30,7 @@ jobs:
restore-keys: ci-

- name: Setup Deno
uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba
with:
deno-version: ${{ env.DENO_VERSION }}

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
# be sure to also update these in other workflows
DENO_DIR: deno_dir
DENO_VERSION: "1.32.1"
DENO_VERSION: "1.40.3"

jobs:
lint:
Expand All @@ -31,7 +31,7 @@ jobs:
restore-keys: ci-

- name: Setup Deno
uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba
with:
deno-version: ${{ env.DENO_VERSION }}

Expand All @@ -56,7 +56,7 @@ jobs:
restore-keys: ci-

- name: Setup Deno
uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba
with:
deno-version: ${{ env.DENO_VERSION }}

Expand All @@ -81,7 +81,7 @@ jobs:
restore-keys: ci-

- name: Setup Deno
uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba
with:
deno-version: ${{ env.DENO_VERSION }}

Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
restore-keys: ci-

- name: Setup Deno
uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba
with:
deno-version: ${{ env.DENO_VERSION }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
# be sure to also update these in other workflows
DENO_DIR: deno_dir
DENO_VERSION: "1.32.1"
DENO_VERSION: "1.40.3"

permissions: {}
jobs:
Expand All @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- name: Setup Deno
uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba
with:
deno-version: ${{ env.DENO_VERSION }}

Expand Down
12 changes: 6 additions & 6 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
},
"importMap": "importmap.json",
"tasks": {
"dev": "deno run --unstable --allow-env --allow-run --allow-read --allow-write --allow-net scripts/dev.js",
"lint": "deno run --allow-env --allow-read --allow-write --allow-run=git scripts/lint.js",
"check": "deno run --unstable --allow-env --allow-run --allow-read --allow-write --allow-net scripts/check.js",
"test": "deno run --unstable --allow-run --allow-read --allow-write --allow-env --allow-net scripts/test.js",
"build-engine": "deno run --unstable --allow-read --allow-write --allow-net --allow-env scripts/buildEngine.js",
"build-studio": "deno run --unstable -A scripts/buildStudio.js",
"dev": "deno run --allow-env --allow-run --allow-read --allow-write --allow-net scripts/dev.js",
"lint": "deno run --allow-env --allow-read --allow-write --allow-sys --allow-run=git scripts/lint.js",
"check": "deno run --allow-env --allow-run --allow-read --allow-write --allow-net scripts/check.js",
"test": "deno run --allow-run --allow-read --allow-write --allow-env --allow-net scripts/test.js",
"build-engine": "deno run --allow-read --allow-write --allow-net --allow-env scripts/buildEngine.js",
"build-studio": "deno run -A scripts/buildStudio.js",
"build-npm-package": "deno run --allow-read --allow-write scripts/buildNpmPackage.js"
}
}
18 changes: 11 additions & 7 deletions scripts/buildStudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,21 @@ function rebaseCssUrl({
* @param {string} cmd
*/
async function runCmd(cmd) {
const p = Deno.run({
cmd: cmd.split(" "),
const splitCmd = cmd.split(" ");
if (splitCmd.length <= 0) {
throw new Error("Invalid command: " + cmd);
}
const [exec, ...args] = splitCmd;
const command = new Deno.Command(exec, {
args,
stdout: "piped",
});
const status = await p.status();
if (!status.success) {
throw new Error(`Running "${cmd}" exited with status code ${status.code}`);
const output = await command.output();
if (!output.success) {
throw new Error(`Running "${cmd}" exited with status code ${output.code}`);
}
const outputBuffer = await p.output();
const outputBuffer = output.stdout;
let outputStr = new TextDecoder().decode(outputBuffer);
p.close();
outputStr = outputStr.trim();
if (!outputStr) {
throw new Error(`Running "${cmd}" resulted in an empty string`);
Expand Down
12 changes: 7 additions & 5 deletions scripts/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import {dev} from "./dev.js";

await dev({
needsTypes: true,
needsTypesSync: true,
needsDependencies: true,
});

const proc = Deno.run({
// Also update the version in ./scripts/dev.js
cmd: ["deno", "run", "--allow-env", "--allow-read", "npm:[email protected]/tsc", "--noEmit", "-p", "./jsconfig.json"],
const command = new Deno.Command(Deno.execPath(), {
args: ["run", "--allow-env", "--allow-read", "npm:[email protected]/tsc", "--noEmit", "-p", "./jsconfig.json"],
stdout: "inherit",
stderr: "inherit",
});

const status = await proc.status();
if (!status.success) {
const output = await command.output();
if (!output.success) {
Deno.exit(1);
} else {
console.log("No type errors!");
Expand Down
92 changes: 53 additions & 39 deletions scripts/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,62 @@ export async function dev({
if (needsTypes) {
const {generateTypes} = await import("https://deno.land/x/[email protected]/mod.js");

const promise = generateTypes({
outputDir: ".denoTypes",
unstable: true,
importMap: "importmap.json",
include: [
"scripts",
"test/shared/",
"test/unit/",
"test/e2e/shared/",
"test/e2e/studio/shared/",
"test/e2e/studio/src/",
"studio/devSocket",
],
excludeUrls: [
"rollup-plugin-cleanup",
"https://deno.land/x/[email protected]/mod.js", // Temporary workaround for https://github.com/denoland/deno/issues/17210
"npm:[email protected]",
"npm:[email protected]",
"npm:[email protected]",
const cwd = Deno.cwd();

// The StudioDiscovery references some types from the main Renda repository,
// but some of these files have css import assertions, causing deno vendor to fail
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/util.js",
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/TypedMessenger/TypedMessenger.js",
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/discoveryMethods/WebRtcDiscoveryMethod.js",
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/DiscoveryManager.js",
],
extraTypeRoots: {
const promise = (async () => {
await generateTypes({
outputDir: ".denoTypes",
importMap: "importmap.json",
include: [
"scripts",
"test/shared/",
"test/unit/",
"test/e2e/shared/",
"test/e2e/studio/shared/",
"test/e2e/studio/src/",
"studio/devSocket",
],
excludeUrls: [
"rollup-plugin-cleanup",
"https://deno.land/x/[email protected]/mod.js", // Temporary workaround for https://github.com/denoland/deno/issues/17210
"npm:[email protected]",
"npm:[email protected]",
"npm:[email protected]",

// The StudioDiscovery references some types from the main Renda repository,
// but some of these files have css import assertions, causing deno vendor to fail
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/util.js",
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/util/TypedMessenger/TypedMessenger.js",
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/discoveryMethods/WebRtcDiscoveryMethod.js",
"https://raw.githubusercontent.com/rendajs/Renda/3570dc24d41ef1522a97371ebdc2e7b88d15317d/src/network/studioConnections/DiscoveryManager.js",
],
extraTypeRoots: {
// We prefix webgpu with aa to ensure it is placed above deno-types.
// The Deno types include webgpu types but they are outdated.
"aa-webgpu": "https://cdn.jsdelivr.net/npm/@webgpu/[email protected]/dist/index.d.ts",
"wicg-file-system-access": "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
"strict-map": "https://deno.land/x/[email protected]/src/map.d.ts",
"strict-set": "https://deno.land/x/[email protected]/src/set.d.ts",
},
exactTypeModules: {
eslint: "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
estree: "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
"npm:[email protected]": "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
},
logLevel: suppressTypesLogging ? "WARNING" : "DEBUG",
});
"aa-webgpu": "https://cdn.jsdelivr.net/npm/@webgpu/[email protected]/dist/index.d.ts",
"wicg-file-system-access": "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
"strict-map": "https://deno.land/x/[email protected]/src/map.d.ts",
"strict-set": "https://deno.land/x/[email protected]/src/set.d.ts",
},
exactTypeModules: {
eslint: "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
estree: "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
"npm:[email protected]": "https://cdn.jsdelivr.net/npm/@types/[email protected]/index.d.ts",
},
logLevel: suppressTypesLogging ? "WARNING" : "DEBUG",
});

// Some of Deno's webgpu types clash with ours
const pathMod = await import("std/path/mod.ts");
const denoTypesPath = pathMod.resolve(cwd, ".denoTypes/@types/deno-types/index.d.ts");
const denoTypes = await Deno.readTextFile(denoTypesPath);
const canvasConfigurationStart = denoTypes.indexOf("declare interface GPUCanvasConfiguration");
if (canvasConfigurationStart > 0) {
const canvasConfigurationEnd = denoTypes.indexOf("}", canvasConfigurationStart) + 1;
const newDenoTypes = denoTypes.slice(0, canvasConfigurationStart) + denoTypes.slice(canvasConfigurationEnd);
await Deno.writeTextFile(denoTypesPath, newDenoTypes);
}
})();

// eslint-disable-next-line no-constant-condition
if (false) {
Expand Down
10 changes: 5 additions & 5 deletions scripts/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ if (useIo) {
if (Deno.args.includes("--all")) {
lintFilesStr = "**/*.js";
} else {
const proc = Deno.run({
cmd: ["git", "status", "-z"],
const command = new Deno.Command("git", {
args: ["status", "-z"],
stdout: "piped",
});
const status = await proc.status();
if (!status.success) {
const output = await command.output();
if (!output.success) {
throw new Error("Failed to determine which files were changed, run with --all to lint all files in the repository.");
}
const result = await proc.output();
const result = output.stdout;

let files = [];
let i = 0;
Expand Down
54 changes: 30 additions & 24 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const testCommands = [];

// Unit tests
if (needsUnitTests) {
const denoTestArgs = ["deno", "test", "--no-check", "--allow-env", "--allow-read", "--allow-net", "--parallel"];
const denoTestArgs = [Deno.execPath(), "test", "--no-check", "--allow-env", "--allow-read", "--allow-net", "--parallel"];
if (needsCoverage) {
denoTestArgs.push("--allow-write");
}
Expand All @@ -74,19 +74,19 @@ if (needsUnitTests) {

// E2e tests
if (needsE2eTests) {
const cmd = ["deno", "run", "--allow-env", "--allow-read", "--allow-write", "--allow-run", "--allow-net"];
const cmd = [Deno.execPath(), "run", "--allow-env", "--allow-read", "--allow-write", "--allow-run", "--allow-net"];
if (inspect) cmd.push("--inspect-brk");
cmd.push("test/e2e/shared/e2eTestRunner.js", ...Deno.args);
testCommands.push(cmd);
}

let lastTestStatus;
for (const cmd of testCommands) {
console.log(`Running: ${cmd.join(" ")}`);
const testProcess = Deno.run({cmd});
lastTestStatus = await testProcess.status();
if (!lastTestStatus.success) {
Deno.exit(lastTestStatus.code);
const [exec, ...args] = cmd;
const testCommand = new Deno.Command(exec, {args, stdout: "inherit", stderr: "inherit"});
const testOutput = await testCommand.output();
if (!testOutput.success) {
Deno.exit(testOutput.code);
}
}

Expand All @@ -103,31 +103,37 @@ if (needsCoverage) {
}
if (coverageMapExists) {
console.log("Applying fake-imports coverage map.");
const p = Deno.run({
cmd: ["deno", "run", "--allow-read", "--no-check", "--allow-write", "https://deno.land/x/[email protected]/applyCoverageMap.js", FAKE_IMPORTS_COVERAGE_DIR, DENO_COVERAGE_DIR],
const cmd = new Deno.Command(Deno.execPath(), {
args: ["run", "--allow-read", "--no-check", "--allow-write", "https://deno.land/x/[email protected]/applyCoverageMap.js", FAKE_IMPORTS_COVERAGE_DIR, DENO_COVERAGE_DIR],
stdout: "inherit",
stderr: "inherit",
});
await p.status();
const output = await cmd.output();
if (!output.success) {
throw new Error(`Applying fake-imports coverage map failed with status ${output.code}`);
}
}

console.log("Generating cov.lcov...");
const includeRegex = `^file://${Deno.cwd()}/(src|studio/src|studio/devSocket/src)`;
const coverageProcess = Deno.run({
cmd: ["deno", "coverage", DENO_COVERAGE_DIR, "--lcov", `--include=${includeRegex}`],
const coverageProcess = new Deno.Command(Deno.execPath(), {
args: ["coverage", DENO_COVERAGE_DIR, "--lcov", `--include=${includeRegex}`],
stdout: "piped",
});
const lcov = await coverageProcess.output();
const coverageStatus = await coverageProcess.status();
if (!coverageStatus.success) {
Deno.exit(coverageStatus.code);
const coverageOutput = await coverageProcess.output();
if (!coverageOutput.success) {
Deno.exit(coverageOutput.code);
}
await Deno.writeFile(".coverage/cov.lcov", lcov);
await Deno.writeFile(".coverage/cov.lcov", coverageOutput.stdout);

if (needsHtmlCoverageReport) {
console.log("Generating HTML coverage report...");
let genHtmlProcess = null;
let genHtmlCommand = null;
try {
genHtmlProcess = Deno.run({
cmd: ["genhtml", "-o", ".coverage/html", ".coverage/cov.lcov"],
genHtmlCommand = new Deno.Command("genhtml", {
args: ["-o", ".coverage/html", ".coverage/cov.lcov"],
stdout: "inherit",
stderr: "inherit",
});
} catch {
console.error("%cERROR%c Failed to generate html report, is lcov not installed?", "color: red", "");
Expand All @@ -140,10 +146,10 @@ if (needsCoverage) {
console.log(`Try installing it with: %c${installCmd}`, "color: black; background-color: grey");
}
}
if (genHtmlProcess) {
const genHtmlStatus = await genHtmlProcess.status();
if (!genHtmlStatus.success) {
Deno.exit(genHtmlStatus.code);
if (genHtmlCommand) {
const genHtmlOutput = await genHtmlCommand.output();
if (!genHtmlOutput.success) {
Deno.exit(genHtmlOutput.code);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/studio/src/misc/ServiceWorkerManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SERVICE_WORKER_CLIENT_ID = "service worker client id";
* @property {(now: number) => void} setPreformanceNow Sets the return value for `preformance.now()`
* @property {(pending: boolean) => void} setUpdatePromisePending
* @property {() => Promise<void>} waitForMicrotasks
* @property {import("std/testing/mock.ts").Stub<Location, [], void>} reloadSpy
* @property {import("std/testing/mock.ts").Stub<Location, [forceReload: boolean], void>} reloadSpy
* @property {import("std/testing/mock.ts").Spy<any, [], void>} registerClientSpy
* @property {import("std/testing/mock.ts").Spy<any, [], void>} unregisterClientSpy
* @property {import("std/testing/mock.ts").Spy<any, [], Promise<void>>} skipWaitingSpy
Expand Down
Loading