Skip to content

Commit

Permalink
Automation: main-next integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
msfluid-bot committed Aug 1, 2023
2 parents bd2d6ad + 1b21a44 commit 6276bd3
Show file tree
Hide file tree
Showing 47 changed files with 1,255 additions and 299 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/sync-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
with:
fetch-depth: "0" # all history
persist-credentials: false
# always check out the main branch by default. Otherwise the starting branch is based on the
# triggering event which can seem unpredictable when the workflow is triggered in different branches.
ref: main
- uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # ratchet:pnpm/action-setup@v2
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # ratchet:actions/setup-node@v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ export class ADOSizeComparator {

if (baselineBuild === undefined) {
baselineCommit = fallbackGen?.next().value;
// For reasons that I don't understand, the "undefined" string is omitted in the log output, which makes the
// output very confusing. The string is capitalized here and elsewhere in this file as a workaround.
console.log(
`Trying backup baseline commit when baseline build is undefined ${baselineCommit}`,
`Trying backup baseline commit when baseline build is UNDEFINED: ${baselineCommit}`,
);
continue;
}
Expand Down Expand Up @@ -162,7 +164,9 @@ export class ADOSizeComparator {
return undefined;
});

console.log(`Baseline Zip === undefined: ${baselineZip === undefined}`);
// For reasons that I don't understand, the "undefined" string is omitted in the log output, which makes the
// output very confusing. The string is capitalized here and elsewhere in this file as a workaround.
console.log(`Baseline Zip === UNDEFINED: ${baselineZip === undefined}`);

// Successful baseline build does not have the needed build artifacts
if (baselineZip === undefined) {
Expand All @@ -184,10 +188,7 @@ export class ADOSizeComparator {
return { message, comparison: undefined };
}

const comparison: BundleComparison[] = await this.createComparisonFromZip(
baselineCommit,
baselineZip,
);
const comparison: BundleComparison[] = await this.createComparisonFromZip(baselineZip);
console.log(JSON.stringify(comparison));

const message = getCommentForBundleDiff(comparison, baselineCommit);
Expand All @@ -212,10 +213,7 @@ export class ADOSizeComparator {
}
}

