Skip to content
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: 3 additions & 1 deletion packages/cli/src/cli-build-provenance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createHash } from "node:crypto"
import { spawn } from "node:child_process"
import { existsSync } from "node:fs"
import { readFile, readdir, writeFile } from "node:fs/promises"
import { readFile, readdir, realpath, writeFile } from "node:fs/promises"
import { dirname, join, relative, resolve } from "node:path"

export const CLI_BUILD_PROVENANCE_FILE = "cli-build-provenance.json"
Expand Down Expand Up @@ -150,6 +150,8 @@ async function readPackageMetadata(packageRoot: string): Promise<{ name: string;
}

async function sourceIdentity(repositoryRoot: string, packageRoot: string): Promise<FileIdentity> {
repositoryRoot = await realpath(repositoryRoot)
packageRoot = await realpath(packageRoot)
const files = [
...(await recursiveFiles(join(packageRoot, "src"))),
join(packageRoot, "package.json"),
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-playground/src/browser-visual-compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ExecutionSpec, RuntimeCreateSpec } from "@automattic/wp-codebox-co
import { errorMessage, now, sha256 } from "@automattic/wp-codebox-core/internals"
import pixelmatch from "pixelmatch"
import { PNG } from "pngjs"
import sharp from "sharp"
import { BrowserArtifactSession } from "./browser-artifact-session.js"
import type { BrowserArtifact, BrowserProbeViewport } from "./browser-artifacts.js"
import { launchChromiumBrowser } from "./browser-capture-session.js"
Expand Down Expand Up @@ -1904,6 +1903,7 @@ function visualCompareAnimatedMediaCandidate(body: Buffer): boolean {
// the response first and reuse one static PNG buffer for identical content, so
// URL, navigation timing, and capture order cannot affect the selected frame.
async function installVisualCompareAnimatedMediaNormalization(page: Page, policy: "allow" | "first-frame", previewOrigin: string): Promise<VisualCompareAnimatedMediaTracker> {
const { default: sharp } = await import("sharp")
let observed = 0
let normalized = 0
let failed = 0
Expand Down
21 changes: 20 additions & 1 deletion tests/release-package-coverage.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert/strict"
import { execFile } from "node:child_process"
import { cp, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises"
import { cp, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises"
import { createHash } from "node:crypto"
import { tmpdir } from "node:os"
import { join, relative, resolve } from "node:path"
Expand Down Expand Up @@ -140,6 +140,7 @@ try {
version = cliVersion.stdout
assert.match(version, /^\d+\.\d+\.\d+\s*$/)
await execFileAsync(process.execPath, [cliEntrypoint, "commands"])
await assertCliStartsWithoutSharpRuntime(root, cliEntrypoint)
}
const descriptorModule = await import(pathToFileURL(join(root, "packages", "runtime-core", "dist", "runtime-contract-manifest.js")).href) as { runtimeDescriptor(): { capabilities: string[]; packageCapabilities: string[]; runtimeServices: { nativeMariaDb: { status: string } }; contractManifest: { capabilities: { runtimeServices: { packageCapabilities: string[] } } } } }
const descriptor = descriptorModule.runtimeDescriptor()
Expand Down Expand Up @@ -213,6 +214,24 @@ try {

console.log("release package coverage passed")

async function assertCliStartsWithoutSharpRuntime(root: string, cliEntrypoint: string): Promise<void> {
const nativePackages = sharpRuntimePackageNames(releasePlatform, releaseArch)
const disabledPackages: string[] = []
try {
for (const packageName of nativePackages) {
const packagePath = join(root, "node_modules", ...packageName.split("/"))
await rename(packagePath, `${packagePath}.disabled`)
disabledPackages.push(packagePath)
}
await execFileAsync(process.execPath, [cliEntrypoint, "--version"])
await execFileAsync(process.execPath, [cliEntrypoint, "commands"])
} finally {
for (const packagePath of disabledPackages.reverse()) {
await rename(`${packagePath}.disabled`, packagePath)
}
}
}

async function assertPinnedPhpWasmOverlay(root: string, provenancePath: string, allowInternalSymlink = false): Promise<void> {
const overlay = join(root, "node_modules", "@php-wasm", "node-8-3")
const overlayStat = await lstat(overlay)
Expand Down
Loading