-
Notifications
You must be signed in to change notification settings - Fork 698
chore(firestore): add automated presubmit serverless bundle size regression guard (#9075) #9075
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
Open
quirogas
wants to merge
12
commits into
feat/firestore-sdk-v9-decoupling
Choose a base branch
from
chore/presubmit-bundle-size-guard
base: feat/firestore-sdk-v9-decoupling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+45
−0
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
295baff
chore(firestore): add automated presubmit bundle size regression chec…
quirogas f2cfb91
revert(ci): restore upstream workflow files and linter script (#8928)
quirogas e072c0d
revert(ci): align workflow files and linter script with true upstream…
quirogas 2470255
Merge branch 'feat/firestore-sdk-v9-decoupling' into chore/presubmit-…
quirogas c0f41b5
Merge branch 'feat/firestore-sdk-v9-decoupling' into chore/presubmit-…
quirogas 0cf0a00
Merge branch 'feat/firestore-sdk-v9-decoupling' into chore/presubmit-…
quirogas 6586b84
Merge branch 'feat/firestore-sdk-v9-decoupling' into chore/presubmit-…
quirogas b9c55af
Merge branch 'feat/firestore-sdk-v9-decoupling' into chore/presubmit-…
quirogas eaec2e7
Merge branch 'feat/firestore-sdk-v9-decoupling' into chore/presubmit-…
quirogas 4a1b2d6
chore(firestore): sync dependencies and breaking changes from Layer 2…
quirogas 8c98669
chore(firestore): adopt os temporary directories and precheck lifecyc…
quirogas dd1eec1
chore(firestore): sync conformance harness proto discovery from Layer…
quirogas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "serverless_minimal_bundle": { | ||
| "entrypoint": "./build/src/index.js", | ||
| "target_minified_bytes": 2293760, | ||
| "max_minified_bytes_deduped": 2500000, | ||
| "max_minified_bytes_undeduped": 5000000, | ||
| "description": "2.19 MB minified target budget for standard serverless Cloud Function deployment" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||
| const path = require('path'); | ||||||||||||||||||||
| const os = require('os'); | ||||||||||||||||||||
| const { execSync } = require('child_process'); | ||||||||||||||||||||
| const budget = require('../bundle-budget.json'); | ||||||||||||||||||||
|
Comment on lines
+1
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To support creating a secure and collision-free temporary directory using
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'firestore-bundle-')); | ||||||||||||||||||||
| const entrypoint = path.join(tmpDir, 'test_bundle_input.js'); | ||||||||||||||||||||
| const outfile = path.join(tmpDir, 'test_bundle_out.min.js'); | ||||||||||||||||||||
| const buildIndexPath = path.resolve(__dirname, '../build/src/index'); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| fs.writeFileSync( | ||||||||||||||||||||
| entrypoint, | ||||||||||||||||||||
| '\nconst { Firestore } = require(' + | ||||||||||||||||||||
| JSON.stringify(buildIndexPath) + | ||||||||||||||||||||
| ');\nconst f = new Firestore();\nconsole.log(f);\n', | ||||||||||||||||||||
| 'utf8' | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try { | ||||||||||||||||||||
| execSync('npx --yes esbuild --bundle --platform=node --target=node18 --minify "' + entrypoint + '" --outfile="' + outfile + '"', { | ||||||||||||||||||||
| stdio: 'inherit', | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| const stats = fs.statSync(outfile); | ||||||||||||||||||||
| const size = stats.size; | ||||||||||||||||||||
| console.log(`[test-bundle-size] Compiled serverless bundle size: ${size} bytes`); | ||||||||||||||||||||
| if (size > budget.maxBundleSize) { | ||||||||||||||||||||
| console.error(`[test-bundle-size] ERROR: Bundle size (${size} bytes) exceeds budget (${budget.maxBundleSize} bytes)`); | ||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| console.log('[test-bundle-size] SUCCESS: Bundle size is within budget.'); | ||||||||||||||||||||
| } finally { | ||||||||||||||||||||
| fs.rmSync(tmpDir, { recursive: true, force: true }); | ||||||||||||||||||||
| } | ||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.