private async createComparisonFromZip(
baselineCommit: string,
baselineZip: JSZip,
): Promise<BundleComparison[]> {
private async createComparisonFromZip(baselineZip: JSZip): Promise<BundleComparison[]> {
const baselineZipBundlePaths = getBundlePathsFromZipObject(baselineZip);

const prBundleFileSystemPaths = await getBundlePathsFromFileSystem(this.localReportPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
import { fail } from "assert";

import { BundleMetric, WebpackStatsProcessor } from "../BundleBuddyTypes";
import { getChunkParsedSize } from "../utilities";

export interface EntryStatsProcessorOptions {
// Custom callback to customize what text will be used as the metric name
metricNameProvider?: (chunkName: string) => string;
}

/**
* A simple stats processor that simply returns the size information for the entry chunk
* Returns a stats processor that returns total asset size information for each entryPoint in the stats object
*/
export function getEntryStatsProcessor(options: EntryStatsProcessorOptions): WebpackStatsProcessor {
return (stats) => {
Expand All @@ -28,11 +25,17 @@ export function getEntryStatsProcessor(options: EntryStatsProcessorOptions): Web
const metricName = options.metricNameProvider
? options.metricNameProvider(chunkName)
: chunkName;

// Note: we have the getChunkParsedSize function, but the entrypoints objects we're analyzing here already
// have a list of the relevant assets and their sizes; no need to take the entrypoints' chunks and pass them to
// that function.
let totalSize: number = 0;
for (const asset of chunkGroupStats.assets ?? []) {
totalSize += asset?.size ?? 0;
}

result.set(metricName, {
parsedSize: getChunkParsedSize(
stats,
(chunkGroupStats.chunks ?? fail("missing chunk"))[0],
),
parsedSize: totalSize,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,33 @@ export function getChunkParsedSize(stats: StatsCompilation, chunkId: string | nu
);
}

const matchingAsset = stats.assets.find((asset) => {
//Find all the assets that contain the chunk. Note: an asset may contain more than one chunk.
const matchingAssets = stats.assets.filter((asset) => {
// Make sure to only look at js files and not source maps (assumes source maps don't end in .js)
if (asset.name.endsWith(".js")) {
// Assumes only a single chunk per asset, this may not hold for all apps.
return asset.chunks?.[0] === chunkId;
// If the asset contains the chunk, it should be considered when calculating the total size.
return asset.chunks?.includes(chunkId);
}

return false;
});

// If there's no matching asset it could be that it was removed in the new version of the bundle, not necessarily an
// error. In that case return 0 as its size.
return matchingAsset?.size ?? 0;
if (matchingAssets.length === 0) {
throw new Error(
`Could not find an asset for chunk with id '${chunkId}' in the webpack stats`,
);
}

if (matchingAssets.length > 1) {
// Typically we expect a single asset to be found per chunk (this is maybe not typical of all webpack projects, but
// it seems to be the case in our usage here), so if we find more than one, log a warning so we can investigate more
// easily if needed.
console.warn(
`${matchingAssets.length} assets contain chunk with id '${chunkId}'; will return total size of all matching assets.`,
);
}

// The total size is the sum of the sizes of all assets with the chunk.
const totalSize = matchingAssets.reduce((acc, asset) => acc + asset.size, 0);
return totalSize;
}
17 changes: 7 additions & 10 deletions examples/data-objects/table-document/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ module.exports = {
rules: {
"@typescript-eslint/strict-boolean-expressions": "off",
},
overrides: [
{
// Rules only for test files
files: ["*.spec.ts", "src/test/**"],
rules: {
// ESLint's resolver doesn't resolve relative imports of ESNext modules correctly, since
// it resolves the path relative to the .ts file (and assumes a file with a .js extension
// should exist there)
"import/no-unresolved": ["error", { ignore: ["^\\.(.*)\\.js$"] }],
settings: {
"import/resolver": {
// Use eslint-import-resolver-typescript.
// This ensures ESNext with `.js` extensions resolve correctly to their corresponding `.ts` files.
typescript: {
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
},
},
],
},
};
2 changes: 2 additions & 0 deletions examples/data-objects/table-document/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"eslint": "~8.6.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "~2.25.4",
"mocha": "^10.2.0",
"mocha-json-output-reporter": "^2.0.1",
"mocha-multi-reporters": "^1.5.1",
Expand Down
15 changes: 9 additions & 6 deletions examples/data-objects/webflow/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ module.exports = {
"max-len": "off",
"no-bitwise": "off",
"no-case-declarations": "off",
// ESLint's resolver doesn't resolve relative imports of ESNext modules correctly, since
// it resolves the path relative to the .ts file (and assumes a file with a .js extension
// should exist there)
// AB#4614 tracks moving to eslint-import-resolver-typescript (which handles such imports
// out of the box) and removing this exception.
"import/no-unresolved": ["error", { ignore: ["^\\.(.*)\\.js$"] }],
},
settings: {
"import/resolver": {
// Use eslint-import-resolver-typescript.
// This ensures ESNext with `.js` extensions resolve correctly to their corresponding `.ts` files.
typescript: {
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
},
},
},
parserOptions: {
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
Expand Down
2 changes: 2 additions & 0 deletions examples/data-objects/webflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
"cross-env": "^7.0.3",
"css-loader": "^1.0.0",
"eslint": "~8.6.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "~2.25.4",
"esm-loader-css": "^1.0.4",
"file-loader": "^3.0.1",
"html-loader": "^3.1.0",
Expand Down
13 changes: 10 additions & 3 deletions experimental/dds/tree2/src/shared-tree-core/editManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ export class EditManager<
Set<SharedTreeBranch<TEditor, TChangeset>>
>();

/** The sequence number of the newest commit on the trunk that has been received by all peers */
private minimumSequenceNumber: SeqNumber = brand(-1);
/**
* The sequence number of the newest commit on the trunk that has been received by all peers.
* Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.
*/
private minimumSequenceNumber = minimumPossibleSequenceNumber;

/**
* An immutable "origin" commit singleton on which the trunk is based.
Expand Down Expand Up @@ -300,7 +303,7 @@ export class EditManager<
this.trunk.getHead() === this.trunkBase &&
this.peerLocalBranches.size === 0 &&
this.localBranch.getHead() === this.trunk.getHead() &&
this.minimumSequenceNumber === -1
this.minimumSequenceNumber === minimumPossibleSequenceNumber
);
}

Expand Down Expand Up @@ -440,6 +443,10 @@ export class EditManager<
sequenceNumber: SeqNumber,
referenceSequenceNumber: SeqNumber,
): void {
assert(
sequenceNumber > this.minimumSequenceNumber,
"Expected change sequence number to exceed the last known minimum sequence number",
);
if (newCommit.sessionId === this.localSessionId) {
const [firstLocalCommit] = getPathFromBase(
this.localBranch.getHead(),
Expand Down
Loading

0 comments on commit 6276bd3

Please sign in to comment.